Search code examples
javahexbytechecksum7-bit

android generating 7 bit checksum for passing data to a bluetooth module


I'm creating an application to send data to a bluetooth module.

I'm having a tough time following the provided documentation. Can anyone help me understand how to create the checksum as mentioned (Byte No. 3)

So far, I have been able to make a sum of address 1 & 2 by converting them into integers and adding them up, the rest is beyond me... how do I take a bit-inverse and apply a 7-bit checksum and turn it into a "7-bit data with 0x7F" ??

The module communication document


Solution

  • The 0x7F means 0b01111111 in binary and represents a bit mask. You have to do a bitwise and with your checksum like that

    result = checksum & 0x7F
    

    EDIT

    As long i understand, it schould be

    checksum = ~( byte1 + byte2 )