Ionic unable to write data in device bluetooth serial connection

I am unable to write data in device when i use bluetooth serial plugin i successfully connect and read data from device

when i write data i got response in “NaN”

What’s the data you’re trying to write? It seems that the plugin expects a number and you’re not posting a number.

thanks for reply
i send data "Helloworld"
my code is
alert(+success+’ Success for write’)
}, (failure)=>{
alert(‘failed data writing’)

And where exactly are you seeing a response of Not a Number? Are you really getting a failure or does success gives you that response?

No controls goes to success

response is:
“NaN Success for write”

Okay so you do get in the success handler. So there’s actually no real failure, but you just are getting NaN as response. I’ve never used the plugin, so I wouldn’t now how a normal response should look like. Seems to me that you followed the example in the docs exactly, so that shouldn’t be the issue.

What kind of response are you expecting exactly?

remove ‘+’ before this ‘+success+’

How are you reading data from paired device using bluetooth serial let me know the code .
It is urgent for me.
Thanks in advance

Hai iam also trying to write data,but iam getting success callback and iam getting OK in success calback. Can any one help me

1 Like

Hi, i don’t know if it could helps you but this is how i write on my bluetooth device (some hexadecimal stuff) :

    var dataBuffer = new Buffer("FF01DED100010401010104","hex");
    .then(data => {
        this.bluetoothSerial.write(dataBuffer).then(data => {
            this.output += "\r\nWrite : " + JSON.stringify(data);
        error =>{
            this.output += "\r\nWrite Error : " + JSON.stringify(error);    
    .catch(error => {
      this.output += "\r\nBT disconnected";

can you show me where to get the Buffer class?

Hi i am also using bluetooth serial and i am getting the same error as you can you please let me know what you did?
i am connecting to bluetooth but when i write using
“bluetoothSerial.write(myOBDcommand)…then( (success) => {
alert('Connected: '+myOBDcommand+'Data: '+success );
(error) => {
alert('Reading failed: ’ + error );

i get an alert saying “Connected: ATZ Data OK