2014-06-27 00:45:26 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_bluetooth_bluedroid_bluetoothinterface_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluedroid_bluetoothinterface_h__
|
|
|
|
|
|
|
|
#include <hardware/bluetooth.h>
|
|
|
|
#include <hardware/bt_sock.h>
|
|
|
|
#include <hardware/bt_hf.h>
|
|
|
|
#include <hardware/bt_av.h>
|
|
|
|
#if ANDROID_VERSION >= 18
|
|
|
|
#include <hardware/bt_rc.h>
|
|
|
|
#endif
|
|
|
|
#include "BluetoothCommon.h"
|
2014-08-06 02:44:47 -07:00
|
|
|
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
class BluetoothInterface;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Socket Interface
|
|
|
|
//
|
|
|
|
|
2014-07-10 06:09:44 -07:00
|
|
|
class BluetoothSocketResultHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothSocketResultHandler)
|
|
|
|
|
|
|
|
virtual ~BluetoothSocketResultHandler() { }
|
|
|
|
|
2014-08-06 02:45:32 -07:00
|
|
|
virtual void OnError(BluetoothStatus aStatus)
|
2014-07-10 06:09:44 -07:00
|
|
|
{
|
2014-08-06 02:45:32 -07:00
|
|
|
BT_WARNING("Received error code %d", (int)aStatus);
|
2014-07-10 06:09:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Listen(int aSockFd) { }
|
2014-07-10 06:10:45 -07:00
|
|
|
virtual void Connect(int aSockFd, const nsAString& aBdAddress,
|
|
|
|
int aConnectionState) { }
|
2014-07-10 06:10:54 -07:00
|
|
|
virtual void Accept(int aSockFd, const nsAString& aBdAddress,
|
|
|
|
int aConnectionState) { }
|
2014-07-10 06:09:44 -07:00
|
|
|
};
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
class BluetoothSocketInterface
|
|
|
|
{
|
|
|
|
public:
|
2014-07-02 19:58:00 -07:00
|
|
|
friend class BluetoothInterface;
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
// Init and Cleanup is handled by BluetoothInterface
|
|
|
|
|
2014-08-06 02:44:56 -07:00
|
|
|
void Listen(BluetoothSocketType aType,
|
|
|
|
const nsAString& aServiceName,
|
|
|
|
const uint8_t aServiceUuid[16],
|
|
|
|
int aChannel, bool aEncrypt, bool aAuth,
|
|
|
|
BluetoothSocketResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-08-06 02:44:56 -07:00
|
|
|
void Connect(const nsAString& aBdAddr,
|
|
|
|
BluetoothSocketType aType,
|
|
|
|
const uint8_t aUuid[16],
|
|
|
|
int aChannel, bool aEncrypt, bool aAuth,
|
2014-07-10 06:10:26 -07:00
|
|
|
BluetoothSocketResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-07-10 06:10:54 -07:00
|
|
|
void Accept(int aFd, BluetoothSocketResultHandler* aRes);
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
protected:
|
|
|
|
BluetoothSocketInterface(const btsock_interface_t* aInterface);
|
|
|
|
~BluetoothSocketInterface();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const btsock_interface_t* mInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Handsfree Interface
|
|
|
|
//
|
|
|
|
|
2014-08-21 01:10:37 -07:00
|
|
|
class BluetoothHandsfreeNotificationHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~BluetoothHandsfreeNotificationHandler();
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ConnectionStateNotification(BluetoothHandsfreeConnectionState aState,
|
|
|
|
const nsAString& aBdAddr)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
AudioStateNotification(BluetoothHandsfreeAudioState aState,
|
|
|
|
const nsAString& aBdAddr)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
AnswerCallNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
HangupCallNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
VolumeNotification(BluetoothHandsfreeVolumeType aType, int aVolume)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
DialCallNotification(const nsAString& aNumber)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
DtmfNotification(char aDtmf)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
NRECNotification(BluetoothHandsfreeNRECState aNrec)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CnumNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CindNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
CopsNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ClccNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
UnknownAtNotification(const nsACString& aAtString)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
KeyPressedNotification()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothHandsfreeNotificationHandler()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2014-07-15 01:56:53 -07:00
|
|
|
class BluetoothHandsfreeResultHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothHandsfreeResultHandler)
|
|
|
|
|
|
|
|
virtual ~BluetoothHandsfreeResultHandler() { }
|
|
|
|
|
2014-08-06 02:45:32 -07:00
|
|
|
virtual void OnError(BluetoothStatus aStatus)
|
2014-07-15 01:56:53 -07:00
|
|
|
{
|
|
|
|
BT_WARNING("Received error code %d", (int)aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Init() { }
|
|
|
|
virtual void Cleanup() { }
|
|
|
|
|
|
|
|
virtual void Connect() { }
|
|
|
|
virtual void Disconnect() { }
|
|
|
|
virtual void ConnectAudio() { }
|
|
|
|
virtual void DisconnectAudio() { }
|
|
|
|
|
|
|
|
virtual void StartVoiceRecognition() { }
|
|
|
|
virtual void StopVoiceRecognition() { }
|
|
|
|
|
|
|
|
virtual void VolumeControl() { }
|
|
|
|
|
|
|
|
virtual void DeviceStatusNotification() { }
|
|
|
|
|
|
|
|
virtual void CopsResponse() { }
|
|
|
|
virtual void CindResponse() { }
|
|
|
|
virtual void FormattedAtResponse() { }
|
|
|
|
virtual void AtResponse() { }
|
|
|
|
virtual void ClccResponse() { }
|
|
|
|
virtual void PhoneStateChange() { }
|
|
|
|
};
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
class BluetoothHandsfreeInterface
|
|
|
|
{
|
|
|
|
public:
|
2014-07-02 19:58:00 -07:00
|
|
|
friend class BluetoothInterface;
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-08-21 01:10:38 -07:00
|
|
|
void Init(BluetoothHandsfreeNotificationHandler* aNotificationHandler,
|
2014-07-15 01:56:53 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
|
|
|
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Connect / Disconnect */
|
|
|
|
|
2014-08-06 02:45:05 -07:00
|
|
|
void Connect(const nsAString& aBdAddr,
|
2014-07-15 01:56:54 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-08-06 02:45:05 -07:00
|
|
|
void Disconnect(const nsAString& aBdAddr,
|
2014-07-15 01:56:54 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-08-06 02:45:05 -07:00
|
|
|
void ConnectAudio(const nsAString& aBdAddr,
|
2014-07-15 01:56:54 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-08-06 02:45:05 -07:00
|
|
|
void DisconnectAudio(const nsAString& aBdAddr,
|
2014-07-15 01:56:54 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Voice Recognition */
|
|
|
|
|
2014-07-15 01:56:54 -07:00
|
|
|
void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
|
|
|
|
void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Volume */
|
|
|
|
|
2014-08-06 02:45:05 -07:00
|
|
|
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
|
2014-07-15 01:56:54 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Device status */
|
|
|
|
|
2014-08-06 02:45:05 -07:00
|
|
|
void DeviceStatusNotification(BluetoothHandsfreeNetworkState aNtkState,
|
|
|
|
BluetoothHandsfreeServiceType aSvcType,
|
2014-07-15 01:56:55 -07:00
|
|
|
int aSignal, int aBattChg,
|
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Responses */
|
|
|
|
|
2014-07-15 01:56:55 -07:00
|
|
|
void CopsResponse(const char* aCops,
|
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
|
|
|
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
|
2014-08-06 02:45:05 -07:00
|
|
|
BluetoothHandsfreeCallState aCallSetupState, int aSignal,
|
2014-07-15 01:56:55 -07:00
|
|
|
int aRoam, int aBattChg,
|
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
|
|
|
void FormattedAtResponse(const char* aRsp,
|
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-08-06 02:45:05 -07:00
|
|
|
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
|
2014-07-15 01:56:55 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-08-06 02:45:05 -07:00
|
|
|
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
|
|
|
|
BluetoothHandsfreeCallState aState,
|
|
|
|
BluetoothHandsfreeCallMode aMode,
|
|
|
|
BluetoothHandsfreeCallMptyType aMpty,
|
|
|
|
const nsAString& aNumber,
|
|
|
|
BluetoothHandsfreeCallAddressType aType,
|
2014-07-15 01:56:55 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Phone State */
|
|
|
|
|
2014-07-15 01:56:55 -07:00
|
|
|
void PhoneStateChange(int aNumActive, int aNumHeld,
|
2014-08-06 02:45:05 -07:00
|
|
|
BluetoothHandsfreeCallState aCallSetupState,
|
|
|
|
const nsAString& aNumber,
|
|
|
|
BluetoothHandsfreeCallAddressType aType,
|
2014-07-15 01:56:55 -07:00
|
|
|
BluetoothHandsfreeResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothHandsfreeInterface(const bthf_interface_t* aInterface);
|
|
|
|
~BluetoothHandsfreeInterface();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const bthf_interface_t* mInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Bluetooth Advanced Audio Interface
|
|
|
|
//
|
|
|
|
|
2014-07-22 22:56:18 -07:00
|
|
|
class BluetoothA2dpResultHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothA2dpResultHandler)
|
|
|
|
|
|
|
|
virtual ~BluetoothA2dpResultHandler() { }
|
|
|
|
|
2014-08-06 02:45:32 -07:00
|
|
|
virtual void OnError(BluetoothStatus aStatus)
|
2014-07-22 22:56:18 -07:00
|
|
|
{
|
2014-08-06 02:45:32 -07:00
|
|
|
BT_WARNING("Received error code %d", (int)aStatus);
|
2014-07-22 22:56:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Init() { }
|
|
|
|
virtual void Cleanup() { }
|
|
|
|
virtual void Connect() { }
|
|
|
|
virtual void Disconnect() { }
|
|
|
|
};
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
class BluetoothA2dpInterface
|
|
|
|
{
|
|
|
|
public:
|
2014-07-02 19:58:00 -07:00
|
|
|
friend class BluetoothInterface;
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-07-22 22:56:22 -07:00
|
|
|
void Init(btav_callbacks_t *aCallbacks,
|
|
|
|
BluetoothA2dpResultHandler* aRes);
|
|
|
|
void Cleanup(BluetoothA2dpResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-08-06 02:45:14 -07:00
|
|
|
void Connect(const nsAString& aBdAddr,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothA2dpResultHandler* aRes);
|
2014-08-06 02:45:14 -07:00
|
|
|
void Disconnect(const nsAString& aBdAddr,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothA2dpResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothA2dpInterface(const btav_interface_t* aInterface);
|
|
|
|
~BluetoothA2dpInterface();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const btav_interface_t* mInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Bluetooth AVRCP Interface
|
|
|
|
//
|
|
|
|
|
2014-07-22 22:56:18 -07:00
|
|
|
class BluetoothAvrcpResultHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothAvrcpResultHandler)
|
|
|
|
|
|
|
|
virtual ~BluetoothAvrcpResultHandler() { }
|
|
|
|
|
2014-08-06 02:45:32 -07:00
|
|
|
virtual void OnError(BluetoothStatus aStatus)
|
2014-07-22 22:56:18 -07:00
|
|
|
{
|
2014-08-06 02:45:32 -07:00
|
|
|
BT_WARNING("Received error code %d", (int)aStatus);
|
2014-07-22 22:56:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Init() { }
|
|
|
|
virtual void Cleanup() { }
|
|
|
|
|
|
|
|
virtual void GetPlayStatusRsp() { }
|
|
|
|
|
|
|
|
virtual void ListPlayerAppAttrRsp() { }
|
|
|
|
virtual void ListPlayerAppValueRsp() { }
|
|
|
|
|
|
|
|
virtual void GetPlayerAppValueRsp() { }
|
|
|
|
virtual void GetPlayerAppAttrTextRsp() { }
|
|
|
|
virtual void GetPlayerAppValueTextRsp() { }
|
|
|
|
|
|
|
|
virtual void GetElementAttrRsp() { }
|
|
|
|
|
|
|
|
virtual void SetPlayerAppValueRsp() { }
|
|
|
|
|
|
|
|
virtual void RegisterNotificationRsp() { }
|
|
|
|
|
|
|
|
virtual void SetVolume() { }
|
|
|
|
};
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
class BluetoothAvrcpInterface
|
|
|
|
{
|
|
|
|
#if ANDROID_VERSION >= 18
|
|
|
|
public:
|
2014-07-02 19:58:00 -07:00
|
|
|
friend class BluetoothInterface;
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-07-22 22:56:22 -07:00
|
|
|
void Init(btrc_callbacks_t* aCallbacks,
|
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
void Cleanup(BluetoothAvrcpResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
void GetPlayStatusRsp(ControlPlayStatus aPlayStatus,
|
2014-07-22 22:56:23 -07:00
|
|
|
uint32_t aSongLen, uint32_t aSongPos,
|
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
void ListPlayerAppAttrRsp(int aNumAttr,
|
|
|
|
const BluetoothAvrcpPlayerAttribute* aPAttrs,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals,
|
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
/* TODO: redesign this interface once we actually use it */
|
|
|
|
void GetPlayerAppValueRsp(uint8_t aNumAttrs,
|
|
|
|
const uint8_t* aIds, const uint8_t* aValues,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
2014-08-06 02:45:22 -07:00
|
|
|
/* TODO: redesign this interface once we actually use it */
|
2014-07-22 22:56:23 -07:00
|
|
|
void GetPlayerAppAttrTextRsp(int aNumAttr,
|
2014-08-06 02:45:22 -07:00
|
|
|
const uint8_t* aIds, const char** aTexts,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
2014-08-06 02:45:22 -07:00
|
|
|
/* TODO: redesign this interface once we actually use it */
|
2014-07-22 22:56:23 -07:00
|
|
|
void GetPlayerAppValueTextRsp(int aNumVal,
|
2014-08-06 02:45:22 -07:00
|
|
|
const uint8_t* aIds, const char** aTexts,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
void GetElementAttrRsp(uint8_t aNumAttr,
|
|
|
|
const BluetoothAvrcpElementAttribute* aAttr,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
void SetPlayerAppValueRsp(BluetoothAvrcpStatus aRspStatus,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
|
|
|
|
2014-08-06 02:45:22 -07:00
|
|
|
void RegisterNotificationRsp(BluetoothAvrcpEvent aEvent,
|
|
|
|
BluetoothAvrcpNotification aType,
|
|
|
|
const BluetoothAvrcpNotificationParam& aParam,
|
2014-07-22 22:56:23 -07:00
|
|
|
BluetoothAvrcpResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-07-22 22:56:23 -07:00
|
|
|
void SetVolume(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothAvrcpInterface(const btrc_interface_t* aInterface);
|
|
|
|
~BluetoothAvrcpInterface();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const btrc_interface_t* mInterface;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Bluetooth Core Interface
|
|
|
|
//
|
|
|
|
|
2014-08-14 09:12:51 -07:00
|
|
|
class BluetoothNotificationHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~BluetoothNotificationHandler();
|
|
|
|
|
|
|
|
virtual void AdapterStateChangedNotification(bool aState) { }
|
|
|
|
virtual void AdapterPropertiesNotification(
|
|
|
|
BluetoothStatus aStatus, int aNumProperties,
|
|
|
|
const BluetoothProperty* aProperties) { }
|
|
|
|
|
|
|
|
virtual void RemoteDevicePropertiesNotification(
|
|
|
|
BluetoothStatus aStatus, const nsAString& aBdAddr,
|
|
|
|
int aNumProperties, const BluetoothProperty* aProperties) { }
|
|
|
|
|
|
|
|
virtual void DeviceFoundNotification(
|
|
|
|
int aNumProperties, const BluetoothProperty* aProperties) { }
|
|
|
|
|
|
|
|
virtual void DiscoveryStateChangedNotification(bool aState) { }
|
|
|
|
|
|
|
|
virtual void PinRequestNotification(const nsAString& aRemoteBdAddr,
|
|
|
|
const nsAString& aBdName, uint32_t aCod) { }
|
|
|
|
virtual void SspRequestNotification(const nsAString& aRemoteBdAddr,
|
|
|
|
const nsAString& aBdName,
|
|
|
|
uint32_t aCod,
|
|
|
|
const nsAString& aPairingVariant,
|
|
|
|
uint32_t aPassKey) { }
|
|
|
|
|
|
|
|
virtual void BondStateChangedNotification(BluetoothStatus aStatus,
|
|
|
|
const nsAString& aRemoteBdAddr,
|
|
|
|
BluetoothBondState aState) { }
|
|
|
|
virtual void AclStateChangedNotification(BluetoothStatus aStatus,
|
|
|
|
const nsAString& aRemoteBdAddr,
|
|
|
|
bool aState) { }
|
|
|
|
|
|
|
|
virtual void DutModeRecvNotification(uint16_t aOpcode,
|
|
|
|
const uint8_t* aBuf, uint8_t aLen) { }
|
|
|
|
virtual void LeTestModeNotification(BluetoothStatus aStatus,
|
|
|
|
uint16_t aNumPackets) { }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothNotificationHandler()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2014-07-03 00:51:27 -07:00
|
|
|
class BluetoothResultHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothResultHandler)
|
|
|
|
|
|
|
|
virtual ~BluetoothResultHandler() { }
|
|
|
|
|
2014-08-06 02:45:32 -07:00
|
|
|
virtual void OnError(BluetoothStatus aStatus)
|
2014-07-03 00:51:27 -07:00
|
|
|
{
|
2014-08-06 02:45:32 -07:00
|
|
|
BT_LOGR("Received error code %d", aStatus);
|
2014-07-03 00:51:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Init() { }
|
|
|
|
virtual void Cleanup() { }
|
|
|
|
virtual void Enable() { }
|
|
|
|
virtual void Disable() { }
|
|
|
|
|
|
|
|
virtual void GetAdapterProperties() { }
|
|
|
|
virtual void GetAdapterProperty() { }
|
|
|
|
virtual void SetAdapterProperty() { }
|
|
|
|
|
|
|
|
virtual void GetRemoteDeviceProperties() { }
|
|
|
|
virtual void GetRemoteDeviceProperty() { }
|
|
|
|
virtual void SetRemoteDeviceProperty() { }
|
|
|
|
|
|
|
|
virtual void GetRemoteServiceRecord() { }
|
|
|
|
virtual void GetRemoteServices() { }
|
|
|
|
|
|
|
|
virtual void StartDiscovery() { }
|
|
|
|
virtual void CancelDiscovery() { }
|
|
|
|
|
|
|
|
virtual void CreateBond() { }
|
|
|
|
virtual void RemoveBond() { }
|
|
|
|
virtual void CancelBond() { }
|
|
|
|
|
|
|
|
virtual void PinReply() { }
|
|
|
|
virtual void SspReply() { }
|
|
|
|
|
|
|
|
virtual void DutModeConfigure() { }
|
|
|
|
virtual void DutModeSend() { }
|
|
|
|
|
|
|
|
virtual void LeTestMode() { }
|
|
|
|
};
|
|
|
|
|
2014-06-27 00:45:26 -07:00
|
|
|
class BluetoothInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BluetoothInterface* GetInstance();
|
|
|
|
|
2014-08-14 09:12:52 -07:00
|
|
|
void Init(BluetoothNotificationHandler* aNotificationHandler,
|
|
|
|
BluetoothResultHandler* aRes);
|
2014-07-03 00:51:57 -07:00
|
|
|
void Cleanup(BluetoothResultHandler* aRes);
|
|
|
|
|
|
|
|
void Enable(BluetoothResultHandler* aRes);
|
|
|
|
void Disable(BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
/* Adapter Properties */
|
|
|
|
|
2014-07-03 00:52:19 -07:00
|
|
|
void GetAdapterProperties(BluetoothResultHandler* aRes);
|
2014-08-06 02:44:47 -07:00
|
|
|
void GetAdapterProperty(const nsAString& aName,
|
2014-07-03 00:52:19 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-08-06 02:44:47 -07:00
|
|
|
void SetAdapterProperty(const BluetoothNamedValue& aProperty,
|
2014-07-03 00:52:19 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Remote Device Properties */
|
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void GetRemoteDeviceProperties(const nsAString& aRemoteAddr,
|
2014-07-03 00:52:35 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-08-06 02:44:47 -07:00
|
|
|
void GetRemoteDeviceProperty(const nsAString& aRemoteAddr,
|
|
|
|
const nsAString& aName,
|
2014-07-03 00:52:35 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-08-06 02:44:47 -07:00
|
|
|
void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
|
|
|
|
const BluetoothNamedValue& aProperty,
|
2014-07-03 00:52:35 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Remote Services */
|
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
|
|
|
|
const uint8_t aUuid[16],
|
2014-07-03 00:52:52 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-08-06 02:44:47 -07:00
|
|
|
void GetRemoteServices(const nsAString& aRemoteAddr,
|
2014-07-03 00:52:52 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Discovery */
|
|
|
|
|
2014-07-03 00:53:06 -07:00
|
|
|
void StartDiscovery(BluetoothResultHandler* aRes);
|
|
|
|
void CancelDiscovery(BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Bonds */
|
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
|
|
|
|
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
|
|
|
|
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Authentication */
|
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void PinReply(const nsAString& aBdAddr, bool aAccept,
|
|
|
|
const nsAString& aPinCode,
|
2014-07-03 00:53:32 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void SspReply(const nsAString& aBdAddr, const nsAString& aVariant,
|
|
|
|
bool aAccept, uint32_t aPasskey,
|
2014-07-03 00:53:32 -07:00
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* DUT Mode */
|
|
|
|
|
2014-08-06 02:44:47 -07:00
|
|
|
void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes);
|
2014-07-03 00:53:39 -07:00
|
|
|
void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
|
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* LE Mode */
|
|
|
|
|
2014-07-03 00:53:39 -07:00
|
|
|
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
|
|
|
|
BluetoothResultHandler* aRes);
|
2014-06-27 00:45:26 -07:00
|
|
|
|
|
|
|
/* Profile Interfaces */
|
|
|
|
|
|
|
|
BluetoothSocketInterface* GetBluetoothSocketInterface();
|
|
|
|
BluetoothHandsfreeInterface* GetBluetoothHandsfreeInterface();
|
|
|
|
BluetoothA2dpInterface* GetBluetoothA2dpInterface();
|
|
|
|
BluetoothAvrcpInterface* GetBluetoothAvrcpInterface();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BluetoothInterface(const bt_interface_t* aInterface);
|
|
|
|
~BluetoothInterface();
|
|
|
|
|
|
|
|
private:
|
|
|
|
template <class T>
|
|
|
|
T* GetProfileInterface();
|
|
|
|
|
|
|
|
const bt_interface_t* mInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|