I want to see distance data with timer with more than 255 value from microcontroller with react native ble plx. Should I edit the base64 library or my code? I tried some options but it didn't work. I can see the value as a number right now, but I can't go over the 255 limit. is there a way to do this? Thanks
const decodeBleString = (value: string | undefined | null ) : string => { if (!value){ return ''; } return Base64.decode(value).charCodeAt(0);};
This is the base64 library I'm using. There are a few things I don't understand here, I'm pretty new to this. when i execute this code, it only takes the 8 bit part. that is, if I send the number 1278, I see a number 206 on the screen. If I send the number 1278 as a byte array, I see byte 1 in charCodeAt(0) and byte 2 in charCodeAt(1). Is there any way I can combine these and get the number 1278? Is there anything in the library that needs to be changed or is there a different library you can suggest?
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g; var cb_btou = function (cccc) { switch (cccc.length) { case 4: var cp = ((7 & cccc.charCodeAt(0)) << 18) | ((63 & cccc.charCodeAt(1)) << 12) | ((63 & cccc.charCodeAt(2)) << 6) | (63 & cccc.charCodeAt(3)), offset = cp - 65536; return ( fromCharCode((offset >>> 10) + 55296) + fromCharCode((offset & 1023) + 56320) ); case 3: return fromCharCode( ((15 & cccc.charCodeAt(0)) << 12) | ((63 & cccc.charCodeAt(1)) << 6) | (63 & cccc.charCodeAt(2)), ); default: return fromCharCode( ((31 & cccc.charCodeAt(0 )) << 6) | (63 & cccc.charCodeAt(1)), ); } }; var btou = function (b) { return b.replace(re_btou, cb_btou); }; var cb_decode = function (cccc) { var len = cccc.length, padlen = len % 4, n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0) | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0) | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0) | (len > 3 ? b64tab[cccc.charAt(3)] : 0), chars = [ fromCharCode(n >>> 16), fromCharCode((n >>> 8) & 255), fromCharCode(n & 255),];