diff --git a/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.cpp b/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.cpp index 6d6d7f16781a..0e880894c8b0 100644 --- a/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.cpp +++ b/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.cpp @@ -52,3 +52,29 @@ BluetoothGattDescriptor::WrapObject(JSContext* aContext, { return BluetoothGattDescriptorBinding::Wrap(aContext, this, aGivenProto); } + +void +BluetoothGattDescriptor::GetValue(JSContext* cx, + JS::MutableHandle aValue) const +{ + MOZ_ASSERT(aValue); + + aValue.set(mValue.IsEmpty() + ? nullptr + : ArrayBuffer::Create(cx, mValue.Length(), mValue.Elements())); +} + +already_AddRefed +BluetoothGattDescriptor::ReadValue(ErrorResult& aRv) +{ + // TODO: This will be implemented by later patch set in the same bug. + return nullptr; +} + +already_AddRefed +BluetoothGattDescriptor::WriteValue( + const RootedTypedArray& aValue, ErrorResult& aRv) +{ + // TODO: This will be implemented by later patch set in the same bug. + return nullptr; +} diff --git a/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.h b/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.h index 0689a614107c..4078179718d6 100644 --- a/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.h +++ b/dom/bluetooth/bluetooth2/BluetoothGattDescriptor.h @@ -10,6 +10,8 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/BluetoothGattDescriptorBinding.h" #include "mozilla/dom/bluetooth/BluetoothCommon.h" +#include "mozilla/dom/Promise.h" +#include "mozilla/dom/TypedArray.h" #include "nsCOMPtr.h" #include "nsWrapperCache.h" #include "nsPIDOMWindow.h" @@ -40,6 +42,15 @@ public: aUuidStr = mUuidStr; } + void GetValue(JSContext* cx, JS::MutableHandle aValue) const; + + /**************************************************************************** + * Methods (Web API Implementation) + ***************************************************************************/ + already_AddRefed ReadValue(ErrorResult& aRv); + already_AddRefed WriteValue( + const RootedTypedArray& aValue, ErrorResult& aRv); + /**************************************************************************** * Others ***************************************************************************/ @@ -81,6 +92,11 @@ private: * UUID string of this GATT descriptor. */ nsString mUuidStr; + + /** + * Value of this GATT descriptor. + */ + nsTArray mValue; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/webidl/BluetoothGattDescriptor.webidl b/dom/webidl/BluetoothGattDescriptor.webidl index 5f2d8be56578..5db729100ab4 100644 --- a/dom/webidl/BluetoothGattDescriptor.webidl +++ b/dom/webidl/BluetoothGattDescriptor.webidl @@ -9,4 +9,10 @@ interface BluetoothGattDescriptor { readonly attribute BluetoothGattCharacteristic characteristic; readonly attribute DOMString uuid; + readonly attribute ArrayBuffer? value; + + [NewObject] + Promise readValue(); + [NewObject] + Promise writeValue(ArrayBuffer value); };