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 ''; } //var nn = Base64.decode(value).charCodeAt(0); var len = value.length; var bytes = new Uint8Array(len); var ff: number = +value; const vvv = BitConverter.GetBytes(ff).toString(); for (var i = 0; i < len; i++) { bytes[i] = Base64.decode(vvv).charCodeAt(i); } return value;};
This is the base64 library I'm using. There are a few things I don't understand here, I'm pretty new to this. I saw that I could only decode 8 bit data and I was a bit confused.
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),];
this is so much important for me. Thank you.