ble.StartNotification() on Ionic 7 not working

32 views Asked by At

I am using cordova-plugin-ble-central plugin in my project. scan(), connect() and write() functions work. However startNotification() does not work. I tried to connect to the same peripheral (same device ID, same service ID, same characteristic ID) using nRF connect mobile app and it notify works there. In the Ionic App, I am always getting alert('Unexpected Error').

Below is an excerpt from my source code.

...

 _self.ble.scan([], 10).subscribe(
      device => {
        if (device.name == "xxxxxxxx") {
          
          _self.ble.connect(device.id).subscribe(peripheralData => {

            _self.ble.startNotification(device.id, "xxxxxx-11ee-b962-0242ac120002", "xxxxxx-11ee-b962-0242ac120002").subscribe(
              data => this.onButtonStateChange(data),
              () => alert('Unexpected Error')
            )

...

Also, please feel free to suggest other BLE plugins for Ionic 7. I don't have to stick to cordova-plugin-ble-central.

0

There are 0 answers