don / ionic-ble-examples

Ionic Framework Bluetooth Low Energy Examples
102 stars 70 forks source link

couldn't write data after start notification #3

Closed NanYoMy closed 6 years ago

NanYoMy commented 6 years ago

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 6 years ago

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.

NanYoMy commented 6 years ago

thx, the problem caused by our bluetooth device!