How to do BLE characteristic.Writevalue () asynchronously ? #7850
-
My set up is Banglejs as BLE host and HM-10 as peripheral. I have included my test javascript for your comments. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
What you're doing looks kind of ok, it's just that you're not waiting for the connection.
|
Beta Was this translation helpful? Give feedback.
It's possible that
Init
is returning before something is properly set up. It should be fine, but it's possible it is the peripheral you are trying to write to that has the problem. You could add:to the end of the
Init
function to add a delay. Or in fact you could manually add a delay aftercharac.writeValue
in the same way.If your
getservice
function works though, I don't see a huge problem in using that. It'd be slightly slower but if as you say you're only occasionally writing then it'd be ok