How to take third byte from NSData (OBDII)

Viewed 110

I'm trying to make iOS app which will connect to a car with phone via OBDII (BLE).

I can get a connection with the module and ask about RPM's, and the answers are returned in parts.

First - 010C (Data used to get RPM's)

then - 41 0C 0A 98 \n \n

To read RPM's I need only the third and fourth byte (0A and 98). How can I do it?

Part of code from:

- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F"]])
    {
        //NSLog(@"char %@", characteristic);

        NSData *sensorData = [characteristic value];
        uint8_t *bodyData = (uint16_t *)[sensorData bytes];

        NSLog(@"data bytes %s", bodyData);
    }
}
2 Answers
Related