bluetooth.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This file was generated by:
  5. // tools/json_schema_compiler/compiler.py.
  6. // NOTE: The format of types has changed. 'FooType' is now
  7. // 'chrome.bluetooth.FooType'.
  8. // Please run the closure compiler before committing changes.
  9. // See https://chromium.googlesource.com/chromium/src/+/main/docs/closure_compilation.md
  10. /** @fileoverview Externs generated from namespace: bluetooth */
  11. /** @const */
  12. chrome.bluetooth = {};
  13. /**
  14. * @enum {string}
  15. * @see https://developer.chrome.com/extensions/bluetooth#type-VendorIdSource
  16. */
  17. chrome.bluetooth.VendorIdSource = {
  18. BLUETOOTH: 'bluetooth',
  19. USB: 'usb',
  20. };
  21. /**
  22. * @enum {string}
  23. * @see https://developer.chrome.com/extensions/bluetooth#type-DeviceType
  24. */
  25. chrome.bluetooth.DeviceType = {
  26. COMPUTER: 'computer',
  27. PHONE: 'phone',
  28. MODEM: 'modem',
  29. AUDIO: 'audio',
  30. CAR_AUDIO: 'carAudio',
  31. VIDEO: 'video',
  32. PERIPHERAL: 'peripheral',
  33. JOYSTICK: 'joystick',
  34. GAMEPAD: 'gamepad',
  35. KEYBOARD: 'keyboard',
  36. MOUSE: 'mouse',
  37. TABLET: 'tablet',
  38. KEYBOARD_MOUSE_COMBO: 'keyboardMouseCombo',
  39. };
  40. /**
  41. * @enum {string}
  42. * @see https://developer.chrome.com/extensions/bluetooth#type-FilterType
  43. */
  44. chrome.bluetooth.FilterType = {
  45. ALL: 'all',
  46. KNOWN: 'known',
  47. };
  48. /**
  49. * @enum {string}
  50. * @see https://developer.chrome.com/extensions/bluetooth#type-Transport
  51. */
  52. chrome.bluetooth.Transport = {
  53. INVALID: 'invalid',
  54. CLASSIC: 'classic',
  55. LE: 'le',
  56. DUAL: 'dual',
  57. };
  58. /**
  59. * @typedef {{
  60. * address: string,
  61. * name: string,
  62. * powered: boolean,
  63. * available: boolean,
  64. * discovering: boolean
  65. * }}
  66. * @see https://developer.chrome.com/extensions/bluetooth#type-AdapterState
  67. */
  68. chrome.bluetooth.AdapterState;
  69. /**
  70. * @typedef {{
  71. * address: string,
  72. * name: (string|undefined),
  73. * deviceClass: (number|undefined),
  74. * vendorIdSource: (!chrome.bluetooth.VendorIdSource|undefined),
  75. * vendorId: (number|undefined),
  76. * productId: (number|undefined),
  77. * deviceId: (number|undefined),
  78. * type: (!chrome.bluetooth.DeviceType|undefined),
  79. * paired: (boolean|undefined),
  80. * connected: (boolean|undefined),
  81. * connecting: (boolean|undefined),
  82. * connectable: (boolean|undefined),
  83. * uuids: (!Array<string>|undefined),
  84. * inquiryRssi: (number|undefined),
  85. * inquiryTxPower: (number|undefined),
  86. * transport: (!chrome.bluetooth.Transport|undefined),
  87. * batteryPercentage: (number|undefined)
  88. * }}
  89. * @see https://developer.chrome.com/extensions/bluetooth#type-Device
  90. */
  91. chrome.bluetooth.Device;
  92. /**
  93. * @typedef {{
  94. * filterType: (!chrome.bluetooth.FilterType|undefined),
  95. * limit: (number|undefined)
  96. * }}
  97. * @see https://developer.chrome.com/extensions/bluetooth#type-BluetoothFilter
  98. */
  99. chrome.bluetooth.BluetoothFilter;
  100. /**
  101. * Get information about the Bluetooth adapter.
  102. * @param {function(!chrome.bluetooth.AdapterState): void} callback Called with
  103. * an AdapterState object describing the adapter state.
  104. * @see https://developer.chrome.com/extensions/bluetooth#method-getAdapterState
  105. */
  106. chrome.bluetooth.getAdapterState = function(callback) {};
  107. /**
  108. * Get information about a Bluetooth device known to the system.
  109. * @param {string} deviceAddress Address of device to get.
  110. * @param {function(!chrome.bluetooth.Device): void} callback Called with the
  111. * Device object describing the device.
  112. * @see https://developer.chrome.com/extensions/bluetooth#method-getDevice
  113. */
  114. chrome.bluetooth.getDevice = function(deviceAddress, callback) {};
  115. /**
  116. * Get a list of Bluetooth devices known to the system, including paired and
  117. * recently discovered devices.
  118. * @param {?chrome.bluetooth.BluetoothFilter|undefined} filter Some criteria to
  119. * filter the list of returned bluetooth devices. If the filter is not set
  120. * or set to <code>{}</code>, returned device list will contain all
  121. * bluetooth devices. Right now this is only supported in ChromeOS, for
  122. * other platforms, a full list is returned.
  123. * @param {function(!Array<!chrome.bluetooth.Device>): void} callback Called
  124. * when the search is completed.
  125. * @see https://developer.chrome.com/extensions/bluetooth#method-getDevices
  126. */
  127. chrome.bluetooth.getDevices = function(filter, callback) {};
  128. /**
  129. * <p>Start discovery. Newly discovered devices will be returned via the
  130. * onDeviceAdded event. Previously discovered devices already known to the
  131. * adapter must be obtained using getDevices and will only be updated using the
  132. * |onDeviceChanged| event if information about them changes.</p><p>Discovery
  133. * will fail to start if this application has already called startDiscovery.
  134. * Discovery can be resource intensive: stopDiscovery should be called as soon
  135. * as possible.</p>
  136. * @param {function(): void=} callback Called to indicate success or failure.
  137. * @see https://developer.chrome.com/extensions/bluetooth#method-startDiscovery
  138. */
  139. chrome.bluetooth.startDiscovery = function(callback) {};
  140. /**
  141. * Stop discovery.
  142. * @param {function(): void=} callback Called to indicate success or failure.
  143. * @see https://developer.chrome.com/extensions/bluetooth#method-stopDiscovery
  144. */
  145. chrome.bluetooth.stopDiscovery = function(callback) {};
  146. /**
  147. * Fired when the state of the Bluetooth adapter changes.
  148. * @type {!ChromeEvent}
  149. * @see https://developer.chrome.com/extensions/bluetooth#event-onAdapterStateChanged
  150. */
  151. chrome.bluetooth.onAdapterStateChanged;
  152. /**
  153. * Fired when information about a new Bluetooth device is available.
  154. * @type {!ChromeEvent}
  155. * @see https://developer.chrome.com/extensions/bluetooth#event-onDeviceAdded
  156. */
  157. chrome.bluetooth.onDeviceAdded;
  158. /**
  159. * Fired when information about a known Bluetooth device has changed.
  160. * @type {!ChromeEvent}
  161. * @see https://developer.chrome.com/extensions/bluetooth#event-onDeviceChanged
  162. */
  163. chrome.bluetooth.onDeviceChanged;
  164. /**
  165. * Fired when a Bluetooth device that was previously discovered has been out of
  166. * range for long enough to be considered unavailable again, and when a paired
  167. * device is removed.
  168. * @type {!ChromeEvent}
  169. * @see https://developer.chrome.com/extensions/bluetooth#event-onDeviceRemoved
  170. */
  171. chrome.bluetooth.onDeviceRemoved;