BLE Write issue


#1

I am trying to write in to BLE Characteristics.

Below is my example code

var buffer  = this.stringToBytes("Test");

BLE.write(deviceID,serviceID,characteristicID,buffer).then(
      result=> {
      }).catch(error=> {
          alert(JSON.stringify(error));
      });

I am not successful with this code. Can any one please lead me to any example with BLE.write syntax. ?


#2

Are you using https://ionicframework.com/docs/native/ble/?
Does other functionality of it work?
Do you get any errors or does just nothing happen?


#3

Yes I am using the same Frame work.
The read program is working fine . I am able to read the characteristic.
I think there is some syntax issues with the BLE.write value parameter.
I didn’t get any errors in the BLE.write call.


#4

I don’t know anything about this plugin, but took a look at the docs:
https://ionicframework.com/docs/native/ble/#write

value | ArrayBuffer | Data to write to the characteristic, as an ArrayBuffer.

Is your buffer an ArrayBuffer?


#5

Thanks for the quick reply sujan.

Yes It’s Array buffer only. Its the same function from the docs page. I have to

Is there any other library for communicating with BLE devices available with Ionic ?


#6

Maybe try posting an issue on the Cordova plugin Github: https://github.com/don/cordova-plugin-ble-central

This exists https://ionicframework.com/docs/native/bluetooth-serial/ but I am not sure if this does the same.