Bumping gaia.json for 1 gaia revision(s) a=gaia-bump
[gecko.git] / dom / bluetooth2 / BluetoothInterface.h
blob88537b14f5b070a9d082596f4fe76b50a64a991d
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_bluetooth_bluetoothinterface_h__
8 #define mozilla_dom_bluetooth_bluetoothinterface_h__
10 #include "BluetoothCommon.h"
11 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
12 #include "mozilla/dom/TypedArray.h"
14 BEGIN_BLUETOOTH_NAMESPACE
17 // Socket Interface
20 class BluetoothSocketResultHandler
22 public:
23 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
25 virtual ~BluetoothSocketResultHandler() { }
27 virtual void OnError(BluetoothStatus aStatus)
29 BT_WARNING("Received error code %d", (int)aStatus);
32 virtual void Listen(int aSockFd) { }
33 virtual void Connect(int aSockFd, const nsAString& aBdAddress,
34 int aConnectionState) { }
35 virtual void Accept(int aSockFd, const nsAString& aBdAddress,
36 int aConnectionState) { }
39 class BluetoothSocketInterface
41 public:
42 // Init and Cleanup is handled by BluetoothInterface
44 virtual void Listen(BluetoothSocketType aType,
45 const nsAString& aServiceName,
46 const uint8_t aServiceUuid[16],
47 int aChannel, bool aEncrypt, bool aAuth,
48 BluetoothSocketResultHandler* aRes) = 0;
50 virtual void Connect(const nsAString& aBdAddr,
51 BluetoothSocketType aType,
52 const uint8_t aUuid[16],
53 int aChannel, bool aEncrypt, bool aAuth,
54 BluetoothSocketResultHandler* aRes) = 0;
56 virtual void Accept(int aFd, BluetoothSocketResultHandler* aRes) = 0;
58 virtual void Close(BluetoothSocketResultHandler* aRes) = 0;
60 protected:
61 virtual ~BluetoothSocketInterface();
65 // Handsfree Interface
68 class BluetoothHandsfreeNotificationHandler
70 public:
71 virtual ~BluetoothHandsfreeNotificationHandler();
73 virtual void
74 ConnectionStateNotification(BluetoothHandsfreeConnectionState aState,
75 const nsAString& aBdAddr)
76 { }
78 virtual void
79 AudioStateNotification(BluetoothHandsfreeAudioState aState,
80 const nsAString& aBdAddr)
81 { }
83 virtual void
84 VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState)
85 { }
87 virtual void
88 AnswerCallNotification()
89 { }
91 virtual void
92 HangupCallNotification()
93 { }
95 virtual void
96 VolumeNotification(BluetoothHandsfreeVolumeType aType, int aVolume)
97 { }
99 virtual void
100 DialCallNotification(const nsAString& aNumber)
103 virtual void
104 DtmfNotification(char aDtmf)
107 virtual void
108 NRECNotification(BluetoothHandsfreeNRECState aNrec)
111 virtual void
112 CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
115 virtual void
116 CnumNotification()
119 virtual void
120 CindNotification()
123 virtual void
124 CopsNotification()
127 virtual void
128 ClccNotification()
131 virtual void
132 UnknownAtNotification(const nsACString& aAtString)
135 virtual void
136 KeyPressedNotification()
139 protected:
140 BluetoothHandsfreeNotificationHandler()
144 class BluetoothHandsfreeResultHandler
146 public:
147 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
149 virtual ~BluetoothHandsfreeResultHandler() { }
151 virtual void OnError(BluetoothStatus aStatus)
153 BT_WARNING("Received error code %d", (int)aStatus);
156 virtual void Init() { }
157 virtual void Cleanup() { }
159 virtual void Connect() { }
160 virtual void Disconnect() { }
161 virtual void ConnectAudio() { }
162 virtual void DisconnectAudio() { }
164 virtual void StartVoiceRecognition() { }
165 virtual void StopVoiceRecognition() { }
167 virtual void VolumeControl() { }
169 virtual void DeviceStatusNotification() { }
171 virtual void CopsResponse() { }
172 virtual void CindResponse() { }
173 virtual void FormattedAtResponse() { }
174 virtual void AtResponse() { }
175 virtual void ClccResponse() { }
176 virtual void PhoneStateChange() { }
179 class BluetoothHandsfreeInterface
181 public:
182 virtual void Init(
183 BluetoothHandsfreeNotificationHandler* aNotificationHandler,
184 BluetoothHandsfreeResultHandler* aRes) = 0;
185 virtual void Cleanup(BluetoothHandsfreeResultHandler* aRes) = 0;
187 /* Connect / Disconnect */
189 virtual void Connect(const nsAString& aBdAddr,
190 BluetoothHandsfreeResultHandler* aRes) = 0;
191 virtual void Disconnect(const nsAString& aBdAddr,
192 BluetoothHandsfreeResultHandler* aRes) = 0;
193 virtual void ConnectAudio(const nsAString& aBdAddr,
194 BluetoothHandsfreeResultHandler* aRes) = 0;
195 virtual void DisconnectAudio(const nsAString& aBdAddr,
196 BluetoothHandsfreeResultHandler* aRes) = 0;
198 /* Voice Recognition */
200 virtual void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
201 virtual void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
203 /* Volume */
205 virtual void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
206 BluetoothHandsfreeResultHandler* aRes) = 0;
208 /* Device status */
210 virtual void DeviceStatusNotification(
211 BluetoothHandsfreeNetworkState aNtkState,
212 BluetoothHandsfreeServiceType aSvcType,
213 int aSignal, int aBattChg, BluetoothHandsfreeResultHandler* aRes) = 0;
215 /* Responses */
217 virtual void CopsResponse(const char* aCops,
218 BluetoothHandsfreeResultHandler* aRes) = 0;
219 virtual void CindResponse(int aSvc, int aNumActive, int aNumHeld,
220 BluetoothHandsfreeCallState aCallSetupState,
221 int aSignal, int aRoam, int aBattChg,
222 BluetoothHandsfreeResultHandler* aRes) = 0;
223 virtual void FormattedAtResponse(const char* aRsp,
224 BluetoothHandsfreeResultHandler* aRes) = 0;
225 virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
226 BluetoothHandsfreeResultHandler* aRes) = 0;
227 virtual void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
228 BluetoothHandsfreeCallState aState,
229 BluetoothHandsfreeCallMode aMode,
230 BluetoothHandsfreeCallMptyType aMpty,
231 const nsAString& aNumber,
232 BluetoothHandsfreeCallAddressType aType,
233 BluetoothHandsfreeResultHandler* aRes) = 0;
235 /* Phone State */
237 virtual void PhoneStateChange(int aNumActive, int aNumHeld,
238 BluetoothHandsfreeCallState aCallSetupState,
239 const nsAString& aNumber,
240 BluetoothHandsfreeCallAddressType aType,
241 BluetoothHandsfreeResultHandler* aRes) = 0;
243 protected:
244 BluetoothHandsfreeInterface();
245 virtual ~BluetoothHandsfreeInterface();
249 // Bluetooth Advanced Audio Interface
252 class BluetoothA2dpNotificationHandler
254 public:
255 virtual ~BluetoothA2dpNotificationHandler();
257 virtual void
258 ConnectionStateNotification(BluetoothA2dpConnectionState aState,
259 const nsAString& aBdAddr)
262 virtual void
263 AudioStateNotification(BluetoothA2dpAudioState aState,
264 const nsAString& aBdAddr)
267 protected:
268 BluetoothA2dpNotificationHandler()
272 class BluetoothA2dpResultHandler
274 public:
275 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler)
277 virtual ~BluetoothA2dpResultHandler() { }
279 virtual void OnError(BluetoothStatus aStatus)
281 BT_WARNING("Received error code %d", (int)aStatus);
284 virtual void Init() { }
285 virtual void Cleanup() { }
286 virtual void Connect() { }
287 virtual void Disconnect() { }
290 class BluetoothA2dpInterface
292 public:
293 virtual void Init(BluetoothA2dpNotificationHandler* aNotificationHandler,
294 BluetoothA2dpResultHandler* aRes) = 0;
295 virtual void Cleanup(BluetoothA2dpResultHandler* aRes) = 0;
297 virtual void Connect(const nsAString& aBdAddr,
298 BluetoothA2dpResultHandler* aRes) = 0;
299 virtual void Disconnect(const nsAString& aBdAddr,
300 BluetoothA2dpResultHandler* aRes) = 0;
302 protected:
303 BluetoothA2dpInterface();
304 virtual ~BluetoothA2dpInterface();
308 // Bluetooth AVRCP Interface
311 class BluetoothAvrcpNotificationHandler
313 public:
314 virtual ~BluetoothAvrcpNotificationHandler();
316 virtual void
317 GetPlayStatusNotification()
320 virtual void
321 ListPlayerAppAttrNotification()
324 virtual void
325 ListPlayerAppValuesNotification(BluetoothAvrcpPlayerAttribute aAttrId)
328 virtual void
329 GetPlayerAppValueNotification(uint8_t aNumAttrs,
330 const BluetoothAvrcpPlayerAttribute* aAttrs)
333 virtual void
334 GetPlayerAppAttrsTextNotification(uint8_t aNumAttrs,
335 const BluetoothAvrcpPlayerAttribute* aAttrs)
338 virtual void
339 GetPlayerAppValuesTextNotification(uint8_t aAttrId, uint8_t aNumVals,
340 const uint8_t* aValues)
343 virtual void
344 SetPlayerAppValueNotification(const BluetoothAvrcpPlayerSettings& aSettings)
347 virtual void
348 GetElementAttrNotification(uint8_t aNumAttrs,
349 const BluetoothAvrcpMediaAttribute* aAttrs)
352 virtual void
353 RegisterNotificationNotification(BluetoothAvrcpEvent aEvent,
354 uint32_t aParam)
357 virtual void
358 RemoteFeatureNotification(const nsAString& aBdAddr, unsigned long aFeatures)
361 virtual void
362 VolumeChangeNotification(uint8_t aVolume, uint8_t aCType)
365 virtual void
366 PassthroughCmdNotification(int aId, int aKeyState)
369 protected:
370 BluetoothAvrcpNotificationHandler()
374 class BluetoothAvrcpResultHandler
376 public:
377 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler)
379 virtual ~BluetoothAvrcpResultHandler() { }
381 virtual void OnError(BluetoothStatus aStatus)
383 BT_WARNING("Received error code %d", (int)aStatus);
386 virtual void Init() { }
387 virtual void Cleanup() { }
389 virtual void GetPlayStatusRsp() { }
391 virtual void ListPlayerAppAttrRsp() { }
392 virtual void ListPlayerAppValueRsp() { }
394 virtual void GetPlayerAppValueRsp() { }
395 virtual void GetPlayerAppAttrTextRsp() { }
396 virtual void GetPlayerAppValueTextRsp() { }
398 virtual void GetElementAttrRsp() { }
400 virtual void SetPlayerAppValueRsp() { }
402 virtual void RegisterNotificationRsp() { }
404 virtual void SetVolume() { }
407 class BluetoothAvrcpInterface
409 public:
410 virtual void Init(BluetoothAvrcpNotificationHandler* aNotificationHandler,
411 BluetoothAvrcpResultHandler* aRes) = 0;
412 virtual void Cleanup(BluetoothAvrcpResultHandler* aRes) = 0;
414 virtual void GetPlayStatusRsp(ControlPlayStatus aPlayStatus,
415 uint32_t aSongLen, uint32_t aSongPos,
416 BluetoothAvrcpResultHandler* aRes) = 0;
418 virtual void ListPlayerAppAttrRsp(
419 int aNumAttr, const BluetoothAvrcpPlayerAttribute* aPAttrs,
420 BluetoothAvrcpResultHandler* aRes) = 0;
421 virtual void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals,
422 BluetoothAvrcpResultHandler* aRes) = 0;
424 /* TODO: redesign this interface once we actually use it */
425 virtual void GetPlayerAppValueRsp(uint8_t aNumAttrs, const uint8_t* aIds,
426 const uint8_t* aValues,
427 BluetoothAvrcpResultHandler* aRes) = 0;
428 /* TODO: redesign this interface once we actually use it */
429 virtual void GetPlayerAppAttrTextRsp(int aNumAttr, const uint8_t* aIds,
430 const char** aTexts,
431 BluetoothAvrcpResultHandler* aRes) = 0;
432 /* TODO: redesign this interface once we actually use it */
433 virtual void GetPlayerAppValueTextRsp(int aNumVal, const uint8_t* aIds,
434 const char** aTexts,
435 BluetoothAvrcpResultHandler* aRes) = 0;
437 virtual void GetElementAttrRsp(uint8_t aNumAttr,
438 const BluetoothAvrcpElementAttribute* aAttr,
439 BluetoothAvrcpResultHandler* aRes) = 0;
441 virtual void SetPlayerAppValueRsp(BluetoothAvrcpStatus aRspStatus,
442 BluetoothAvrcpResultHandler* aRes) = 0;
444 virtual void RegisterNotificationRsp(
445 BluetoothAvrcpEvent aEvent, BluetoothAvrcpNotification aType,
446 const BluetoothAvrcpNotificationParam& aParam,
447 BluetoothAvrcpResultHandler* aRes) = 0;
449 virtual void SetVolume(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes) = 0;
451 protected:
452 BluetoothAvrcpInterface();
453 virtual ~BluetoothAvrcpInterface();
457 // GATT Interface
460 class BluetoothGattClientNotificationHandler
462 public:
463 virtual ~BluetoothGattClientNotificationHandler();
465 virtual void
466 RegisterClientNotification(int aStatus,
467 int aClientIf,
468 const BluetoothUuid& aAppUuid)
471 virtual void
472 ScanResultNotification(const nsAString& aBdAddr,
473 int aRssi,
474 const BluetoothGattAdvData& aAdvData)
477 virtual void
478 ConnectNotification(int aConnId,
479 int aStatus,
480 int aClientIf,
481 const nsAString& aBdAddr)
484 virtual void
485 DisconnectNotification(int aConnId,
486 int aStatus,
487 int aClientIf,
488 const nsAString& aBdAddr)
491 virtual void
492 SearchCompleteNotification(int aConnId, int aStatus) { }
493 virtual void
494 SearchResultNotification(int aConnId,
495 const BluetoothGattServiceId& aServiceId)
498 virtual void
499 GetCharacteristicNotification(int aConnId,
500 int aStatus,
501 const BluetoothGattServiceId& aServiceId,
502 const BluetoothGattId& aCharId,
503 int aCharProperty)
506 virtual void
507 GetDescriptorNotification(int aConnId,
508 int aStatus,
509 const BluetoothGattServiceId& aServiceId,
510 const BluetoothGattId& aCharId,
511 const BluetoothGattId& aDescriptorId)
514 virtual void
515 GetIncludedServiceNotification(int aConnId,
516 int aStatus,
517 const BluetoothGattServiceId& aServiceId,
518 const BluetoothGattServiceId& aIncludedServId)
521 virtual void
522 RegisterNotificationNotification(int aConnId,
523 int aIsRegister,
524 int aStatus,
525 const BluetoothGattServiceId& aServiceId,
526 const BluetoothGattId& aCharId)
529 virtual void
530 NotifyNotification(int aConnId, const BluetoothGattNotifyParam& aNotifyParam)
533 virtual void
534 ReadCharacteristicNotification(int aConnId,
535 int aStatus,
536 const BluetoothGattReadParam& aReadParam)
539 virtual void
540 WriteCharacteristicNotification(int aConnId,
541 int aStatus,
542 const BluetoothGattWriteParam& aWriteParam)
545 virtual void
546 ReadDescriptorNotification(int aConnId,
547 int aStatus,
548 const BluetoothGattReadParam& aReadParam)
551 virtual void
552 WriteDescriptorNotification(int aConnId,
553 int aStatus,
554 const BluetoothGattWriteParam& aWriteParam)
557 virtual void
558 ExecuteWriteNotification(int aConnId, int aStatus) { }
560 virtual void
561 ReadRemoteRssiNotification(int aClientIf,
562 const nsAString& aBdAddr,
563 int aRssi,
564 int aStatus)
567 virtual void
568 ListenNotification(int aStatus, int aServerIf) { }
570 protected:
571 BluetoothGattClientNotificationHandler()
575 class BluetoothGattServerNotificationHandler
577 public:
578 virtual ~BluetoothGattServerNotificationHandler();
579 // TODO: Add server notifications
581 protected:
582 BluetoothGattServerNotificationHandler()
586 class BluetoothGattNotificationHandler
587 : public BluetoothGattClientNotificationHandler
588 , public BluetoothGattServerNotificationHandler
590 public:
591 virtual ~BluetoothGattNotificationHandler();
593 protected:
594 BluetoothGattNotificationHandler()
598 class BluetoothGattClientResultHandler
600 public:
601 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothGattClientResultHandler)
603 virtual ~BluetoothGattClientResultHandler() { }
605 virtual void OnError(BluetoothStatus aStatus)
607 BT_WARNING("Received error code %d", (int)aStatus);
610 virtual void RegisterClient() { }
611 virtual void UnregisterClient() { }
613 virtual void Scan() { }
615 virtual void Connect() { }
616 virtual void Disconnect() { }
618 virtual void Listen() { }
619 virtual void Refresh() { }
621 virtual void SearchService() { }
622 virtual void GetIncludedService() { }
623 virtual void GetCharacteristic() { }
624 virtual void GetDescriptor() { }
626 virtual void ReadCharacteristic() { }
627 virtual void WriteCharacteristic() { }
628 virtual void ReadDescriptor() { }
629 virtual void WriteDescriptor() { }
631 virtual void ExecuteWrite() { }
633 virtual void RegisterNotification() { }
634 virtual void DeregisterNotification() { }
636 virtual void ReadRemoteRssi() { }
637 virtual void GetDeviceType() { }
638 virtual void SetAdvData() { }
641 // TODO: Add GattServerResultHandler
643 class BluetoothGattResultHandler
645 public:
646 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothGattResultHandler)
648 virtual ~BluetoothGattResultHandler() { }
650 virtual void OnError(BluetoothStatus aStatus)
652 BT_WARNING("Received error code %d", (int)aStatus);
655 virtual void Init() { }
656 virtual void Cleanup() { }
659 class BluetoothGattClientInterface
661 public:
662 /* Register / Unregister */
663 virtual void RegisterClient(const BluetoothUuid& aUuid,
664 BluetoothGattClientResultHandler* aRes) = 0;
665 virtual void UnregisterClient(int aClientIf,
666 BluetoothGattClientResultHandler* aRes) = 0;
668 /* Start / Stop LE Scan */
669 virtual void Scan(int aClientIf, bool aStart,
670 BluetoothGattClientResultHandler* aRes) = 0;
672 /* Connect / Disconnect */
673 virtual void Connect(int aClientIf,
674 const nsAString& aBdAddr,
675 bool aIsDirect, /* auto connect */
676 BluetoothGattClientResultHandler* aRes) = 0;
677 virtual void Disconnect(int aClientIf,
678 const nsAString& aBdAddr,
679 int aConnId,
680 BluetoothGattClientResultHandler* aRes) = 0;
682 /* Start / Stop advertisements to listen for incoming connections */
683 virtual void Listen(int aClientIf,
684 bool aIsStart,
685 BluetoothGattClientResultHandler* aRes) = 0;
687 /* Clear the attribute cache for a given device*/
688 virtual void Refresh(int aClientIf,
689 const nsAString& aBdAddr,
690 BluetoothGattClientResultHandler* aRes) = 0;
692 /* Enumerate Attributes */
693 virtual void SearchService(int aConnId,
694 const BluetoothUuid& aUuid,
695 BluetoothGattClientResultHandler* aRes) = 0;
696 virtual void GetIncludedService(
697 int aConnId,
698 const BluetoothGattServiceId& aServiceId,
699 const BluetoothGattServiceId& aStartServiceId,
700 BluetoothGattClientResultHandler* aRes) = 0;
701 virtual void GetCharacteristic(int aConnId,
702 const BluetoothGattServiceId& aServiceId,
703 const BluetoothGattId& aStartCharId,
704 BluetoothGattClientResultHandler* aRes) = 0;
705 virtual void GetDescriptor(int aConnId,
706 const BluetoothGattServiceId& aServiceId,
707 const BluetoothGattId& aCharId,
708 const BluetoothGattId& aDescriptorId,
709 BluetoothGattClientResultHandler* aRes) = 0;
711 /* Read / Write An Attribute */
712 virtual void ReadCharacteristic(int aConnId,
713 const BluetoothGattServiceId& aServiceId,
714 const BluetoothGattId& aCharId,
715 int aAuthReq,
716 BluetoothGattClientResultHandler* aRes) = 0;
717 virtual void WriteCharacteristic(int aConnId,
718 const BluetoothGattServiceId& aServiceId,
719 const BluetoothGattId& aCharId,
720 int aWriteType,
721 int aLen,
722 int aAuthReq,
723 const ArrayBuffer& aValue,
724 BluetoothGattClientResultHandler* aRes) = 0;
725 virtual void ReadDescriptor(int aConnId,
726 const BluetoothGattServiceId& aServiceId,
727 const BluetoothGattId& aCharId,
728 const BluetoothGattId& aDescriptorId,
729 int aAuthReq,
730 BluetoothGattClientResultHandler* aRes) = 0;
731 virtual void WriteDescriptor(int aConnId,
732 const BluetoothGattServiceId& aServiceId,
733 const BluetoothGattId& aCharId,
734 const BluetoothGattId& aDescriptorId,
735 int aWriteType,
736 int aLen,
737 int aAuthReq,
738 const ArrayBuffer& aValue,
739 BluetoothGattClientResultHandler* aRes) = 0;
741 /* Execute / Abort Prepared Write*/
742 virtual void ExecuteWrite(int aConnId,
743 int aIsExecute,
744 BluetoothGattClientResultHandler* aRes) = 0;
747 /* Register / Deregister Characteristic Notifications or Indications */
748 virtual void RegisterNotification(
749 int aClientIf,
750 const nsAString& aBdAddr,
751 const BluetoothGattServiceId& aServiceId,
752 const BluetoothGattId& aCharId,
753 BluetoothGattClientResultHandler* aRes) = 0;
754 virtual void DeregisterNotification(
755 int aClientIf,
756 const nsAString& aBdAddr,
757 const BluetoothGattServiceId& aServiceId,
758 const BluetoothGattId& aCharId,
759 BluetoothGattClientResultHandler* aRes) = 0;
761 virtual void ReadRemoteRssi(int aClientIf,
762 const nsAString& aBdAddr,
763 BluetoothGattClientResultHandler* aRes) = 0;
765 virtual void GetDeviceType(const nsAString& aBdAddr,
766 BluetoothGattClientResultHandler* aRes) = 0;
768 /* Set advertising data or scan response data */
769 virtual void SetAdvData(int aServerIf,
770 bool aIsScanRsp,
771 bool aIsNameIncluded,
772 bool aIsTxPowerIncluded,
773 int aMinInterval,
774 int aMaxInterval,
775 int aApperance,
776 uint8_t aManufacturerLen,
777 const ArrayBuffer& aManufacturerData,
778 BluetoothGattClientResultHandler* aRes) = 0;
780 protected:
781 BluetoothGattClientInterface();
782 virtual ~BluetoothGattClientInterface();
785 // TODO: Add GattServerInterface
787 class BluetoothGattInterface
789 public:
790 virtual void Init(BluetoothGattNotificationHandler* aNotificationHandler,
791 BluetoothGattResultHandler* aRes) = 0;
792 virtual void Cleanup(BluetoothGattResultHandler* aRes) = 0;
794 virtual BluetoothGattClientInterface* GetBluetoothGattClientInterface() = 0;
796 protected:
797 BluetoothGattInterface();
798 virtual ~BluetoothGattInterface();
802 // Bluetooth Core Interface
805 class BluetoothNotificationHandler
807 public:
808 virtual ~BluetoothNotificationHandler();
810 virtual void AdapterStateChangedNotification(bool aState) { }
811 virtual void AdapterPropertiesNotification(
812 BluetoothStatus aStatus, int aNumProperties,
813 const BluetoothProperty* aProperties) { }
815 virtual void RemoteDevicePropertiesNotification(
816 BluetoothStatus aStatus, const nsAString& aBdAddr,
817 int aNumProperties, const BluetoothProperty* aProperties) { }
819 virtual void DeviceFoundNotification(
820 int aNumProperties, const BluetoothProperty* aProperties) { }
822 virtual void DiscoveryStateChangedNotification(bool aState) { }
824 virtual void PinRequestNotification(const nsAString& aRemoteBdAddr,
825 const nsAString& aBdName, uint32_t aCod) { }
826 virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
827 const nsAString& aBdName,
828 uint32_t aCod,
829 BluetoothSspVariant aPairingVariant,
830 uint32_t aPassKey) { }
832 virtual void BondStateChangedNotification(BluetoothStatus aStatus,
833 const nsAString& aRemoteBdAddr,
834 BluetoothBondState aState) { }
835 virtual void AclStateChangedNotification(BluetoothStatus aStatus,
836 const nsAString& aRemoteBdAddr,
837 bool aState) { }
839 virtual void DutModeRecvNotification(uint16_t aOpcode,
840 const uint8_t* aBuf, uint8_t aLen) { }
841 virtual void LeTestModeNotification(BluetoothStatus aStatus,
842 uint16_t aNumPackets) { }
844 protected:
845 BluetoothNotificationHandler()
849 class BluetoothResultHandler
851 public:
852 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler)
854 virtual ~BluetoothResultHandler() { }
856 virtual void OnError(BluetoothStatus aStatus)
858 BT_LOGR("Received error code %d", aStatus);
861 virtual void Init() { }
862 virtual void Cleanup() { }
863 virtual void Enable() { }
864 virtual void Disable() { }
866 virtual void GetAdapterProperties() { }
867 virtual void GetAdapterProperty() { }
868 virtual void SetAdapterProperty() { }
870 virtual void GetRemoteDeviceProperties() { }
871 virtual void GetRemoteDeviceProperty() { }
872 virtual void SetRemoteDeviceProperty() { }
874 virtual void GetRemoteServiceRecord() { }
875 virtual void GetRemoteServices() { }
877 virtual void StartDiscovery() { }
878 virtual void CancelDiscovery() { }
880 virtual void CreateBond() { }
881 virtual void RemoveBond() { }
882 virtual void CancelBond() { }
884 virtual void PinReply() { }
885 virtual void SspReply() { }
887 virtual void DutModeConfigure() { }
888 virtual void DutModeSend() { }
890 virtual void LeTestMode() { }
893 class BluetoothInterface
895 public:
896 static BluetoothInterface* GetInstance();
898 virtual void Init(BluetoothNotificationHandler* aNotificationHandler,
899 BluetoothResultHandler* aRes) = 0;
900 virtual void Cleanup(BluetoothResultHandler* aRes) = 0;
902 virtual void Enable(BluetoothResultHandler* aRes) = 0;
903 virtual void Disable(BluetoothResultHandler* aRes) = 0;
905 /* Adapter Properties */
907 virtual void GetAdapterProperties(BluetoothResultHandler* aRes) = 0;
908 virtual void GetAdapterProperty(const nsAString& aName,
909 BluetoothResultHandler* aRes) = 0;
910 virtual void SetAdapterProperty(const BluetoothNamedValue& aProperty,
911 BluetoothResultHandler* aRes) = 0;
913 /* Remote Device Properties */
915 virtual void GetRemoteDeviceProperties(const nsAString& aRemoteAddr,
916 BluetoothResultHandler* aRes) = 0;
917 virtual void GetRemoteDeviceProperty(const nsAString& aRemoteAddr,
918 const nsAString& aName,
919 BluetoothResultHandler* aRes) = 0;
920 virtual void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
921 const BluetoothNamedValue& aProperty,
922 BluetoothResultHandler* aRes) = 0;
924 /* Remote Services */
926 virtual void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
927 const uint8_t aUuid[16],
928 BluetoothResultHandler* aRes) = 0;
929 virtual void GetRemoteServices(const nsAString& aRemoteAddr,
930 BluetoothResultHandler* aRes) = 0;
932 /* Discovery */
934 virtual void StartDiscovery(BluetoothResultHandler* aRes) = 0;
935 virtual void CancelDiscovery(BluetoothResultHandler* aRes) = 0;
937 /* Bonds */
939 virtual void CreateBond(const nsAString& aBdAddr,
940 BluetoothResultHandler* aRes) = 0;
941 virtual void RemoveBond(const nsAString& aBdAddr,
942 BluetoothResultHandler* aRes) = 0;
943 virtual void CancelBond(const nsAString& aBdAddr,
944 BluetoothResultHandler* aRes) = 0;
946 /* Authentication */
948 virtual void PinReply(const nsAString& aBdAddr, bool aAccept,
949 const nsAString& aPinCode,
950 BluetoothResultHandler* aRes) = 0;
952 virtual void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
953 bool aAccept, uint32_t aPasskey,
954 BluetoothResultHandler* aRes) = 0;
956 /* DUT Mode */
958 virtual void DutModeConfigure(bool aEnable,
959 BluetoothResultHandler* aRes) = 0;
960 virtual void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
961 BluetoothResultHandler* aRes) = 0;
963 /* LE Mode */
965 virtual void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
966 BluetoothResultHandler* aRes) = 0;
968 /* Profile Interfaces */
970 virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;
971 virtual BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface() = 0;
972 virtual BluetoothA2dpInterface* GetBluetoothA2dpInterface() = 0;
973 virtual BluetoothAvrcpInterface* GetBluetoothAvrcpInterface() = 0;
974 virtual BluetoothGattInterface* GetBluetoothGattInterface() = 0;
976 protected:
977 BluetoothInterface();
978 virtual ~BluetoothInterface();
981 END_BLUETOOTH_NAMESPACE
983 #endif