Bug 1156716: Build GATT HAL helpers in Bluetooth v1, r=joliu

This commit is contained in:
Thomas Zimmermann 2015-04-23 10:43:51 +02:00
Родитель 997a9dedca
Коммит d611c792d6
2 изменённых файлов: 15 добавлений и 43 удалений

Просмотреть файл

@ -122,7 +122,6 @@ Convert(const bt_uuid_t& aIn, BluetoothUuid& aOut)
return NS_OK; return NS_OK;
} }
#ifdef MOZ_B2G_BT_API_V2
nsresult nsresult
Convert(const BluetoothUuid& aIn, bt_uuid_t& aOut) Convert(const BluetoothUuid& aIn, bt_uuid_t& aOut)
{ {
@ -134,9 +133,6 @@ Convert(const BluetoothUuid& aIn, bt_uuid_t& aOut)
return NS_OK; return NS_OK;
} }
#else
// TODO: Support GATT
#endif
nsresult nsresult
Convert(const nsAString& aIn, bt_pin_code_t& aOut) Convert(const nsAString& aIn, bt_pin_code_t& aOut)
@ -202,6 +198,13 @@ Convert(const bt_service_record_t& aIn, BluetoothServiceRecord& aOut)
return NS_OK; return NS_OK;
} }
nsresult
Convert(const uint8_t* aIn, BluetoothGattAdvData& aOut)
{
memcpy(aOut.mAdvData, aIn, sizeof(aOut.mAdvData));
return NS_OK;
}
#if ANDROID_VERSION >= 18 #if ANDROID_VERSION >= 18
nsresult nsresult
Convert(const BluetoothAvrcpElementAttribute& aIn, btrc_element_attr_val_t& aOut) Convert(const BluetoothAvrcpElementAttribute& aIn, btrc_element_attr_val_t& aOut)
@ -227,14 +230,6 @@ Convert(const btrc_player_settings_t& aIn, BluetoothAvrcpPlayerSettings& aOut)
} }
#endif // ANDROID_VERSION >= 18 #endif // ANDROID_VERSION >= 18
#ifdef MOZ_B2G_BT_API_V2
nsresult
Convert(const uint8_t* aIn, BluetoothGattAdvData& aOut)
{
memcpy(aOut.mAdvData, aIn, sizeof(aOut.mAdvData));
return NS_OK;
}
#if ANDROID_VERSION >= 19 #if ANDROID_VERSION >= 19
nsresult nsresult
Convert(const BluetoothGattId& aIn, btgatt_gatt_id_t& aOut) Convert(const BluetoothGattId& aIn, btgatt_gatt_id_t& aOut)
@ -343,12 +338,7 @@ Convert(const BluetoothTransport& aIn, btgatt_transport_t& aOut)
aOut = sTransport[aIn]; aOut = sTransport[aIn];
return NS_OK; return NS_OK;
} }
#endif
#else
// TODO: Support GATT
#endif
#if ANDROID_VERSION >= 21
nsresult nsresult
Convert(const bt_activity_energy_info& aIn, BluetoothActivityEnergyInfo& aOut) Convert(const bt_activity_energy_info& aIn, BluetoothActivityEnergyInfo& aOut)
{ {

Просмотреть файл

@ -14,21 +14,13 @@
#if ANDROID_VERSION >= 18 #if ANDROID_VERSION >= 18
#include <hardware/bt_rc.h> #include <hardware/bt_rc.h>
#endif #endif
#ifdef MOZ_B2G_BT_API_V2
#if ANDROID_VERSION >= 19 #if ANDROID_VERSION >= 19
#include <hardware/bt_gatt.h> #include <hardware/bt_gatt.h>
#endif #endif
#else
// Support GATT
#endif
#include "BluetoothCommon.h" #include "BluetoothCommon.h"
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h" #include "mozilla/dom/bluetooth/BluetoothTypes.h"
#ifdef MOZ_B2G_BT_API_V2
#include "mozilla/dom/TypedArray.h" #include "mozilla/dom/TypedArray.h"
#else
// Support GATT
#endif
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
BEGIN_BLUETOOTH_NAMESPACE BEGIN_BLUETOOTH_NAMESPACE
@ -154,12 +146,8 @@ Convert(const uint8_t aIn[16], bt_uuid_t& aOut);
nsresult nsresult
Convert(const bt_uuid_t& aIn, BluetoothUuid& aOut); Convert(const bt_uuid_t& aIn, BluetoothUuid& aOut);
#ifdef MOZ_B2G_BT_API_V2
nsresult nsresult
Convert(const BluetoothUuid& aIn, bt_uuid_t& aOut); Convert(const BluetoothUuid& aIn, bt_uuid_t& aOut);
#else
// TODO: Support GATT
#endif
nsresult nsresult
Convert(const nsAString& aIn, bt_pin_code_t& aOut); Convert(const nsAString& aIn, bt_pin_code_t& aOut);
@ -779,7 +767,6 @@ Convert(btrc_remote_features_t aIn, unsigned long& aOut)
} }
#endif // ANDROID_VERSION >= 19 #endif // ANDROID_VERSION >= 19
#ifdef MOZ_B2G_BT_API_V2
inline nsresult inline nsresult
Convert(int aIn, BluetoothGattStatus& aOut) Convert(int aIn, BluetoothGattStatus& aOut)
{ {
@ -875,6 +862,14 @@ Convert(BluetoothGattWriteType aIn, int& aOut)
return NS_OK; return NS_OK;
} }
inline nsresult
Convert(const ArrayBuffer& aIn, char* aOut)
{
aIn.ComputeLengthAndData();
memcpy(aOut, aIn.Data(), aIn.Length());
return NS_OK;
}
#if ANDROID_VERSION >= 19 #if ANDROID_VERSION >= 19
nsresult nsresult
Convert(const BluetoothGattId& aIn, btgatt_gatt_id_t& aOut); Convert(const BluetoothGattId& aIn, btgatt_gatt_id_t& aOut);
@ -898,23 +893,10 @@ nsresult
Convert(const btgatt_notify_params_t& aIn, BluetoothGattNotifyParam& aOut); Convert(const btgatt_notify_params_t& aIn, BluetoothGattNotifyParam& aOut);
#endif // ANDROID_VERSION >= 19 #endif // ANDROID_VERSION >= 19
inline nsresult
Convert(const ArrayBuffer& aIn, char* aOut)
{
aIn.ComputeLengthAndData();
memcpy(aOut, aIn.Data(), aIn.Length());
return NS_OK;
}
#if ANDROID_VERSION >= 21 #if ANDROID_VERSION >= 21
nsresult nsresult
Convert(const BluetoothTransport& aIn, btgatt_transport_t& aOut); Convert(const BluetoothTransport& aIn, btgatt_transport_t& aOut);
#endif
#else
// TODO: Support GATT
#endif
#if ANDROID_VERSION >= 21
inline nsresult inline nsresult
Convert(BluetoothTransport aIn, int& aOut) Convert(BluetoothTransport aIn, int& aOut)
{ {