1

After scanning for the BLE device, I call the below method:

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI 

and receive the following advertisement data as such:

{ kCBAdvDataManufacturerData = <ffff0215 cf6d4a0f .....  adf2f491 ... ... > }

How can I decode the data and access its information?

Johnny Rockex
  • 4,136
  • 3
  • 35
  • 55
Moxarth
  • 303
  • 4
  • 13
  • `NSData *data = advertisementData[kCBAdvDataManufacturerData]`. Now, what do you want to fetch/decode on it? What information do you want? – Larme Aug 24 '17 at 07:28
  • contains some of the data like . so i want to fetch uuid: major: minor: meaured power at 1 meter(Tx power) : .... so for that we have to decode that into some format , and that i dont know how . – Moxarth Aug 24 '17 at 07:32
  • You can use `subdataWithRange:` to isolate the wanted data. For the rest, it's up to the documentation on how it's translated into NSData for it (https://stackoverflow.com/questions/6123029/how-to-convert-nsdata-variable-into-nsinteger-variable-in-iphone ? More complex, etc.) – Larme Aug 24 '17 at 07:34
  • Clean up the English + formatting – Johnny Rockex Aug 24 '17 at 08:37
  • @Larme , it did not help me . – Moxarth Aug 24 '17 at 08:55
  • @Moxarth: Give the whole `kCBAdvDataManufacturerData`. Give what are supposed to be the values, explain by separating the values of the ManufacturerData and what they should hold as Int. My suggestion should work. – Larme Aug 24 '17 at 08:58
  • whole data is ` kCBAdvDataManufacturerData = ; ` . i guess this value is in Hex code. so we have to decode it in order to get the major , minor ,Tx power from it . so i don't know how to decode it or convert it . – Moxarth Aug 24 '17 at 09:10
  • In it, where is the major or minor? Could you isolate it? Do you have a doc? – Larme Aug 24 '17 at 09:13
  • no . they just mentioned these , – Moxarth Aug 24 '17 at 09:16
  • And what are the value of the major or the minor in your case? If it's major = 44864 and minor = 36219, I got it, but if not... – Larme Aug 24 '17 at 09:27
  • You may want the reverse of https://stackoverflow.com/questions/19410398/turn-macbook-into-ibeacon/19741615#19741615 + https://stackoverflow.com/questions/18906988/what-is-the-ibeacon-bluetooth-profile/19026387 – Larme Aug 24 '17 at 09:32

2 Answers2

1

It seems that you are expecting this advertising packet to be decodable as iBeacon, but it is not. The full bytes listed in comments are:

ff ff 02 15 e8 4a 40 af 7b 8d e8 8d 4a 7b 40 af af e8 4a 40 40 af 7b 8d c3

The 02 15 is the company code of Apple, but the next two bytes e8 4a are not consistent with the pattern you will see for iBeacon. There is no reason to think, therefore, that beacon identifiers are encoded in this packet.

What do the data mean? It's impossible to say without more information about what software or hardware is transmitting this packet and what its intended purpose is. All we can tell is that it is a manufacturer advertisement (type ff) and is reporting itself as an Apple device.

If you want to figure out the meaning of the packet, you need to determine what app or hardware manufacturer is emitting it and seek documentation from that entity.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • yes . they informed me like this , . so i have to fetch the major minor and Tx power from this, in order to calculate the distance between the BLE device and phone . so i am confused , how to separate these data and in which format to convert ? – Moxarth Aug 24 '17 at 11:10
  • I don't think what you describe makes sense. In the above example, the "type (1 byte)" that follows the 02 15 company identifier would be 0xe8 and the "data length (1 byte)" that comes after that would be 0x4a. This cannot be right. 0x48 is 72 decimal. There are not 72 bytes in the packet. Either this description of the advertisement format is wrong, or that packet byte sequence is not for a packet matching that description. – davidgyoung Aug 25 '17 at 15:15
  • no . this data is correct 1 . in android we are getting the data exactly what we want . after 4 bytes , 16 bytes are MAC address of the device , that i want to find out from it , or using some method we have to convert it to access its data . after that 2 bytes are major and after that 2 bytes are minor . i want to find those out too . in android we are converting this HEX data string into decimal and that way we have got it but i dont know how get in ios .\ – Moxarth Aug 26 '17 at 09:14
0

my small code snippet:

-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
    // NSLog(@"%@", central);
    NSLog(@"%@", peripheral);
    //NSLog(@"%@", advertisementData);
    NSLog(@"%@", RSSI);

    // more details:
    NSString* name = [peripheral name]; // name in NULL in iOS 6
    NSLog(@"%@", name);

    for (NSString * key in advertisementData){
        NSLog(@"%@", advertisementData[key]);
    }


}
ingconti
  • 10,876
  • 3
  • 61
  • 48
  • 1
    yes . through this only i got the inside adv data kCBAdvDataManufacturerData . now my issue is , how to decode that data to access those information . – Moxarth Aug 24 '17 at 08:42