writeCharacteristic success callback does not work

Ask, and ye shall receive.
jjww
Posts: 2
Joined: 07:06, 11 Sep 2015

writeCharacteristic success callback does not work

Postby jjww » 07:34, 11 Sep 2015

Code: Select all

app.onSendCommand = function()
{
      
   app.device.writeCharacteristic(
      '6e400002-b5a3-f393-e0a9-e50e24dcca9e',
      new Unit8Array([1,0]),
      function(){console.log('the write is done');},
      function(error){console.log('write error' + error) })
}


Hey all, is there any problem with this code, the function(){console.log('the write is done');} does not work at all, but function(error){console.log('write error' + error) }) can work.

Does the writeCharacteristic() expecting some feedback from ble board?

jjww
Posts: 2
Joined: 07:06, 11 Sep 2015

Re: writeCharacteristic success callback does not work

Postby jjww » 07:38, 11 Sep 2015

I was trying to put enablenotification(), in the success callback function

thanks in advance for any help

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: writeCharacteristic success callback does not work

Postby Fredrik » 11:49, 12 Sep 2015

For notifications, you need to do writeDescriptor(... [1,0] ...), not writeCharacteristic. The descriptor is the one with the 2902 UUID.

Characteristics can be defined as writable with or without notification. If write-notification is on, then writeCharacteristic() will wait for the remote device to respond before calling the win callback, otherwise it will be called as soon as the write packet is sent... or so I think.

If neither win or fail callbacks are called, then that's a bug in the plugin, which may be caused by a bug in the OS's BLE stack. We might want to add a timeout.


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 17 guests