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
20 class BluetoothSocketResultHandler
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
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;
61 virtual ~BluetoothSocketInterface();
65 // Handsfree Interface
68 class BluetoothHandsfreeNotificationHandler
71 virtual ~BluetoothHandsfreeNotificationHandler();
74 ConnectionStateNotification(BluetoothHandsfreeConnectionState aState
,
75 const nsAString
& aBdAddr
)
79 AudioStateNotification(BluetoothHandsfreeAudioState aState
,
80 const nsAString
& aBdAddr
)
84 VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState
)
88 AnswerCallNotification()
92 HangupCallNotification()
96 VolumeNotification(BluetoothHandsfreeVolumeType aType
, int aVolume
)
100 DialCallNotification(const nsAString
& aNumber
)
104 DtmfNotification(char aDtmf
)
108 NRECNotification(BluetoothHandsfreeNRECState aNrec
)
112 CallHoldNotification(BluetoothHandsfreeCallHoldType aChld
)
132 UnknownAtNotification(const nsACString
& aAtString
)
136 KeyPressedNotification()
140 BluetoothHandsfreeNotificationHandler()
144 class BluetoothHandsfreeResultHandler
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
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;
205 virtual void VolumeControl(BluetoothHandsfreeVolumeType aType
, int aVolume
,
206 BluetoothHandsfreeResultHandler
* aRes
) = 0;
210 virtual void DeviceStatusNotification(
211 BluetoothHandsfreeNetworkState aNtkState
,
212 BluetoothHandsfreeServiceType aSvcType
,
213 int aSignal
, int aBattChg
, BluetoothHandsfreeResultHandler
* aRes
) = 0;
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;
237 virtual void PhoneStateChange(int aNumActive
, int aNumHeld
,
238 BluetoothHandsfreeCallState aCallSetupState
,
239 const nsAString
& aNumber
,
240 BluetoothHandsfreeCallAddressType aType
,
241 BluetoothHandsfreeResultHandler
* aRes
) = 0;
244 BluetoothHandsfreeInterface();
245 virtual ~BluetoothHandsfreeInterface();
249 // Bluetooth Advanced Audio Interface
252 class BluetoothA2dpNotificationHandler
255 virtual ~BluetoothA2dpNotificationHandler();
258 ConnectionStateNotification(BluetoothA2dpConnectionState aState
,
259 const nsAString
& aBdAddr
)
263 AudioStateNotification(BluetoothA2dpAudioState aState
,
264 const nsAString
& aBdAddr
)
268 BluetoothA2dpNotificationHandler()
272 class BluetoothA2dpResultHandler
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
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;
303 BluetoothA2dpInterface();
304 virtual ~BluetoothA2dpInterface();
308 // Bluetooth AVRCP Interface
311 class BluetoothAvrcpNotificationHandler
314 virtual ~BluetoothAvrcpNotificationHandler();
317 GetPlayStatusNotification()
321 ListPlayerAppAttrNotification()
325 ListPlayerAppValuesNotification(BluetoothAvrcpPlayerAttribute aAttrId
)
329 GetPlayerAppValueNotification(uint8_t aNumAttrs
,
330 const BluetoothAvrcpPlayerAttribute
* aAttrs
)
334 GetPlayerAppAttrsTextNotification(uint8_t aNumAttrs
,
335 const BluetoothAvrcpPlayerAttribute
* aAttrs
)
339 GetPlayerAppValuesTextNotification(uint8_t aAttrId
, uint8_t aNumVals
,
340 const uint8_t* aValues
)
344 SetPlayerAppValueNotification(const BluetoothAvrcpPlayerSettings
& aSettings
)
348 GetElementAttrNotification(uint8_t aNumAttrs
,
349 const BluetoothAvrcpMediaAttribute
* aAttrs
)
353 RegisterNotificationNotification(BluetoothAvrcpEvent aEvent
,
358 RemoteFeatureNotification(const nsAString
& aBdAddr
, unsigned long aFeatures
)
362 VolumeChangeNotification(uint8_t aVolume
, uint8_t aCType
)
366 PassthroughCmdNotification(int aId
, int aKeyState
)
370 BluetoothAvrcpNotificationHandler()
374 class BluetoothAvrcpResultHandler
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
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
,
431 BluetoothAvrcpResultHandler
* aRes
) = 0;
432 /* TODO: redesign this interface once we actually use it */
433 virtual void GetPlayerAppValueTextRsp(int aNumVal
, const uint8_t* aIds
,
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;
452 BluetoothAvrcpInterface();
453 virtual ~BluetoothAvrcpInterface();
460 class BluetoothGattClientNotificationHandler
463 virtual ~BluetoothGattClientNotificationHandler();
466 RegisterClientNotification(int aStatus
,
468 const BluetoothUuid
& aAppUuid
)
472 ScanResultNotification(const nsAString
& aBdAddr
,
474 const BluetoothGattAdvData
& aAdvData
)
478 ConnectNotification(int aConnId
,
481 const nsAString
& aBdAddr
)
485 DisconnectNotification(int aConnId
,
488 const nsAString
& aBdAddr
)
492 SearchCompleteNotification(int aConnId
, int aStatus
) { }
494 SearchResultNotification(int aConnId
,
495 const BluetoothGattServiceId
& aServiceId
)
499 GetCharacteristicNotification(int aConnId
,
501 const BluetoothGattServiceId
& aServiceId
,
502 const BluetoothGattId
& aCharId
,
507 GetDescriptorNotification(int aConnId
,
509 const BluetoothGattServiceId
& aServiceId
,
510 const BluetoothGattId
& aCharId
,
511 const BluetoothGattId
& aDescriptorId
)
515 GetIncludedServiceNotification(int aConnId
,
517 const BluetoothGattServiceId
& aServiceId
,
518 const BluetoothGattServiceId
& aIncludedServId
)
522 RegisterNotificationNotification(int aConnId
,
525 const BluetoothGattServiceId
& aServiceId
,
526 const BluetoothGattId
& aCharId
)
530 NotifyNotification(int aConnId
, const BluetoothGattNotifyParam
& aNotifyParam
)
534 ReadCharacteristicNotification(int aConnId
,
536 const BluetoothGattReadParam
& aReadParam
)
540 WriteCharacteristicNotification(int aConnId
,
542 const BluetoothGattWriteParam
& aWriteParam
)
546 ReadDescriptorNotification(int aConnId
,
548 const BluetoothGattReadParam
& aReadParam
)
552 WriteDescriptorNotification(int aConnId
,
554 const BluetoothGattWriteParam
& aWriteParam
)
558 ExecuteWriteNotification(int aConnId
, int aStatus
) { }
561 ReadRemoteRssiNotification(int aClientIf
,
562 const nsAString
& aBdAddr
,
568 ListenNotification(int aStatus
, int aServerIf
) { }
571 BluetoothGattClientNotificationHandler()
575 class BluetoothGattServerNotificationHandler
578 virtual ~BluetoothGattServerNotificationHandler();
579 // TODO: Add server notifications
582 BluetoothGattServerNotificationHandler()
586 class BluetoothGattNotificationHandler
587 : public BluetoothGattClientNotificationHandler
588 , public BluetoothGattServerNotificationHandler
591 virtual ~BluetoothGattNotificationHandler();
594 BluetoothGattNotificationHandler()
598 class BluetoothGattClientResultHandler
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
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
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
,
680 BluetoothGattClientResultHandler
* aRes
) = 0;
682 /* Start / Stop advertisements to listen for incoming connections */
683 virtual void Listen(int aClientIf
,
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(
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
,
716 BluetoothGattClientResultHandler
* aRes
) = 0;
717 virtual void WriteCharacteristic(int aConnId
,
718 const BluetoothGattServiceId
& aServiceId
,
719 const BluetoothGattId
& aCharId
,
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
,
730 BluetoothGattClientResultHandler
* aRes
) = 0;
731 virtual void WriteDescriptor(int aConnId
,
732 const BluetoothGattServiceId
& aServiceId
,
733 const BluetoothGattId
& aCharId
,
734 const BluetoothGattId
& aDescriptorId
,
738 const ArrayBuffer
& aValue
,
739 BluetoothGattClientResultHandler
* aRes
) = 0;
741 /* Execute / Abort Prepared Write*/
742 virtual void ExecuteWrite(int aConnId
,
744 BluetoothGattClientResultHandler
* aRes
) = 0;
747 /* Register / Deregister Characteristic Notifications or Indications */
748 virtual void RegisterNotification(
750 const nsAString
& aBdAddr
,
751 const BluetoothGattServiceId
& aServiceId
,
752 const BluetoothGattId
& aCharId
,
753 BluetoothGattClientResultHandler
* aRes
) = 0;
754 virtual void DeregisterNotification(
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
,
771 bool aIsNameIncluded
,
772 bool aIsTxPowerIncluded
,
776 uint8_t aManufacturerLen
,
777 const ArrayBuffer
& aManufacturerData
,
778 BluetoothGattClientResultHandler
* aRes
) = 0;
781 BluetoothGattClientInterface();
782 virtual ~BluetoothGattClientInterface();
785 // TODO: Add GattServerInterface
787 class BluetoothGattInterface
790 virtual void Init(BluetoothGattNotificationHandler
* aNotificationHandler
,
791 BluetoothGattResultHandler
* aRes
) = 0;
792 virtual void Cleanup(BluetoothGattResultHandler
* aRes
) = 0;
794 virtual BluetoothGattClientInterface
* GetBluetoothGattClientInterface() = 0;
797 BluetoothGattInterface();
798 virtual ~BluetoothGattInterface();
802 // Bluetooth Core Interface
805 class BluetoothNotificationHandler
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
,
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
,
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
) { }
845 BluetoothNotificationHandler()
849 class BluetoothResultHandler
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
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;
934 virtual void StartDiscovery(BluetoothResultHandler
* aRes
) = 0;
935 virtual void CancelDiscovery(BluetoothResultHandler
* aRes
) = 0;
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;
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;
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;
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;
977 BluetoothInterface();
978 virtual ~BluetoothInterface();
981 END_BLUETOOTH_NAMESPACE