Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some digging around, here's what I discovered:</p> <p>The advertisement data passed as a parameter to the centralManager:didDiscoverPeripheral:advertisementData:RSSI is an NSDictionary that always seems to contain at least one key called kCBAdvDataServiceUUIDs. The value associated with this key is an NSArray of objects of type CBUUID.</p> <p>CBUUID is not documented in the iOS 5 documentation, despite the fact that it is used in many places, including every Apple sample for Bluetooth LE I've seen. Among it's methods is one called <code>data</code> that returns an NSData object. This NSData object has the UUID encoded as a series of bytes.</p> <p>So, to get and, in this case, view the bytes in the UUIDs of a BLE advertisement, you can use code such as the following:</p> <pre><code>- (void) centralManager: (CBCentralManager *) central didDiscoverPeripheral: (CBPeripheral *) aPeripheral advertisementData: (NSDictionary *) advertisementData RSSI: (NSNumber *) RSSI { printf("Discovered %s\n", [[aPeripheral name] cStringUsingEncoding: NSUTF8StringEncoding]); // TODO: Remove printfs printf(" RSSI: %s\n", [[RSSI stringValue] cStringUsingEncoding: NSUTF8StringEncoding]); NSArray *keys = [advertisementData allKeys]; for (int i = 0; i &lt; [keys count]; ++i) { id key = [keys objectAtIndex: i]; NSString *keyName = (NSString *) key; NSObject *value = [advertisementData objectForKey: key]; if ([value isKindOfClass: [NSArray class]]) { printf(" key: %s\n", [keyName cStringUsingEncoding: NSUTF8StringEncoding]); NSArray *values = (NSArray *) value; for (int j = 0; j &lt; [values count]; ++j) { if ([[values objectAtIndex: j] isKindOfClass: [CBUUID class]]) { CBUUID *uuid = [values objectAtIndex: j]; NSData *data = uuid.data; printf(" uuid(%d):", j); for (int j = 0; j &lt; data.length; ++j) printf(" %2X", ((UInt8 *) data.bytes)[j]); printf("\n"); } else { const char *valueString = [[value description] cStringUsingEncoding: NSUTF8StringEncoding]; printf(" value(%d): %s\n", j, valueString); } } } else { const char *valueString = [[value description] cStringUsingEncoding: NSUTF8StringEncoding]; printf(" key: %s, value: %s\n", [keyName cStringUsingEncoding: NSUTF8StringEncoding], valueString); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload