don/ionic-ble-examples

couldn't write data after start notification

Closed this issue · 2 comments

hi don, recently i had working on a BLE light APP, i found i can't start Notificaiton

this.ble.startNotification(this.peripheral.id, TELINK_SERVICE, TELINK_CHARACTERISTIC_NOTIFY).subscribe(
  buffer => {
     var data = new Uint8Array(buffer);
     console.log('Received Notification:   = ' + data);

    let iv = this.getSecIVS();
    this.copyarray(data, 0, iv, 3, 5);
    let ret = this.mydecryptCmd(this.sessionkey, iv, data);

    this.setStatus('Received Notification:   = ' + ret)
  }, () => this.showAlert('Unexpected Error', 'enable notify failed')
);
don commented

The characteristic must have the notify or indicate property for ble.startNotification to work. The peripheral controls how the characteristic are accessed. Look at the JSON retuned when you connect to see details about the characteristic permissions.

thx, the problem caused by our bluetooth device!