Skip to content

Commit

Permalink
Bug 1228546 - Implement peripheral mode support for GATT API. r=brsun…
Browse files Browse the repository at this point in the history
…, r=mrbkap
  • Loading branch information
yrliou committed Jan 15, 2016
1 parent eff6b42 commit 64e09fe
Show file tree
Hide file tree
Showing 23 changed files with 1,017 additions and 29 deletions.
37 changes: 25 additions & 12 deletions dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,27 @@ nsresult
BluetoothDaemonGattModule::ClientSetAdvDataCmd(
int aServerIf, bool aIsScanRsp, bool aIsNameIncluded,
bool aIsTxPowerIncluded, int aMinInterval, int aMaxInterval, int aApperance,
uint16_t aManufacturerLen, char* aManufacturerData,
uint16_t aServiceDataLen, char* aServiceData,
uint16_t aServiceUuidLen, char* aServiceUuid,
const nsTArray<uint8_t>& aManufacturerData,
const nsTArray<uint8_t>& aServiceData,
const nsTArray<BluetoothUuid>& aServiceUuids,
BluetoothGattResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());

nsAutoPtr<DaemonSocketPDU> pdu(
new DaemonSocketPDU(SERVICE_ID, OPCODE_CLIENT_SET_ADV_DATA, 0));

uint16_t manufacturerDataByteLen =
aManufacturerData.Length() * sizeof(uint8_t);
uint16_t serviceDataByteLen = aServiceData.Length() * sizeof(uint8_t);
uint16_t serviceUuidsByteLen =
aServiceUuids.Length() * sizeof(BluetoothUuid::mUuid);
uint8_t* manufacturerData =
const_cast<uint8_t*>(aManufacturerData.Elements());
uint8_t* serviceData = const_cast<uint8_t*>(aServiceData.Elements());
BluetoothUuid* serviceUuids =
const_cast<BluetoothUuid*>(aServiceUuids.Elements());

nsresult rv = PackPDU(
PackConversion<int, int32_t>(aServerIf),
PackConversion<bool, uint8_t>(aIsScanRsp),
Expand All @@ -606,10 +617,12 @@ BluetoothDaemonGattModule::ClientSetAdvDataCmd(
PackConversion<int, int32_t>(aMinInterval),
PackConversion<int, int32_t>(aMaxInterval),
PackConversion<int, int32_t>(aApperance),
aManufacturerLen, aServiceDataLen, aServiceUuidLen,
PackArray<char>(aManufacturerData, aManufacturerLen),
PackArray<char>(aServiceData, aServiceDataLen),
PackArray<char>(aServiceUuid, aServiceUuidLen), *pdu);
manufacturerDataByteLen, serviceDataByteLen, serviceUuidsByteLen,
PackArray<uint8_t>(manufacturerData, aManufacturerData.Length()),
PackArray<uint8_t>(serviceData, aServiceData.Length()),
PackArray<PackReversed<BluetoothUuid>>(
serviceUuids, aServiceUuids.Length()),
*pdu);
if (NS_FAILED(rv)) {
return rv;
}
Expand Down Expand Up @@ -2415,17 +2428,17 @@ void
BluetoothDaemonGattInterface::SetAdvData(
int aServerIf, bool aIsScanRsp, bool aIsNameIncluded,
bool aIsTxPowerIncluded, int aMinInterval, int aMaxInterval, int aApperance,
uint16_t aManufacturerLen, char* aManufacturerData,
uint16_t aServiceDataLen, char* aServiceData,
uint16_t aServiceUUIDLen, char* aServiceUUID,
const nsTArray<uint8_t>& aManufacturerData,
const nsTArray<uint8_t>& aServiceData,
const nsTArray<BluetoothUuid>& aServiceUuids,
BluetoothGattResultHandler* aRes)
{
MOZ_ASSERT(mModule);

nsresult rv = mModule->ClientSetAdvDataCmd(
aServerIf, aIsScanRsp, aIsNameIncluded, aIsTxPowerIncluded, aMinInterval,
aMaxInterval, aApperance, aManufacturerLen, aManufacturerData,
aServiceDataLen, aServiceData, aServiceUUIDLen, aServiceUUID, aRes);
aMaxInterval, aApperance, aManufacturerData, aServiceData, aServiceUuids,
aRes);

if (NS_FAILED(rv)) {
DispatchError(aRes, rv);
Expand Down
15 changes: 6 additions & 9 deletions dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,9 @@ class BluetoothDaemonGattModule
int aMinInterval,
int aMaxInterval,
int aApperance,
uint16_t aManufacturerLen,
char* aManufacturerData,
uint16_t aServiceDataLen,
char* aServiceData,
uint16_t aServiceUUIDLen,
char* aServiceUUID,
const nsTArray<uint8_t>& aManufacturerData,
const nsTArray<uint8_t>& aServiceData,
const nsTArray<BluetoothUuid>& aServiceUuids,
BluetoothGattResultHandler* aRes);

nsresult ClientTestCommandCmd(int aCommand,
Expand Down Expand Up @@ -908,9 +905,9 @@ class BluetoothDaemonGattInterface final
int aMinInterval,
int aMaxInterval,
int aApperance,
uint16_t aManufacturerLen, char* aManufacturerData,
uint16_t aServiceDataLen, char* aServiceData,
uint16_t aServiceUuidLen, char* aServiceUuid,
const nsTArray<uint8_t>& aManufacturerData,
const nsTArray<uint8_t>& aServiceData,
const nsTArray<BluetoothUuid>& aServiceUuids,
BluetoothGattResultHandler* aRes) override;

void TestCommand(int aCommand,
Expand Down
Loading

0 comments on commit 64e09fe

Please sign in to comment.