Frage

I am working with iOS central to communicate with BLE peripheral device.

Using LGBluetooth framework https://github.com/DavidSahakyan/LGBluetooth

The method gets

        [LGUtils readDataFromCharactUUID:aCharactId
                              seriveUUID:aServiceId
                              peripheral:peripheral
                              completion:^(NSData *data, NSError *error) {
                                  NSLog(@"Data : %s Error : %@", (char *)[data bytes], error);
                              }];

It outputs "1234567890"

I need to convert (char *) [data bytes] to NSInteger. When I get it

         NSInteger dataInt = [data bytes];

I get 2013527536, but the value is 1234567890 on peripheral side

War es hilfreich?

Lösung

Try to do something like that:

NSInteger dataInt = atoi((const char*)[data bytes]);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top