I'm doing a project and I have to use Bluetooth and apparently, all the incoming data need to be in NSData format.
I'm using the implementation from the question Best way to serialize a NSData into an hexadeximal string but the conversion is incorrect.
The main code snippet is this:
for (int i = 0; i < dataLength; ++i)
[hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];
and the wrong conversion is happening here. I checked it byte by byte.
Some conversion examples:
NSData: <00250045 044f04a4 00000000 00000000 00000000> Hex String: 00240043043d0493000000000000000000000000
NSData: <00240043 043d0493 00000000 00000000 00000000> Hex String: 002300450435049a000000000000000000000000
NSData: <00230045 0435049a 00000000 00000000 00000000> Hex String: 00250045044e04a9000000000000000000000000
NSData: <00250045 044e04a9 00000000 00000000 00000000> Hex String: 00250043043b0497000000000000000000000000
Is there something wrong with the implementation?