Peripheral: Update values

You can rewrite the characteristic values registered, regardless of whether the other party is connected or not.

Rewrite

Some other devices may rewrite the characteristic values via BLE, but you can also change it.
You can update the value using characteristic.writeWait(). In following example, the characteristic value is [1,2,3] at first, but it is immediately replaced by [0xFF]. You can read 0xFF from other devices via BLE.

// Javascript Full Example

var obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async function () {
  await obniz.ble.initWait();

  obniz.ble.peripheral.onconnectionupdates = function(data){
    console.log("remote device ", data.address, data.status)
  };

  var service = new obniz.ble.service({ uuid : "1234" });
  var characteristic = new obniz.ble.characteristic({ uuid : "7777", data: [1, 2, 3]});
  service.addCharacteristic(characteristic);
  obniz.ble.peripheral.addService(service);

  obniz.ble.advertisement.setAdvData(service.advData);
  obniz.ble.advertisement.setScanRespData({
    localName : "obniz BLE",
  });
  obniz.ble.advertisement.start();

  await characteristic.writeWait([0xFF]) // over write
}