My application is receiving a remote binary file via BLE and save it. I use "AsciiConversion" extension block to encode received byte then to "file" extension block to write to a file, when i check the result of the file, only the value between 0x00 ~ 0x7F can be saved correctly, the value greater then 0x80 will be replace to 2 bytes value. As below,
the original contents are
0x99 0xcc 0xaa 0x55 0x55 0x53 0x45 0x52 ....
send via BLE, the AI2 app received the data and save to a file becomes
0xc2 0x99 0xc3 0x8c 0xc2 0xaa 0x55 0x55 0x53 0x45 0x52 ...
If your application receives bytes and wants to store them, why do you need to convert those bytes? What format are you converting the bytes to? Why don't you just write them down directly?
The problem is an extension that converts something but we don't know what and why.
Try removing the extension block and writing the bytes to the file directly.
This is part from protocol, i need to parse the data contents and compare the checksum, after all pass, point the start to the assigned position, and find the data length in the protocol, pick all the data in the protocol then write to a file. These are data from an IOT device.
The same blocks, but not use ASCiiconversion, the data save to the file will show as the following (all in ASCII text form)
153204170858583698232777968693222.....
it means 153 204 170 85 85 83 69 82 ...
the same meanings as original file
0x99 0xcc 0xaa 0x55 0x55 0x53 0x45 0x52 ....
but all in ASCII text, that is why i call ASCiiconversion. It seems either asciiconversion block can not conver the value greater than 0x7f, or FILE block can not save the value greater than 0x7f. Is there any other way to solve it?
In fact, the file component writes text. So you're on the right track if you want to convert the bytes to ascii characters and then save them. The problem here is the file component that use utf8. Pure ascii ends at byte 127, later different encodings use different techniques. UTF8 encodes with two bytes.
The question is what do you want to do next with the saved file? Will you export it further or process it only in your app?
The solution would be another extension that can save a text file in ANSI encoding.
Putaning whether this bin will be used only by your app or for general use. Because if only through your app, the format can be any. If it's for the general then you'll have to do something with the data record.