2

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

l0gg3r
  • 8,864
  • 3
  • 26
  • 46

1 Answers1

1

Try to do something like that:

NSInteger dataInt = atoi((const char*)[data bytes]);
Michał Banasiak
  • 950
  • 6
  • 13