Original URL: http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/73443.aspx
Nsarray *keys = [Advertisementdata AllKeys];
NSData *dataamb, *dataobj;
for (int i = 0; i < [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 < [values count]; ++j) {
if ([[Values Objectatindex:j] Iskindofclass: [Cbuuid class]]) {
Cbuuid *uuid = [values objectatindex:j];
NSData *data = Uuid.data;
if (j = = 0) {
Dataobj = Uuid.data;
} else {
Dataamb = Uuid.data;
}
printf ("uuid (%d):", j);
for (int j = 0; j < data.length; ++j)
printf ("%02x", ((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);
}
}
Thanks, but the result is
Key:kcbadvdataisconnectable, Value:1
Key:kcbadvdatalocalname, Value:simplebleperipheral
Key:kcbadvdataserviceuuids
UUID (0): FF F0
Key:kcbadvdatatxpowerlevel, value:0
I want to get the broadcast data or not read ....
For iOS devices, I get broadcast data through Kcbadvdataserviceuuids.
Li Zongwu:
I also feel that the broadcast data should be in the advertisementdata, can be inside is no kcbadvdataserviceuuids this key value. Tangled.... I don't know if it's CC2540, it's not the right program.
-(void) Centralmanagerdidupdatestate: (cbcentralmanager *) Central
{....} How does this define the AH ...
Using the code I provided earlier, I can get kcbadvdataserviceuuids This key value, which corresponds to the so-called data in the broadcast.
"Go" IOS how to get peripheral broadcast data Advdata