bluetoothemulation.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. // Package bluetoothemulation provides the Chrome DevTools Protocol
  2. // commands, types, and events for the BluetoothEmulation domain.
  3. //
  4. // This domain allows configuring virtual Bluetooth devices to test the
  5. // web-bluetooth API.
  6. //
  7. // Generated by the cdproto-gen command.
  8. package bluetoothemulation
  9. // Code generated by cdproto-gen. DO NOT EDIT.
  10. import (
  11. "context"
  12. "github.com/chromedp/cdproto/cdp"
  13. )
  14. // EnableParams enable the BluetoothEmulation domain.
  15. type EnableParams struct {
  16. State CentralState `json:"state"` // State of the simulated central.
  17. LeSupported bool `json:"leSupported"` // If the simulated central supports low-energy.
  18. }
  19. // Enable enable the BluetoothEmulation domain.
  20. //
  21. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-enable
  22. //
  23. // parameters:
  24. //
  25. // state - State of the simulated central.
  26. // leSupported - If the simulated central supports low-energy.
  27. func Enable(state CentralState, leSupported bool) *EnableParams {
  28. return &EnableParams{
  29. State: state,
  30. LeSupported: leSupported,
  31. }
  32. }
  33. // Do executes BluetoothEmulation.enable against the provided context.
  34. func (p *EnableParams) Do(ctx context.Context) (err error) {
  35. return cdp.Execute(ctx, CommandEnable, p, nil)
  36. }
  37. // SetSimulatedCentralStateParams set the state of the simulated central.
  38. type SetSimulatedCentralStateParams struct {
  39. State CentralState `json:"state"` // State of the simulated central.
  40. }
  41. // SetSimulatedCentralState set the state of the simulated central.
  42. //
  43. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-setSimulatedCentralState
  44. //
  45. // parameters:
  46. //
  47. // state - State of the simulated central.
  48. func SetSimulatedCentralState(state CentralState) *SetSimulatedCentralStateParams {
  49. return &SetSimulatedCentralStateParams{
  50. State: state,
  51. }
  52. }
  53. // Do executes BluetoothEmulation.setSimulatedCentralState against the provided context.
  54. func (p *SetSimulatedCentralStateParams) Do(ctx context.Context) (err error) {
  55. return cdp.Execute(ctx, CommandSetSimulatedCentralState, p, nil)
  56. }
  57. // DisableParams disable the BluetoothEmulation domain.
  58. type DisableParams struct{}
  59. // Disable disable the BluetoothEmulation domain.
  60. //
  61. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-disable
  62. func Disable() *DisableParams {
  63. return &DisableParams{}
  64. }
  65. // Do executes BluetoothEmulation.disable against the provided context.
  66. func (p *DisableParams) Do(ctx context.Context) (err error) {
  67. return cdp.Execute(ctx, CommandDisable, nil, nil)
  68. }
  69. // SimulatePreconnectedPeripheralParams simulates a peripheral with
  70. // |address|, |name| and |knownServiceUuids| that has already been connected to
  71. // the system.
  72. type SimulatePreconnectedPeripheralParams struct {
  73. Address string `json:"address"`
  74. Name string `json:"name"`
  75. ManufacturerData []*ManufacturerData `json:"manufacturerData"`
  76. KnownServiceUUIDs []string `json:"knownServiceUuids"`
  77. }
  78. // SimulatePreconnectedPeripheral simulates a peripheral with |address|,
  79. // |name| and |knownServiceUuids| that has already been connected to the system.
  80. //
  81. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulatePreconnectedPeripheral
  82. //
  83. // parameters:
  84. //
  85. // address
  86. // name
  87. // manufacturerData
  88. // knownServiceUUIDs
  89. func SimulatePreconnectedPeripheral(address string, name string, manufacturerData []*ManufacturerData, knownServiceUUIDs []string) *SimulatePreconnectedPeripheralParams {
  90. return &SimulatePreconnectedPeripheralParams{
  91. Address: address,
  92. Name: name,
  93. ManufacturerData: manufacturerData,
  94. KnownServiceUUIDs: knownServiceUUIDs,
  95. }
  96. }
  97. // Do executes BluetoothEmulation.simulatePreconnectedPeripheral against the provided context.
  98. func (p *SimulatePreconnectedPeripheralParams) Do(ctx context.Context) (err error) {
  99. return cdp.Execute(ctx, CommandSimulatePreconnectedPeripheral, p, nil)
  100. }
  101. // SimulateAdvertisementParams simulates an advertisement packet described in
  102. // |entry| being received by the central.
  103. type SimulateAdvertisementParams struct {
  104. Entry *ScanEntry `json:"entry"`
  105. }
  106. // SimulateAdvertisement simulates an advertisement packet described in
  107. // |entry| being received by the central.
  108. //
  109. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateAdvertisement
  110. //
  111. // parameters:
  112. //
  113. // entry
  114. func SimulateAdvertisement(entry *ScanEntry) *SimulateAdvertisementParams {
  115. return &SimulateAdvertisementParams{
  116. Entry: entry,
  117. }
  118. }
  119. // Do executes BluetoothEmulation.simulateAdvertisement against the provided context.
  120. func (p *SimulateAdvertisementParams) Do(ctx context.Context) (err error) {
  121. return cdp.Execute(ctx, CommandSimulateAdvertisement, p, nil)
  122. }
  123. // SimulateGATTOperationResponseParams simulates the response code from the
  124. // peripheral with |address| for a GATT operation of |type|. The |code| value
  125. // follows the HCI Error Codes from Bluetooth Core Specification Vol 2 Part D
  126. // 1.3 List Of Error Codes.
  127. type SimulateGATTOperationResponseParams struct {
  128. Address string `json:"address"`
  129. Type GATTOperationType `json:"type"`
  130. Code int64 `json:"code"`
  131. }
  132. // SimulateGATTOperationResponse simulates the response code from the
  133. // peripheral with |address| for a GATT operation of |type|. The |code| value
  134. // follows the HCI Error Codes from Bluetooth Core Specification Vol 2 Part D
  135. // 1.3 List Of Error Codes.
  136. //
  137. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-simulateGATTOperationResponse
  138. //
  139. // parameters:
  140. //
  141. // address
  142. // type
  143. // code
  144. func SimulateGATTOperationResponse(address string, typeVal GATTOperationType, code int64) *SimulateGATTOperationResponseParams {
  145. return &SimulateGATTOperationResponseParams{
  146. Address: address,
  147. Type: typeVal,
  148. Code: code,
  149. }
  150. }
  151. // Do executes BluetoothEmulation.simulateGATTOperationResponse against the provided context.
  152. func (p *SimulateGATTOperationResponseParams) Do(ctx context.Context) (err error) {
  153. return cdp.Execute(ctx, CommandSimulateGATTOperationResponse, p, nil)
  154. }
  155. // AddServiceParams adds a service with |serviceUuid| to the peripheral with
  156. // |address|.
  157. type AddServiceParams struct {
  158. Address string `json:"address"`
  159. ServiceUUID string `json:"serviceUuid"`
  160. }
  161. // AddService adds a service with |serviceUuid| to the peripheral with
  162. // |address|.
  163. //
  164. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addService
  165. //
  166. // parameters:
  167. //
  168. // address
  169. // serviceUUID
  170. func AddService(address string, serviceUUID string) *AddServiceParams {
  171. return &AddServiceParams{
  172. Address: address,
  173. ServiceUUID: serviceUUID,
  174. }
  175. }
  176. // AddServiceReturns return values.
  177. type AddServiceReturns struct {
  178. ServiceID string `json:"serviceId,omitempty,omitzero"` // An identifier that uniquely represents this service.
  179. }
  180. // Do executes BluetoothEmulation.addService against the provided context.
  181. //
  182. // returns:
  183. //
  184. // serviceID - An identifier that uniquely represents this service.
  185. func (p *AddServiceParams) Do(ctx context.Context) (serviceID string, err error) {
  186. // execute
  187. var res AddServiceReturns
  188. err = cdp.Execute(ctx, CommandAddService, p, &res)
  189. if err != nil {
  190. return "", err
  191. }
  192. return res.ServiceID, nil
  193. }
  194. // RemoveServiceParams removes the service respresented by |serviceId| from
  195. // the peripheral with |address|.
  196. type RemoveServiceParams struct {
  197. Address string `json:"address"`
  198. ServiceID string `json:"serviceId"`
  199. }
  200. // RemoveService removes the service respresented by |serviceId| from the
  201. // peripheral with |address|.
  202. //
  203. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeService
  204. //
  205. // parameters:
  206. //
  207. // address
  208. // serviceID
  209. func RemoveService(address string, serviceID string) *RemoveServiceParams {
  210. return &RemoveServiceParams{
  211. Address: address,
  212. ServiceID: serviceID,
  213. }
  214. }
  215. // Do executes BluetoothEmulation.removeService against the provided context.
  216. func (p *RemoveServiceParams) Do(ctx context.Context) (err error) {
  217. return cdp.Execute(ctx, CommandRemoveService, p, nil)
  218. }
  219. // AddCharacteristicParams adds a characteristic with |characteristicUuid|
  220. // and |properties| to the service represented by |serviceId| in the peripheral
  221. // with |address|.
  222. type AddCharacteristicParams struct {
  223. Address string `json:"address"`
  224. ServiceID string `json:"serviceId"`
  225. CharacteristicUUID string `json:"characteristicUuid"`
  226. Properties *CharacteristicProperties `json:"properties"`
  227. }
  228. // AddCharacteristic adds a characteristic with |characteristicUuid| and
  229. // |properties| to the service represented by |serviceId| in the peripheral with
  230. // |address|.
  231. //
  232. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addCharacteristic
  233. //
  234. // parameters:
  235. //
  236. // address
  237. // serviceID
  238. // characteristicUUID
  239. // properties
  240. func AddCharacteristic(address string, serviceID string, characteristicUUID string, properties *CharacteristicProperties) *AddCharacteristicParams {
  241. return &AddCharacteristicParams{
  242. Address: address,
  243. ServiceID: serviceID,
  244. CharacteristicUUID: characteristicUUID,
  245. Properties: properties,
  246. }
  247. }
  248. // AddCharacteristicReturns return values.
  249. type AddCharacteristicReturns struct {
  250. CharacteristicID string `json:"characteristicId,omitempty,omitzero"` // An identifier that uniquely represents this characteristic.
  251. }
  252. // Do executes BluetoothEmulation.addCharacteristic against the provided context.
  253. //
  254. // returns:
  255. //
  256. // characteristicID - An identifier that uniquely represents this characteristic.
  257. func (p *AddCharacteristicParams) Do(ctx context.Context) (characteristicID string, err error) {
  258. // execute
  259. var res AddCharacteristicReturns
  260. err = cdp.Execute(ctx, CommandAddCharacteristic, p, &res)
  261. if err != nil {
  262. return "", err
  263. }
  264. return res.CharacteristicID, nil
  265. }
  266. // RemoveCharacteristicParams removes the characteristic respresented by
  267. // |characteristicId| from the service respresented by |serviceId| in the
  268. // peripheral with |address|.
  269. type RemoveCharacteristicParams struct {
  270. Address string `json:"address"`
  271. ServiceID string `json:"serviceId"`
  272. CharacteristicID string `json:"characteristicId"`
  273. }
  274. // RemoveCharacteristic removes the characteristic respresented by
  275. // |characteristicId| from the service respresented by |serviceId| in the
  276. // peripheral with |address|.
  277. //
  278. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeCharacteristic
  279. //
  280. // parameters:
  281. //
  282. // address
  283. // serviceID
  284. // characteristicID
  285. func RemoveCharacteristic(address string, serviceID string, characteristicID string) *RemoveCharacteristicParams {
  286. return &RemoveCharacteristicParams{
  287. Address: address,
  288. ServiceID: serviceID,
  289. CharacteristicID: characteristicID,
  290. }
  291. }
  292. // Do executes BluetoothEmulation.removeCharacteristic against the provided context.
  293. func (p *RemoveCharacteristicParams) Do(ctx context.Context) (err error) {
  294. return cdp.Execute(ctx, CommandRemoveCharacteristic, p, nil)
  295. }
  296. // AddDescriptorParams adds a descriptor with |descriptorUuid| to the
  297. // characteristic respresented by |characteristicId| in the service represented
  298. // by |serviceId| of the peripheral with |address|.
  299. type AddDescriptorParams struct {
  300. Address string `json:"address"`
  301. ServiceID string `json:"serviceId"`
  302. CharacteristicID string `json:"characteristicId"`
  303. DescriptorUUID string `json:"descriptorUuid"`
  304. }
  305. // AddDescriptor adds a descriptor with |descriptorUuid| to the
  306. // characteristic respresented by |characteristicId| in the service represented
  307. // by |serviceId| of the peripheral with |address|.
  308. //
  309. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-addDescriptor
  310. //
  311. // parameters:
  312. //
  313. // address
  314. // serviceID
  315. // characteristicID
  316. // descriptorUUID
  317. func AddDescriptor(address string, serviceID string, characteristicID string, descriptorUUID string) *AddDescriptorParams {
  318. return &AddDescriptorParams{
  319. Address: address,
  320. ServiceID: serviceID,
  321. CharacteristicID: characteristicID,
  322. DescriptorUUID: descriptorUUID,
  323. }
  324. }
  325. // AddDescriptorReturns return values.
  326. type AddDescriptorReturns struct {
  327. DescriptorID string `json:"descriptorId,omitempty,omitzero"` // An identifier that uniquely represents this descriptor.
  328. }
  329. // Do executes BluetoothEmulation.addDescriptor against the provided context.
  330. //
  331. // returns:
  332. //
  333. // descriptorID - An identifier that uniquely represents this descriptor.
  334. func (p *AddDescriptorParams) Do(ctx context.Context) (descriptorID string, err error) {
  335. // execute
  336. var res AddDescriptorReturns
  337. err = cdp.Execute(ctx, CommandAddDescriptor, p, &res)
  338. if err != nil {
  339. return "", err
  340. }
  341. return res.DescriptorID, nil
  342. }
  343. // RemoveDescriptorParams removes the descriptor with |descriptorId| from the
  344. // characteristic respresented by |characteristicId| in the service represented
  345. // by |serviceId| of the peripheral with |address|.
  346. type RemoveDescriptorParams struct {
  347. Address string `json:"address"`
  348. ServiceID string `json:"serviceId"`
  349. CharacteristicID string `json:"characteristicId"`
  350. DescriptorID string `json:"descriptorId"`
  351. }
  352. // RemoveDescriptor removes the descriptor with |descriptorId| from the
  353. // characteristic respresented by |characteristicId| in the service represented
  354. // by |serviceId| of the peripheral with |address|.
  355. //
  356. // See: https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation#method-removeDescriptor
  357. //
  358. // parameters:
  359. //
  360. // address
  361. // serviceID
  362. // characteristicID
  363. // descriptorID
  364. func RemoveDescriptor(address string, serviceID string, characteristicID string, descriptorID string) *RemoveDescriptorParams {
  365. return &RemoveDescriptorParams{
  366. Address: address,
  367. ServiceID: serviceID,
  368. CharacteristicID: characteristicID,
  369. DescriptorID: descriptorID,
  370. }
  371. }
  372. // Do executes BluetoothEmulation.removeDescriptor against the provided context.
  373. func (p *RemoveDescriptorParams) Do(ctx context.Context) (err error) {
  374. return cdp.Execute(ctx, CommandRemoveDescriptor, p, nil)
  375. }
  376. // Command names.
  377. const (
  378. CommandEnable = "BluetoothEmulation.enable"
  379. CommandSetSimulatedCentralState = "BluetoothEmulation.setSimulatedCentralState"
  380. CommandDisable = "BluetoothEmulation.disable"
  381. CommandSimulatePreconnectedPeripheral = "BluetoothEmulation.simulatePreconnectedPeripheral"
  382. CommandSimulateAdvertisement = "BluetoothEmulation.simulateAdvertisement"
  383. CommandSimulateGATTOperationResponse = "BluetoothEmulation.simulateGATTOperationResponse"
  384. CommandAddService = "BluetoothEmulation.addService"
  385. CommandRemoveService = "BluetoothEmulation.removeService"
  386. CommandAddCharacteristic = "BluetoothEmulation.addCharacteristic"
  387. CommandRemoveCharacteristic = "BluetoothEmulation.removeCharacteristic"
  388. CommandAddDescriptor = "BluetoothEmulation.addDescriptor"
  389. CommandRemoveDescriptor = "BluetoothEmulation.removeDescriptor"
  390. )