mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1220121: Convert IPDL of Bluetooth GATT API to |BluetoothAddress|, r=joliu
This commit is contained in:
parent
9ec12aea49
commit
10e5c8cb29
@ -363,7 +363,7 @@ BluetoothServiceBluedroid::StopLeScanInternal(
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -376,18 +376,12 @@ BluetoothServiceBluedroid::ConnectGattClientInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->Connect(appUuid, deviceAddress, aRunnable);
|
||||
gatt->Connect(appUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -400,13 +394,7 @@ BluetoothServiceBluedroid::DisconnectGattClientInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->Disconnect(appUuid, deviceAddress, aRunnable);
|
||||
gatt->Disconnect(appUuid, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
@ -478,7 +466,7 @@ BluetoothServiceBluedroid::UnregisterGattClientInternal(
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -488,13 +476,7 @@ BluetoothServiceBluedroid::GattClientReadRemoteRssiInternal(
|
||||
BluetoothGattManager* gatt = BluetoothGattManager::Get();
|
||||
ENSURE_GATT_MGR_IS_READY_VOID(gatt, aRunnable);
|
||||
|
||||
BluetoothAddress deviceAddress;
|
||||
if (NS_FAILED(StringToAddress(aDeviceAddress, deviceAddress))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ReadRemoteRssi(aClientIf, deviceAddress, aRunnable);
|
||||
gatt->ReadRemoteRssi(aClientIf, aDeviceAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
@ -589,7 +571,7 @@ BluetoothServiceBluedroid::GattClientWriteDescriptorValueInternal(
|
||||
// GATT Server
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -602,18 +584,12 @@ BluetoothServiceBluedroid::GattServerConnectPeripheralInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ConnectPeripheral(appUuid, address, aRunnable);
|
||||
gatt->ConnectPeripheral(appUuid, aAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -626,13 +602,7 @@ BluetoothServiceBluedroid::GattServerDisconnectPeripheralInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->DisconnectPeripheral(appUuid, address, aRunnable);
|
||||
gatt->DisconnectPeripheral(appUuid, aAddress, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
@ -806,7 +776,7 @@ BluetoothServiceBluedroid::GattServerStopServiceInternal(
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -822,20 +792,14 @@ BluetoothServiceBluedroid::GattServerSendResponseInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ServerSendResponse(
|
||||
appUuid, address, aStatus, aRequestId, aRsp, aRunnable);
|
||||
appUuid, aAddress, aStatus, aRequestId, aRsp, aRunnable);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
@ -851,14 +815,8 @@ BluetoothServiceBluedroid::GattServerSendIndicationInternal(
|
||||
BluetoothUuid appUuid;
|
||||
StringToUuid(aAppUuid, appUuid);
|
||||
|
||||
BluetoothAddress address;
|
||||
if (NS_FAILED(StringToAddress(aAddress, address))) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt->ServerSendIndication(appUuid,
|
||||
address,
|
||||
aAddress,
|
||||
aCharacteristicHandle,
|
||||
aConfirm,
|
||||
aValue,
|
||||
|
@ -283,12 +283,12 @@ public:
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -315,7 +315,7 @@ public:
|
||||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -354,13 +354,13 @@ public:
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -420,7 +420,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -429,7 +429,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -4309,14 +4309,14 @@ BluetoothDBusService::StopLeScanInternal(
|
||||
|
||||
void
|
||||
BluetoothDBusService::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
@ -4349,7 +4349,7 @@ BluetoothDBusService::UnregisterGattClientInternal(
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
@ -4521,14 +4521,14 @@ BluetoothDBusService::ReplyToMapMessageUpdate(long aMasId, bool aStatus,
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
}
|
||||
@ -4606,7 +4606,7 @@ BluetoothDBusService::GattServerStopServiceInternal(
|
||||
void
|
||||
BluetoothDBusService::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
@ -4617,7 +4617,7 @@ BluetoothDBusService::GattServerSendIndicationInternal(
|
||||
void
|
||||
BluetoothDBusService::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
|
@ -294,12 +294,12 @@ public:
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -326,7 +326,7 @@ public:
|
||||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -365,13 +365,13 @@ public:
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -431,7 +431,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -440,7 +440,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -442,7 +442,7 @@ public:
|
||||
*/
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -451,7 +451,7 @@ public:
|
||||
*/
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -494,7 +494,7 @@ public:
|
||||
*/
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(int aClientIf,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -549,13 +549,13 @@ public:
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
@ -618,7 +618,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -627,7 +627,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -112,6 +112,12 @@ BluetoothGatt::Connect(ErrorResult& aRv)
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
if (mAppUuid.IsEmpty()) {
|
||||
nsresult rv = GenerateUuid(mAppUuid);
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv) && !mAppUuid.IsEmpty(),
|
||||
@ -122,7 +128,7 @@ BluetoothGatt::Connect(ErrorResult& aRv)
|
||||
|
||||
UpdateConnectionState(BluetoothConnectionState::Connecting);
|
||||
bs->ConnectGattClientInternal(
|
||||
mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
mAppUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
@ -147,9 +153,15 @@ BluetoothGatt::Disconnect(ErrorResult& aRv)
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
UpdateConnectionState(BluetoothConnectionState::Disconnecting);
|
||||
bs->DisconnectGattClientInternal(
|
||||
mAppUuid, mDeviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
mAppUuid, deviceAddr, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
@ -196,8 +208,14 @@ BluetoothGatt::ReadRemoteRssi(ErrorResult& aRv)
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress deviceAddr;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(mDeviceAddr, deviceAddr)),
|
||||
promise,
|
||||
NS_ERROR_DOM_OPERATION_ERR);
|
||||
|
||||
bs->GattClientReadRemoteRssiInternal(
|
||||
mClientIf, mDeviceAddr, new ReadRemoteRssiTask(promise));
|
||||
mClientIf, deviceAddr, new ReadRemoteRssiTask(promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
@ -319,12 +319,18 @@ BluetoothGattServer::Connect(const nsAString& aAddress, ErrorResult& aRv)
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerConnectPeripheralInternal(
|
||||
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
mAppUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
@ -341,12 +347,18 @@ BluetoothGattServer::Disconnect(const nsAString& aAddress, ErrorResult& aRv)
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerDisconnectPeripheralInternal(
|
||||
mAppUuid, aAddress, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
mAppUuid, address, new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
@ -798,6 +810,12 @@ BluetoothGattServer::NotifyCharacteristicChanged(
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
@ -808,7 +826,7 @@ BluetoothGattServer::NotifyCharacteristicChanged(
|
||||
NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->GattServerSendIndicationInternal(
|
||||
mAppUuid, aAddress, aCharacteristic.GetCharacteristicHandle(), aConfirm,
|
||||
mAppUuid, address, aCharacteristic.GetCharacteristicHandle(), aConfirm,
|
||||
aCharacteristic.GetValue(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
@ -830,6 +848,12 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
|
||||
RefPtr<Promise> promise = Promise::Create(global, aRv);
|
||||
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
|
||||
|
||||
BluetoothAddress address;
|
||||
BT_ENSURE_TRUE_REJECT(
|
||||
NS_SUCCEEDED(StringToAddress(aAddress, address)),
|
||||
promise,
|
||||
NS_ERROR_INVALID_ARG);
|
||||
|
||||
BT_ENSURE_TRUE_REJECT(mValid, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
RequestData* requestData;
|
||||
@ -862,7 +886,7 @@ BluetoothGattServer::SendResponse(const nsAString& aAddress,
|
||||
|
||||
bs->GattServerSendResponseInternal(
|
||||
mAppUuid,
|
||||
aAddress,
|
||||
address,
|
||||
aStatus,
|
||||
aRequestId,
|
||||
response,
|
||||
|
@ -550,20 +550,20 @@ BluetoothServiceChildProcess::SendPlayStatus(int64_t aDuration,
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::ConnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, ConnectGattClientRequest(nsString(aAppUuid),
|
||||
nsString(aDeviceAddress)));
|
||||
aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::DisconnectGattClientInternal(
|
||||
const nsAString& aAppUuid, const nsAString& aDeviceAddress,
|
||||
const nsAString& aAppUuid, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
DisconnectGattClientRequest(nsString(aAppUuid), nsString(aDeviceAddress)));
|
||||
DisconnectGattClientRequest(nsString(aAppUuid), aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
@ -601,12 +601,11 @@ BluetoothServiceChildProcess::UnregisterGattClientInternal(
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattClientReadRemoteRssiInternal(
|
||||
int aClientIf, const nsAString& aDeviceAddress,
|
||||
int aClientIf, const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattClientReadRemoteRssiRequest(aClientIf,
|
||||
nsString(aDeviceAddress)));
|
||||
GattClientReadRemoteRssiRequest(aClientIf, aDeviceAddress));
|
||||
}
|
||||
|
||||
void
|
||||
@ -674,23 +673,21 @@ BluetoothServiceChildProcess::GattClientWriteDescriptorValueInternal(
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerConnectPeripheralRequest(nsString(aAppUuid),
|
||||
nsString(aAddress)));
|
||||
GattServerConnectPeripheralRequest(nsString(aAppUuid), aAddress));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerDisconnectPeripheralRequest(nsString(aAppUuid),
|
||||
nsString(aAddress)));
|
||||
GattServerDisconnectPeripheralRequest(nsString(aAppUuid), aAddress));
|
||||
}
|
||||
|
||||
void
|
||||
@ -791,7 +788,7 @@ BluetoothServiceChildProcess::GattServerStopServiceInternal(
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -799,13 +796,13 @@ BluetoothServiceChildProcess::GattServerSendResponseInternal(
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerSendResponseRequest(
|
||||
nsString(aAppUuid), nsString(aAddress), aStatus, aRequestId, aRsp));
|
||||
nsString(aAppUuid), aAddress, aStatus, aRequestId, aRsp));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceChildProcess::GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
@ -813,7 +810,7 @@ BluetoothServiceChildProcess::GattServerSendIndicationInternal(
|
||||
{
|
||||
SendRequest(aRunnable,
|
||||
GattServerSendIndicationRequest(nsString(aAppUuid),
|
||||
nsString(aAddress),
|
||||
aAddress,
|
||||
aCharacteristicHandle,
|
||||
aConfirm,
|
||||
aValue));
|
||||
|
@ -285,12 +285,12 @@ public:
|
||||
|
||||
virtual void
|
||||
ConnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
DisconnectGattClientInternal(const nsAString& aAppUuid,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -317,7 +317,7 @@ public:
|
||||
|
||||
virtual void
|
||||
GattClientReadRemoteRssiInternal(int aClientIf,
|
||||
const nsAString& aDeviceAddress,
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -356,13 +356,13 @@ public:
|
||||
virtual void
|
||||
GattServerConnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
GattServerDisconnectPeripheralInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
@ -422,7 +422,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendResponseInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
uint16_t aStatus,
|
||||
int32_t aRequestId,
|
||||
const BluetoothGattResponse& aRsp,
|
||||
@ -431,7 +431,7 @@ public:
|
||||
virtual void
|
||||
GattServerSendIndicationInternal(
|
||||
const nsAString& aAppUuid,
|
||||
const nsAString& aAddress,
|
||||
const BluetoothAddress& aAddress,
|
||||
const BluetoothAttributeHandle& aCharacteristicHandle,
|
||||
bool aConfirm,
|
||||
const nsTArray<uint8_t>& aValue,
|
||||
|
@ -276,13 +276,13 @@ struct SendPlayStatusRequest
|
||||
struct ConnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct DisconnectGattClientRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct DiscoverGattServicesRequest
|
||||
@ -312,7 +312,7 @@ struct UnregisterGattClientRequest
|
||||
struct GattClientReadRemoteRssiRequest
|
||||
{
|
||||
int clientIf;
|
||||
nsString deviceAddress;
|
||||
BluetoothAddress deviceAddress;
|
||||
};
|
||||
|
||||
struct GattClientReadCharacteristicValueRequest
|
||||
@ -351,13 +351,13 @@ struct GattClientWriteDescriptorValueRequest
|
||||
struct GattServerConnectPeripheralRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct GattServerDisconnectPeripheralRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
};
|
||||
|
||||
struct UnregisterGattServerRequest
|
||||
@ -418,7 +418,7 @@ struct GattServerStopServiceRequest
|
||||
struct GattServerSendResponseRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
uint16_t status;
|
||||
int32_t requestId;
|
||||
BluetoothGattResponse response;
|
||||
@ -427,7 +427,7 @@ struct GattServerSendResponseRequest
|
||||
struct GattServerSendIndicationRequest
|
||||
{
|
||||
nsString appUuid;
|
||||
nsString address;
|
||||
BluetoothAddress address;
|
||||
BluetoothAttributeHandle characteristicHandle;
|
||||
bool confirm;
|
||||
uint8_t[] value;
|
||||
|
Loading…
Reference in New Issue
Block a user