BLE Peripheral - Descriptor

new descriptor(json)

This creates descriptor.


await obniz.ble.initWait(); 
var descriptor = new obniz.ble.characteristic({
                      "uuid" : "2901",   //Characteristic User Description
                      "text" : "hello world characteristic",
                  });

var characteristic = new obniz.ble.characteristic({
                    "uuid" : "FFF1",
                    "text" : "Hi",
                    "descriptors" : [ descriptor ]
                  });

var service = new obniz.ble.service({
                  "uuid" : "fff0",
                  "characteristics" : [ characteristic ]
});
obniz.ble.peripheral.addService(service); 

descriptor.writeWait(data)

This writes data on descriptor.
It throws an error when failed.

await descriptor.writeWait([0xf0,0x27]);
console.log("write success");

[await] descriptor.readWait()

This reads data on descriptor.
It returns data array when it succeeds.
It throws an error when failed.

let data =  await descriptor.readWait()
console.log("data: " , data );

descriptor.onwritefromremote

This is a callback function used when the descriptor gets changed by an external device.


descriptor.onwritefromremote = function(val){
    console.log("remote address :",val.address);
    console.log("remote data :",val.data);
}

descriptor.onreadfromremote

This is a callback function used when the descriptor is read by an external device.


descriptor.onreadfromremote = function(val){
    console.log("remote address :",val.address);    
}

You will Get in Few Days

Circuit for Starter “obniz Board” is available on Amazon and other online stores.
You can get it at below

Our products and resellers

Forum

Visit our developer’s forum to discuss and discover technologies.

Forum

Contact

Feel free to contact out support and technical team.

Contact us