Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
999 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 122 additions & 0 deletions
122
components/script/dom/bluetoothcharacteristicproperties.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
Oops, something went wrong.