UnkNown (<fff0>)
这是来源:
- (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 < [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) { NSObject *aValue = [values objectAtIndex: j]; printf(" %s\n",[[aValue description] cStringUsingEnCoding: NSUTF8StringEnCoding]); printf(" is NSData: %d\n",[aValue isKindOfClass: [NSData class]]); } } else { const char *valueString = [[value description] cStringUsingEnCoding: NSUTF8StringEnCoding]; printf(" key: %s,value: %s\n",[keyname cStringUsingEnCoding: NSUTF8StringEnCoding],valueString); } }}
以下是TI CC2250迷你开发套件中密钥卡的输出:
discovered (null) RSSI: -36 key: kCBAdvDataServiceUUIDs UnkNown (<fff0>) is NSData: 0discovered SimpleBLEPeripheral RSSI: -37 key: kCBAdvDataServiceUUIDs UnkNown (<fff0>) is NSData: 0 key: kCBAdvDataLocalname,value: SimpleBLEPeripheral key: kCBAdvDataTxPowerLevel,value: 0解决方法 经过一番挖掘,这是我发现的:
广告数据作为参数传递给centralManager:dIDdiscoverPeripheral:advertisementData:RSSI是一个NSDictionary,似乎总是包含至少一个名为kCBAdvDataServiceUUIDs的密钥.与此键关联的值是CBUUID类型的对象的NSArray.
尽管在许多地方都使用过CBUUID,但在iOS 5文档中没有记录CBUUID,包括我见过的所有用于蓝牙LE的Apple样本.其中的方法是一个称为返回NSData对象的数据.此NSData对象将UUID编码为一系列字节.
因此,要获得并且在这种情况下,查看BLE广告的UUID中的字节,您可以使用如下代码:
- (voID) centralManager: (CBCentralManager *) central dIDdiscoverPeripheral: (CBPeripheral *) aPeripheral advertisementData: (NSDictionary *) advertisementData RSSI: (NSNumber *) RSSI{ printf("discovered %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; printf(" uuID(%d):",j); for (int j = 0; j < 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,valueString); } }}总结
以上是内存溢出为你收集整理的iOS蓝牙LE kCBAdvDataServiceUUID的格式是什么?全部内容,希望文章能够帮你解决iOS蓝牙LE kCBAdvDataServiceUUID的格式是什么?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)