I'm using cordova-plugin-ble of evothing and I can't send data to my device( HM10). I´m trying to send to bluetooth device a string ('a') but not working.
I have tried with these options also:
1. 'a' letter en hexa
var data = '61';
2. whit array
var data = new Unit8Array(2);
data[0] = '6';
data[2] = '1';
3. var data = new Unit8Array();
data[0] = 'a';
4. var data = new Unit8Array();
data[0] = '61';
I got it guys!. I was sending the information wrong, I found this function and implemented it in my code:
str2ab: function (str){
var buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
return bufView;
}
}