mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
WebBluetooth API classes
This commit is contained in:
parent
00628704ca
commit
e7d70cfabf
28 changed files with 999 additions and 28 deletions
|
@ -82,6 +82,7 @@ rand = "0.3"
|
|||
phf = "0.7.13"
|
||||
phf_macros = "0.7.13"
|
||||
ref_slice = "0.1.0"
|
||||
regex = "0.1.43"
|
||||
rustc-serialize = "0.3"
|
||||
selectors = {version = "0.5", features = ["heap_size"]}
|
||||
serde = "0.6"
|
||||
|
|
39
components/script/dom/bluetooth.rs
Normal file
39
components/script/dom/bluetooth.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
|
||||
#[dom_struct]
|
||||
pub struct Bluetooth {
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
impl Bluetooth {
|
||||
pub fn new_inherited() -> Bluetooth {
|
||||
Bluetooth {
|
||||
reflector_: Reflector::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef) -> Root<Bluetooth> {
|
||||
reflect_dom_object(box Bluetooth::new_inherited(),
|
||||
global,
|
||||
BluetoothBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothMethods for Bluetooth {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||
fn RequestDevice(&self) -> Option<Root<BluetoothDevice>> {
|
||||
//UNIMPLEMENTED
|
||||
None
|
||||
}
|
||||
}
|
54
components/script/dom/bluetoothadvertisingdata.rs
Normal file
54
components/script/dom/bluetoothadvertisingdata.rs
Normal file
|
@ -0,0 +1,54 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding::BluetoothAdvertisingDataMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
|
||||
#[dom_struct]
|
||||
pub struct BluetoothAdvertisingData {
|
||||
reflector_: Reflector,
|
||||
appearance: u16,
|
||||
txPower: i8,
|
||||
rssi: i8,
|
||||
}
|
||||
|
||||
impl BluetoothAdvertisingData {
|
||||
pub fn new_inherited(appearance: u16, txPower: i8, rssi: i8) -> BluetoothAdvertisingData {
|
||||
BluetoothAdvertisingData {
|
||||
reflector_: Reflector::new(),
|
||||
appearance: appearance,
|
||||
txPower: txPower,
|
||||
rssi: rssi,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, appearance: u16, txPower: i8, rssi: i8) -> Root<BluetoothAdvertisingData> {
|
||||
reflect_dom_object(box BluetoothAdvertisingData::new_inherited(appearance,
|
||||
txPower,
|
||||
rssi),
|
||||
global,
|
||||
BluetoothAdvertisingDataBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothAdvertisingDataMethods for BluetoothAdvertisingData {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-appearance
|
||||
fn GetAppearance(&self) -> Option<u16> {
|
||||
Some(self.appearance)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-txpower
|
||||
fn GetTxPower(&self) -> Option<i8> {
|
||||
Some(self.txPower)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-rssi
|
||||
fn GetRssi(&self) -> Option<i8> {
|
||||
Some(self.rssi)
|
||||
}
|
||||
}
|
122
components/script/dom/bluetoothcharacteristicproperties.rs
Normal file
122
components/script/dom/bluetoothcharacteristicproperties.rs
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
|
||||
BluetoothCharacteristicPropertiesMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
|
||||
#[dom_struct]
|
||||
pub struct BluetoothCharacteristicProperties {
|
||||
reflector_: Reflector,
|
||||
broadcast: bool,
|
||||
read: bool,
|
||||
writeWithoutResponse: bool,
|
||||
write: bool,
|
||||
notify: bool,
|
||||
indicate: bool,
|
||||
authenticatedSignedWrites: bool,
|
||||
reliableWrite: bool,
|
||||
writableAuxiliaries: bool,
|
||||
}
|
||||
|
||||
impl BluetoothCharacteristicProperties {
|
||||
pub fn new_inherited(broadcast: bool,
|
||||
read: bool,
|
||||
writeWithoutResponse: bool,
|
||||
write: bool,
|
||||
notify: bool,
|
||||
indicate: bool,
|
||||
authenticatedSignedWrites: bool,
|
||||
reliableWrite: bool,
|
||||
writableAuxiliaries: bool)
|
||||
-> BluetoothCharacteristicProperties {
|
||||
BluetoothCharacteristicProperties {
|
||||
reflector_: Reflector::new(),
|
||||
broadcast: broadcast,
|
||||
read: read,
|
||||
writeWithoutResponse: writeWithoutResponse,
|
||||
write: write,
|
||||
notify: notify,
|
||||
indicate: indicate,
|
||||
authenticatedSignedWrites: authenticatedSignedWrites,
|
||||
reliableWrite: reliableWrite,
|
||||
writableAuxiliaries: writableAuxiliaries,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
broadcast: bool,
|
||||
read: bool,
|
||||
writeWithoutResponse: bool,
|
||||
write: bool,
|
||||
notify: bool,
|
||||
indicate: bool,
|
||||
authenticatedSignedWrites: bool,
|
||||
reliableWrite: bool,
|
||||
writableAuxiliaries: bool)
|
||||
-> Root<BluetoothCharacteristicProperties> {
|
||||
reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
|
||||
read,
|
||||
writeWithoutResponse,
|
||||
write,
|
||||
notify,
|
||||
indicate,
|
||||
authenticatedSignedWrites,
|
||||
reliableWrite,
|
||||
writableAuxiliaries),
|
||||
global,
|
||||
BluetoothCharacteristicPropertiesBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothCharacteristicPropertiesMethods for BluetoothCharacteristicProperties {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-broadcast
|
||||
fn Broadcast(&self) -> bool {
|
||||
self.broadcast
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-read
|
||||
fn Read(&self) -> bool {
|
||||
self.read
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writewithoutresponse
|
||||
fn WriteWithoutResponse(&self) -> bool {
|
||||
self.writeWithoutResponse
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-write
|
||||
fn Write(&self) -> bool {
|
||||
self.write
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-notify
|
||||
fn Notify(&self) -> bool {
|
||||
self.notify
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-indicate
|
||||
fn Indicate(&self) -> bool {
|
||||
self.indicate
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-authenticatedsignedwrites
|
||||
fn AuthenticatedSignedWrites(&self) -> bool {
|
||||
self.authenticatedSignedWrites
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-reliablewrite
|
||||
fn ReliableWrite(&self) -> bool {
|
||||
self.reliableWrite
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writableauxiliaries
|
||||
fn WritableAuxiliaries(&self) -> bool {
|
||||
self.writableAuxiliaries
|
||||
}
|
||||
}
|
125
components/script/dom/bluetoothdevice.rs
Normal file
125
components/script/dom/bluetoothdevice.rs
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::{BluetoothDeviceMethods, VendorIDSource};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, Root, MutHeap};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
|
||||
use dom::bluetoothremotegattserver::BluetoothRemoteGATTServer;
|
||||
use util::str::DOMString;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
|
||||
#[dom_struct]
|
||||
pub struct BluetoothDevice {
|
||||
reflector_: Reflector,
|
||||
id: DOMString,
|
||||
name: DOMString,
|
||||
adData: MutHeap<JS<BluetoothAdvertisingData>>,
|
||||
deviceClass: u32,
|
||||
vendorIDSource: VendorIDSource,
|
||||
vendorID: u32,
|
||||
productID: u32,
|
||||
productVersion: u32,
|
||||
gatt: MutHeap<JS<BluetoothRemoteGATTServer>>,
|
||||
}
|
||||
|
||||
impl BluetoothDevice {
|
||||
pub fn new_inherited(id: DOMString,
|
||||
name: DOMString,
|
||||
adData: &BluetoothAdvertisingData,
|
||||
deviceClass: u32,
|
||||
vendorIDSource: VendorIDSource,
|
||||
vendorID: u32,
|
||||
productID: u32,
|
||||
productVersion: u32,
|
||||
gatt: &BluetoothRemoteGATTServer)
|
||||
-> BluetoothDevice {
|
||||
BluetoothDevice {
|
||||
reflector_: Reflector::new(),
|
||||
id: id,
|
||||
name: name,
|
||||
adData: MutHeap::new(adData),
|
||||
deviceClass: deviceClass,
|
||||
vendorIDSource: vendorIDSource,
|
||||
vendorID: vendorID,
|
||||
productID: productID,
|
||||
productVersion: productVersion,
|
||||
gatt: MutHeap::new(gatt),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
id: DOMString,
|
||||
name: DOMString,
|
||||
adData: &BluetoothAdvertisingData,
|
||||
deviceClass: u32,
|
||||
vendorIDSource: VendorIDSource,
|
||||
vendorID: u32,
|
||||
productID: u32,
|
||||
productVersion: u32,
|
||||
gatt: &BluetoothRemoteGATTServer)
|
||||
-> Root<BluetoothDevice> {
|
||||
reflect_dom_object(box BluetoothDevice::new_inherited(id,
|
||||
name,
|
||||
adData,
|
||||
deviceClass,
|
||||
vendorIDSource,
|
||||
vendorID,
|
||||
productID,
|
||||
productVersion,
|
||||
gatt),
|
||||
global,
|
||||
BluetoothDeviceBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothDeviceMethods for BluetoothDevice {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-id
|
||||
fn Id(&self) -> DOMString {
|
||||
self.id.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-name
|
||||
fn GetName(&self) -> Option<DOMString> {
|
||||
Some(self.name.clone())
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-addata
|
||||
fn AdData(&self) -> Root<BluetoothAdvertisingData> {
|
||||
self.adData.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-deviceclass
|
||||
fn GetDeviceClass(&self) -> Option<u32> {
|
||||
Some(self.deviceClass)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-vendoridsource
|
||||
fn GetVendorIDSource(&self) -> Option<VendorIDSource> {
|
||||
Some(self.vendorIDSource)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-vendorid
|
||||
fn GetVendorID(&self) -> Option<u32> {
|
||||
Some(self.vendorID)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-productid
|
||||
fn GetProductID(&self) -> Option<u32> {
|
||||
Some(self.productID)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-productversion
|
||||
fn GetProductVersion(&self) -> Option<u32> {
|
||||
Some(self.productVersion)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
|
||||
fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||
self.gatt.get()
|
||||
}
|
||||
}
|
87
components/script/dom/bluetoothremotegattcharacteristic.rs
Normal file
87
components/script/dom/bluetoothremotegattcharacteristic.rs
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
|
||||
BluetoothRemoteGATTCharacteristicMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::ByteString;
|
||||
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
|
||||
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
|
||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||
use util::str::DOMString;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
|
||||
#[dom_struct]
|
||||
pub struct BluetoothRemoteGATTCharacteristic {
|
||||
reflector_: Reflector,
|
||||
service: MutHeap<JS<BluetoothRemoteGATTService>>,
|
||||
uuid: DOMString,
|
||||
properties: MutHeap<JS<BluetoothCharacteristicProperties>>,
|
||||
value: Option<ByteString>,
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTCharacteristic {
|
||||
pub fn new_inherited(service: &BluetoothRemoteGATTService,
|
||||
uuid: DOMString,
|
||||
properties: &BluetoothCharacteristicProperties)
|
||||
-> BluetoothRemoteGATTCharacteristic {
|
||||
BluetoothRemoteGATTCharacteristic {
|
||||
reflector_: Reflector::new(),
|
||||
service: MutHeap::new(service),
|
||||
uuid: uuid,
|
||||
properties: MutHeap::new(properties),
|
||||
value: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
service: &BluetoothRemoteGATTService,
|
||||
uuid: DOMString,
|
||||
properties: &BluetoothCharacteristicProperties)
|
||||
-> Root<BluetoothRemoteGATTCharacteristic> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service,
|
||||
uuid,
|
||||
properties),
|
||||
global,
|
||||
BluetoothRemoteGATTCharacteristicBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties
|
||||
fn Properties(&self) -> Root<BluetoothCharacteristicProperties> {
|
||||
self.properties.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service
|
||||
fn Service(&self) -> Root<BluetoothRemoteGATTService> {
|
||||
self.service.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-uuid
|
||||
fn Uuid(&self) -> DOMString {
|
||||
self.uuid.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
|
||||
fn GetDescriptor(&self) -> Option<Root<BluetoothRemoteGATTDescriptor>> {
|
||||
//UNIMPLEMENTED
|
||||
None
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-value
|
||||
fn GetValue(&self) -> Option<ByteString> {
|
||||
self.value.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
|
||||
fn ReadValue(&self) -> ByteString {
|
||||
//UNIMPLEMENTED
|
||||
ByteString::new(vec!())
|
||||
}
|
||||
}
|
68
components/script/dom/bluetoothremotegattdescriptor.rs
Normal file
68
components/script/dom/bluetoothremotegattdescriptor.rs
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::ByteString;
|
||||
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
|
||||
use util::str::DOMString;
|
||||
|
||||
// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
|
||||
#[dom_struct]
|
||||
pub struct BluetoothRemoteGATTDescriptor {
|
||||
reflector_: Reflector,
|
||||
characteristic: MutHeap<JS<BluetoothRemoteGATTCharacteristic>>,
|
||||
uuid: DOMString,
|
||||
value: Option<ByteString>,
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTDescriptor {
|
||||
pub fn new_inherited(characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||
uuid: DOMString)
|
||||
-> BluetoothRemoteGATTDescriptor {
|
||||
BluetoothRemoteGATTDescriptor {
|
||||
reflector_: Reflector::new(),
|
||||
characteristic: MutHeap::new(characteristic),
|
||||
uuid: uuid,
|
||||
value: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
characteristic: &BluetoothRemoteGATTCharacteristic,
|
||||
uuid: DOMString)
|
||||
-> Root<BluetoothRemoteGATTDescriptor>{
|
||||
reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic,
|
||||
uuid),
|
||||
global,
|
||||
BluetoothRemoteGATTDescriptorBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic
|
||||
fn Characteristic(&self) -> Root<BluetoothRemoteGATTCharacteristic> {
|
||||
self.characteristic.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-uuid
|
||||
fn Uuid(&self) -> DOMString {
|
||||
self.uuid.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-value
|
||||
fn GetValue(&self) -> Option<ByteString> {
|
||||
self.value.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
|
||||
fn ReadValue(&self) -> ByteString {
|
||||
//UNIMPLEMENTED
|
||||
ByteString::new(vec!())
|
||||
}
|
||||
}
|
70
components/script/dom/bluetoothremotegattserver.rs
Normal file
70
components/script/dom/bluetoothremotegattserver.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
|
||||
use std::cell::Cell;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver
|
||||
#[dom_struct]
|
||||
pub struct BluetoothRemoteGATTServer {
|
||||
reflector_: Reflector,
|
||||
device: MutHeap<JS<BluetoothDevice>>,
|
||||
connected: Cell<bool>,
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTServer {
|
||||
pub fn new_inherited(device: &BluetoothDevice, is_connected: bool) -> BluetoothRemoteGATTServer {
|
||||
BluetoothRemoteGATTServer {
|
||||
reflector_: Reflector::new(),
|
||||
device: MutHeap::new(device),
|
||||
connected: Cell::new(is_connected),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef, device: &BluetoothDevice, connected: bool) -> Root<BluetoothRemoteGATTServer> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(
|
||||
device,
|
||||
connected),
|
||||
global,
|
||||
BluetoothRemoteGATTServerBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
|
||||
fn Device(&self) -> Root<BluetoothDevice> {
|
||||
self.device.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
|
||||
fn Connected(&self) -> bool {
|
||||
self.connected.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
|
||||
fn Connect(&self) -> Root<BluetoothRemoteGATTServer> {
|
||||
if !self.connected.get() {
|
||||
self.connected.set(true);
|
||||
}
|
||||
Root::from_ref(self)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
|
||||
fn Disconnect(&self) {
|
||||
self.connected.set(false);
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
|
||||
fn GetPrimaryService(&self) -> Option<Root<BluetoothRemoteGATTService>> {
|
||||
//UNIMPLEMENTED
|
||||
None
|
||||
}
|
||||
}
|
70
components/script/dom/bluetoothremotegattservice.rs
Normal file
70
components/script/dom/bluetoothremotegattservice.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
|
||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bluetoothdevice::BluetoothDevice;
|
||||
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
|
||||
use util::str::DOMString;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
|
||||
#[dom_struct]
|
||||
pub struct BluetoothRemoteGATTService {
|
||||
reflector_: Reflector,
|
||||
device: MutHeap<JS<BluetoothDevice>>,
|
||||
uuid: DOMString,
|
||||
isPrimary: bool,
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTService {
|
||||
pub fn new_inherited(device: &BluetoothDevice,
|
||||
uuid: DOMString,
|
||||
isPrimary: bool)
|
||||
-> BluetoothRemoteGATTService {
|
||||
BluetoothRemoteGATTService {
|
||||
reflector_: Reflector::new(),
|
||||
device: MutHeap::new(device),
|
||||
uuid: uuid,
|
||||
isPrimary: isPrimary,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
device: &BluetoothDevice,
|
||||
uuid: DOMString,
|
||||
isPrimary: bool)
|
||||
-> Root<BluetoothRemoteGATTService> {
|
||||
reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device,
|
||||
uuid,
|
||||
isPrimary),
|
||||
global,
|
||||
BluetoothRemoteGATTServiceBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device
|
||||
fn Device(&self) -> Root<BluetoothDevice> {
|
||||
self.device.get()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary
|
||||
fn IsPrimary(&self) -> bool {
|
||||
self.isPrimary
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-uuid
|
||||
fn Uuid(&self) -> DOMString {
|
||||
self.uuid.clone()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristic
|
||||
fn GetCharacteristic(&self) -> Option<Root<BluetoothRemoteGATTCharacteristic>> {
|
||||
// UNIMPLEMENTED
|
||||
None
|
||||
}
|
||||
}
|
116
components/script/dom/bluetoothuuid.rs
Normal file
116
components/script/dom/bluetoothuuid.rs
Normal file
|
@ -0,0 +1,116 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
|
||||
use dom::bindings::error::Error::Syntax;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::reflector::Reflector;
|
||||
use regex::Regex;
|
||||
use util::str::DOMString;
|
||||
|
||||
pub type UUID = DOMString;
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
|
||||
#[dom_struct]
|
||||
pub struct BluetoothUUID {
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
const BLUETOOTH_ASSIGNED_SERVICES: &'static [(&'static str, u32)] = &[
|
||||
//TODO(zakorgy) create all the services
|
||||
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
|
||||
("org.bluetooth.service.alert_notification", 0x1811_u32),
|
||||
("org.bluetooth.service.automation_io", 0x1815_u32),
|
||||
("org.bluetooth.service.battery_service", 0x180f_u32)
|
||||
];
|
||||
|
||||
const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &'static [(&'static str, u32)] = &[
|
||||
//TODO(zakorgy) create all the characteristics
|
||||
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
|
||||
("org.bluetooth.characteristic.aerobic_heart_rate_lower_limit", 0x2a7e_u32),
|
||||
("org.bluetooth.characteristic.aerobic_heart_rate_upper_limit", 0x2a84_u32),
|
||||
("org.bluetooth.characteristic.battery_level", 0x2a19_u32)
|
||||
];
|
||||
|
||||
const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&'static str, u32)] = &[
|
||||
//TODO(zakorgy) create all the descriptors
|
||||
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
|
||||
("org.bluetooth.descriptor.gatt.characteristic_extended_properties", 0x2900_u32),
|
||||
("org.bluetooth.descriptor.gatt.characteristic_user_description", 0x2901_u32)
|
||||
];
|
||||
|
||||
const BASE_UUID: &'static str = "-0000-1000-8000-00805f9b34fb";
|
||||
const SERVICE_PREFIX: &'static str = "org.bluetooth.service";
|
||||
const CHARACTERISTIC_PREFIX: &'static str = "org.bluetooth.characteristic";
|
||||
const DESCRIPTOR_PREFIX: &'static str = "org.bluetooth.descriptor";
|
||||
const VALID_UUID_REGEX: &'static str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
||||
|
||||
impl BluetoothUUID {
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid
|
||||
pub fn CanonicalUUID(_: GlobalRef, alias: u32) -> UUID {
|
||||
DOMString::from(format!("{:08x}", &alias) + BASE_UUID)
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice
|
||||
pub fn GetService(globalref: GlobalRef,
|
||||
name: StringOrUnsignedLong)
|
||||
-> Fallible<UUID> {
|
||||
BluetoothUUID::resolve_uuid_name(globalref,
|
||||
name,
|
||||
BLUETOOTH_ASSIGNED_SERVICES,
|
||||
DOMString::from(SERVICE_PREFIX))
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic
|
||||
pub fn GetCharacteristic(globalref: GlobalRef,
|
||||
name: StringOrUnsignedLong)
|
||||
-> Fallible<UUID> {
|
||||
BluetoothUUID::resolve_uuid_name(globalref,
|
||||
name,
|
||||
BLUETOOTH_ASSIGNED_CHARCTERISTICS,
|
||||
DOMString::from(CHARACTERISTIC_PREFIX))
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor
|
||||
pub fn GetDescriptor(globalref: GlobalRef,
|
||||
name: StringOrUnsignedLong)
|
||||
-> Fallible<UUID> {
|
||||
BluetoothUUID::resolve_uuid_name(globalref,
|
||||
name,
|
||||
BLUETOOTH_ASSIGNED_DESCRIPTORS,
|
||||
DOMString::from(DESCRIPTOR_PREFIX))
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#resolveuuidname
|
||||
pub fn resolve_uuid_name(globalref: GlobalRef,
|
||||
name: StringOrUnsignedLong,
|
||||
assigned_numbers_table: &'static [(&'static str, u32)],
|
||||
prefix: DOMString)
|
||||
-> Fallible<DOMString> {
|
||||
match name {
|
||||
// Step 1
|
||||
StringOrUnsignedLong::UnsignedLong(unsigned32) =>{
|
||||
Ok(BluetoothUUID::CanonicalUUID(globalref, unsigned32))
|
||||
},
|
||||
StringOrUnsignedLong::String(dstring) => {
|
||||
// Step 2
|
||||
let regex = Regex::new(VALID_UUID_REGEX).unwrap();
|
||||
if regex.is_match(&*dstring) {
|
||||
Ok(dstring)
|
||||
} else {
|
||||
// Step 3
|
||||
let concatenated = format!("{}.{}", prefix, dstring);
|
||||
let is_in_table = assigned_numbers_table.iter()
|
||||
.find(|p| p.0 == concatenated);
|
||||
match is_in_table {
|
||||
Some(&(_, alias)) => Ok(BluetoothUUID::CanonicalUUID(globalref, alias)),
|
||||
None => Err(Syntax),
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
|
@ -218,6 +218,15 @@ mod create;
|
|||
#[deny(missing_docs, non_snake_case)]
|
||||
pub mod bindings;
|
||||
pub mod blob;
|
||||
pub mod bluetooth;
|
||||
pub mod bluetoothadvertisingdata;
|
||||
pub mod bluetoothcharacteristicproperties;
|
||||
pub mod bluetoothdevice;
|
||||
pub mod bluetoothremotegattcharacteristic;
|
||||
pub mod bluetoothremotegattdescriptor;
|
||||
pub mod bluetoothremotegattserver;
|
||||
pub mod bluetoothremotegattservice;
|
||||
pub mod bluetoothuuid;
|
||||
pub mod browsingcontext;
|
||||
pub mod canvasgradient;
|
||||
pub mod canvaspattern;
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
use dom::bindings::codegen::Bindings::NavigatorBinding;
|
||||
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bluetooth::Bluetooth;
|
||||
use dom::navigatorinfo;
|
||||
use dom::window::Window;
|
||||
use util::str::DOMString;
|
||||
|
@ -14,12 +15,14 @@ use util::str::DOMString;
|
|||
#[dom_struct]
|
||||
pub struct Navigator {
|
||||
reflector_: Reflector,
|
||||
bluetooth: MutNullableHeap<JS<Bluetooth>>,
|
||||
}
|
||||
|
||||
impl Navigator {
|
||||
fn new_inherited() -> Navigator {
|
||||
Navigator {
|
||||
reflector_: Reflector::new()
|
||||
reflector_: Reflector::new(),
|
||||
bluetooth: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,4 +68,9 @@ impl NavigatorMethods for Navigator {
|
|||
fn AppVersion(&self) -> DOMString {
|
||||
navigatorinfo::AppVersion()
|
||||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
|
||||
fn Bluetooth(&self) -> Root<Bluetooth> {
|
||||
self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
|
||||
}
|
||||
}
|
||||
|
|
15
components/script/dom/webidls/Bluetooth.webidl
Normal file
15
components/script/dom/webidls/Bluetooth.webidl
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
|
||||
|
||||
interface Bluetooth {
|
||||
// Promise<BluetoothDevice> requestDevice(RequestDeviceOptions options);
|
||||
BluetoothDevice? requestDevice(/*RequestDeviceOptions options*/);
|
||||
};
|
||||
|
||||
// Bluetooth implements EventTarget;
|
||||
// Bluetooth implements CharacteristicEventHandlers;
|
||||
// Bluetooth implements ServiceEventHandlers;
|
|
@ -0,0 +1,22 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
|
||||
|
||||
/*interface BluetoothManufacturerDataMap {
|
||||
readonly maplike<unsigned short, DataView>;
|
||||
};
|
||||
|
||||
interface BluetoothServiceDataMap {
|
||||
readonly maplike<UUID, DataView>;
|
||||
};*/
|
||||
|
||||
interface BluetoothAdvertisingData {
|
||||
readonly attribute unsigned short? appearance;
|
||||
readonly attribute byte? txPower;
|
||||
readonly attribute byte? rssi;
|
||||
// readonly attribute BluetoothManufacturerDataMap manufacturerData;
|
||||
// readonly attribute BluetoothServiceDataMap serviceData;
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
|
||||
|
||||
interface BluetoothCharacteristicProperties {
|
||||
readonly attribute boolean broadcast;
|
||||
readonly attribute boolean read;
|
||||
readonly attribute boolean writeWithoutResponse;
|
||||
readonly attribute boolean write;
|
||||
readonly attribute boolean notify;
|
||||
readonly attribute boolean indicate;
|
||||
readonly attribute boolean authenticatedSignedWrites;
|
||||
readonly attribute boolean reliableWrite;
|
||||
readonly attribute boolean writableAuxiliaries;
|
||||
};
|
30
components/script/dom/webidls/BluetoothDevice.webidl
Normal file
30
components/script/dom/webidls/BluetoothDevice.webidl
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
|
||||
|
||||
// Allocation authorities for Vendor IDs:
|
||||
enum VendorIDSource {
|
||||
"bluetooth",
|
||||
"usb"
|
||||
};
|
||||
|
||||
interface BluetoothDevice {
|
||||
readonly attribute DOMString id;
|
||||
readonly attribute DOMString? name;
|
||||
readonly attribute BluetoothAdvertisingData adData;
|
||||
readonly attribute unsigned long? deviceClass;
|
||||
readonly attribute VendorIDSource? vendorIDSource;
|
||||
readonly attribute unsigned long? vendorID;
|
||||
readonly attribute unsigned long? productID;
|
||||
readonly attribute unsigned long? productVersion;
|
||||
readonly attribute BluetoothRemoteGATTServer gatt;
|
||||
// readonly attribute FrozenArray[] uuids;
|
||||
};
|
||||
|
||||
// BluetoothDevice implements EventTarget;
|
||||
// BluetoothDevice implements BluetoothDeviceEventHandlers;
|
||||
// BluetoothDevice implements CharacteristicEventHandlers;
|
||||
// BluetoothDevice implements ServiceEventHandlers;
|
|
@ -0,0 +1,25 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
|
||||
|
||||
interface BluetoothRemoteGATTCharacteristic {
|
||||
readonly attribute BluetoothRemoteGATTService service;
|
||||
readonly attribute DOMString uuid;
|
||||
readonly attribute BluetoothCharacteristicProperties properties;
|
||||
readonly attribute ByteString? value;
|
||||
BluetoothRemoteGATTDescriptor? getDescriptor(/*BluetoothDescriptorUUID descriptor*/);
|
||||
//Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor);
|
||||
//Promise<sequence<BluetoothRemoteGATTDescriptor>>
|
||||
//getDescriptors(optional BluetoothDescriptorUUID descriptor);
|
||||
//Promise<DataView> readValue();
|
||||
ByteString readValue();
|
||||
//Promise<void> writeValue(BufferSource value);
|
||||
//Promise<void> startNotifications();
|
||||
//Promise<void> stopNotifications();
|
||||
};
|
||||
|
||||
//BluetootRemoteGATTCharacteristic implements EventTarget;
|
||||
//BluetootRemoteGATTCharacteristic implements CharacteristicEventHandlers;
|
|
@ -0,0 +1,16 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
|
||||
|
||||
interface BluetoothRemoteGATTDescriptor {
|
||||
readonly attribute BluetoothRemoteGATTCharacteristic characteristic;
|
||||
readonly attribute DOMString uuid;
|
||||
readonly attribute ByteString? value;
|
||||
|
||||
ByteString readValue();
|
||||
//Promise<DataView> readValue();
|
||||
//Promise<void> writeValue(BufferSource value);
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver
|
||||
|
||||
interface BluetoothRemoteGATTServer {
|
||||
readonly attribute BluetoothDevice device;
|
||||
readonly attribute boolean connected;
|
||||
BluetoothRemoteGATTServer connect();
|
||||
void disconnect();
|
||||
BluetoothRemoteGATTService? getPrimaryService();
|
||||
//Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
|
||||
//Promise<sequence<BluetoothRemoteGATTService>>getPrimaryServices(optional BluetoothServiceUUID service);
|
||||
//Promise<BluetoothRemoteGATTServer> connect();
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
|
||||
|
||||
interface BluetoothRemoteGATTService {
|
||||
readonly attribute BluetoothDevice device;
|
||||
readonly attribute DOMString uuid;
|
||||
readonly attribute boolean isPrimary;
|
||||
BluetoothRemoteGATTCharacteristic? getCharacteristic(/*DOMString characteristic*/);
|
||||
//Promise<BluetoothRemoteGATTCharacteristic>getCharacteristic(BluetoothCharacteristicUUID characteristic);
|
||||
//Promise<sequence<BluetoothRemoteGATTCharacteristic>>
|
||||
//getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
|
||||
//Promise<BluetoothRemoteGATTService>getIncludedService(BluetoothServiceUUID service);
|
||||
//Promise<sequence<BluetoothRemoteGATTService>>getIncludedServices(optional BluetoothServiceUUID service);
|
||||
};
|
21
components/script/dom/webidls/BluetoothUUID.webidl
Normal file
21
components/script/dom/webidls/BluetoothUUID.webidl
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
|
||||
|
||||
interface BluetoothUUID {
|
||||
[Throws]
|
||||
static UUID getService(BluetoothServiceUUID name);
|
||||
[Throws]
|
||||
static UUID getCharacteristic(BluetoothCharacteristicUUID name);
|
||||
[Throws]
|
||||
static UUID getDescriptor(BluetoothDescriptorUUID name);
|
||||
static UUID canonicalUUID([EnforceRange] unsigned long alias);
|
||||
};
|
||||
|
||||
typedef DOMString UUID;
|
||||
typedef (DOMString or unsigned long) BluetoothServiceUUID;
|
||||
typedef (DOMString or unsigned long) BluetoothCharacteristicUUID;
|
||||
typedef (DOMString or unsigned long) BluetoothDescriptorUUID;
|
|
@ -8,6 +8,7 @@ interface Navigator {
|
|||
// objects implementing this interface also implement the interfaces given below
|
||||
};
|
||||
Navigator implements NavigatorID;
|
||||
Navigator implements NavigatorBluetooth;
|
||||
//Navigator implements NavigatorLanguage;
|
||||
//Navigator implements NavigatorOnLine;
|
||||
//Navigator implements NavigatorContentUtils;
|
||||
|
@ -25,3 +26,8 @@ interface NavigatorID {
|
|||
boolean taintEnabled(); // constant false
|
||||
readonly attribute DOMString userAgent;
|
||||
};
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface NavigatorBluetooth {
|
||||
readonly attribute Bluetooth bluetooth;
|
||||
};
|
||||
|
|
|
@ -61,6 +61,7 @@ extern crate phf;
|
|||
extern crate profile_traits;
|
||||
extern crate rand;
|
||||
extern crate ref_slice;
|
||||
extern crate regex;
|
||||
extern crate rustc_serialize;
|
||||
extern crate script_traits;
|
||||
extern crate selectors;
|
||||
|
|
19
components/servo/Cargo.lock
generated
19
components/servo/Cargo.lock
generated
|
@ -190,7 +190,7 @@ name = "caseless"
|
|||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -548,7 +548,7 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -825,7 +825,7 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1503,7 +1503,7 @@ dependencies = [
|
|||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"task_info 0.0.1",
|
||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1581,18 +1581,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.51"
|
||||
version = "0.1.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.2.3"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -1651,6 +1651,7 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2214,7 +2215,7 @@ source = "git+https://github.com/jgraham/webdriver-rust.git#9dffcbe409af052788b7
|
|||
dependencies = [
|
||||
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -2230,7 +2231,7 @@ dependencies = [
|
|||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
|
19
ports/cef/Cargo.lock
generated
19
ports/cef/Cargo.lock
generated
|
@ -177,7 +177,7 @@ name = "caseless"
|
|||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -487,7 +487,7 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -755,7 +755,7 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1391,7 +1391,7 @@ dependencies = [
|
|||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"task_info 0.0.1",
|
||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1467,18 +1467,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.51"
|
||||
version = "0.1.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.2.3"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -1537,6 +1537,7 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2100,7 +2101,7 @@ source = "git+https://github.com/jgraham/webdriver-rust.git#9dffcbe409af052788b7
|
|||
dependencies = [
|
||||
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -2116,7 +2117,7 @@ dependencies = [
|
|||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
|
15
ports/gonk/Cargo.lock
generated
15
ports/gonk/Cargo.lock
generated
|
@ -169,7 +169,7 @@ name = "caseless"
|
|||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -479,7 +479,7 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -736,7 +736,7 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1372,7 +1372,7 @@ dependencies = [
|
|||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"profile_traits 0.0.1",
|
||||
"regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"task_info 0.0.1",
|
||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"util 0.0.1",
|
||||
|
@ -1448,18 +1448,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.51"
|
||||
version = "0.1.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.2.3"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -1518,6 +1518,7 @@ dependencies = [
|
|||
"profile_traits 0.0.1",
|
||||
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -463,6 +463,7 @@ def check_webidl_spec(file_name, contents):
|
|||
"//xhr.spec.whatwg.org",
|
||||
"//w3c.github.io",
|
||||
"//heycam.github.io/webidl",
|
||||
"//webbluetoothcg.github.io/web-bluetooth/",
|
||||
# Not a URL
|
||||
"// This interface is entirely internal to Servo, and should not be" +
|
||||
" accessible to\n// web pages."
|
||||
|
|
|
@ -73,6 +73,15 @@ var ecmaGlobals = [
|
|||
var interfaceNamesInGlobalScope = [
|
||||
"Attr",
|
||||
"Blob",
|
||||
"Bluetooth",
|
||||
"BluetoothAdvertisingData",
|
||||
"BluetoothCharacteristicProperties",
|
||||
"BluetoothDevice",
|
||||
"BluetoothRemoteGATTCharacteristic",
|
||||
"BluetoothRemoteGATTDescriptor",
|
||||
"BluetoothRemoteGATTServer",
|
||||
"BluetoothRemoteGATTService",
|
||||
"BluetoothUUID",
|
||||
"CanvasGradient",
|
||||
"CanvasRenderingContext2D",
|
||||
"CanvasPattern",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue