зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1140952 - Implement read/write value of a descriptor for GATT client API (webapi part). f=jocelyn, r=btian, r=mrbkap
This commit is contained in:
Родитель
c20fe1eef4
Коммит
ea2fb4850a
|
@ -52,3 +52,29 @@ BluetoothGattDescriptor::WrapObject(JSContext* aContext,
|
||||||
{
|
{
|
||||||
return BluetoothGattDescriptorBinding::Wrap(aContext, this, aGivenProto);
|
return BluetoothGattDescriptorBinding::Wrap(aContext, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
BluetoothGattDescriptor::GetValue(JSContext* cx,
|
||||||
|
JS::MutableHandle<JSObject*> aValue) const
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aValue);
|
||||||
|
|
||||||
|
aValue.set(mValue.IsEmpty()
|
||||||
|
? nullptr
|
||||||
|
: ArrayBuffer::Create(cx, mValue.Length(), mValue.Elements()));
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<Promise>
|
||||||
|
BluetoothGattDescriptor::ReadValue(ErrorResult& aRv)
|
||||||
|
{
|
||||||
|
// TODO: This will be implemented by later patch set in the same bug.
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
already_AddRefed<Promise>
|
||||||
|
BluetoothGattDescriptor::WriteValue(
|
||||||
|
const RootedTypedArray<ArrayBuffer>& aValue, ErrorResult& aRv)
|
||||||
|
{
|
||||||
|
// TODO: This will be implemented by later patch set in the same bug.
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/dom/BluetoothGattDescriptorBinding.h"
|
#include "mozilla/dom/BluetoothGattDescriptorBinding.h"
|
||||||
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
|
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
|
||||||
|
#include "mozilla/dom/Promise.h"
|
||||||
|
#include "mozilla/dom/TypedArray.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsWrapperCache.h"
|
#include "nsWrapperCache.h"
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
|
@ -40,6 +42,15 @@ public:
|
||||||
aUuidStr = mUuidStr;
|
aUuidStr = mUuidStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetValue(JSContext* cx, JS::MutableHandle<JSObject*> aValue) const;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Methods (Web API Implementation)
|
||||||
|
***************************************************************************/
|
||||||
|
already_AddRefed<Promise> ReadValue(ErrorResult& aRv);
|
||||||
|
already_AddRefed<Promise> WriteValue(
|
||||||
|
const RootedTypedArray<ArrayBuffer>& aValue, ErrorResult& aRv);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Others
|
* Others
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
@ -81,6 +92,11 @@ private:
|
||||||
* UUID string of this GATT descriptor.
|
* UUID string of this GATT descriptor.
|
||||||
*/
|
*/
|
||||||
nsString mUuidStr;
|
nsString mUuidStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value of this GATT descriptor.
|
||||||
|
*/
|
||||||
|
nsTArray<uint8_t> mValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
END_BLUETOOTH_NAMESPACE
|
END_BLUETOOTH_NAMESPACE
|
||||||
|
|
|
@ -9,4 +9,10 @@ interface BluetoothGattDescriptor
|
||||||
{
|
{
|
||||||
readonly attribute BluetoothGattCharacteristic characteristic;
|
readonly attribute BluetoothGattCharacteristic characteristic;
|
||||||
readonly attribute DOMString uuid;
|
readonly attribute DOMString uuid;
|
||||||
|
readonly attribute ArrayBuffer? value;
|
||||||
|
|
||||||
|
[NewObject]
|
||||||
|
Promise<ArrayBuffer> readValue();
|
||||||
|
[NewObject]
|
||||||
|
Promise<void> writeValue(ArrayBuffer value);
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче