It's Long to write because the many times use the XOR on the decoding. I give only the fragment of code.
The only interest me. If I calculate supose: Byte1=0x56 and value from loop FOR NEXT I will be have correct Value. Example
dim byte1 as byte=0x56
dim result(255) as byte
dim data as int=60
dim key as byte=0xB2
dim Mytrue_data(255) as byte
For i=0 to data
result(i)= bit.xor(byte1,(i))
result(i)=bit.xor(result(i),key)
mytrue_data(i)=result(i)
next
The calculate value will be the same as calculate valu on MCU ??. I think the function Bit.XOR is not he same work like MCU XOR. Because I rewrite the code and the value never pass to nothing. I think that can be, because in the Tutorial oF B4A the write. bit.xor(value as int,value as int) .In the MCU the XOR bytes. I do not shure but this. Sorry I not use never B4A I only write some code on MCU and I encountered a problem. When I will be have some time I try write the same code and result from MCU and from B4Android.