Callback function when read value.
Callback function when write value finished.
It is uuid as string.
console.log(attr.uuid); // => '4C84'
Wrapper for writeWait with data converting from number. It writes data as 1byte.
It throws an error when failed.
val
Wrapper for readWait with data converting to text. It convert UTF-8 and write binary array to string.
It throws an error when failed.
Read data from descriptor.
The return value appears in the callback function onread. If reading succeeds an Array with data will be returned. It throws an error when failed.
// Javascript Example
await obniz.ble.initWait();
var target = {
uuids: ["fff0"],
};
var peripheral = await obniz.ble.scan.startOneWait(target);
if(peripheral){
await peripheral.connectWait();
console.log("connected");
await obniz.wait(1000);
var dataArray = await peripheral.getService("FF00").getCharacteristic("FF01").readWait();
console.log(dataArray);
}
Wrapper for writeWait with data converting from number. It writes data as 1byte.
It throws an error when failed.
Wrapper for writeWait with data converting from text. It convert string to UTF-8 and write binary array.
It throws an error when failed.
This writes dataArray to descriptor. It throws an error when failed.
// Javascript Example
await obniz.ble.initWait();
var target = {
uuids: ["fff0"],
};
var peripheral = await obniz.ble.scan.startOneWait(target);
if(peripheral){
await peripheral.connectWait();
console.log("connected");
await obniz.wait(1000);
var dataArray = [0x02, 0xFF];
await peripheral.getService("FF00").getCharacteristic("FF01").getDescriptor("2901").writeWait(dataArray);
console.log("write success");
}
Generated using TypeDoc