"Go" IOS how to get peripheral broadcast data Advdata

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.