Ios 如何从核心蓝牙设备读取信息

Ios 如何从核心蓝牙设备读取信息,ios,ipad,core-bluetooth,Ios,Ipad,Core Bluetooth,我正在使用iOS核心蓝牙应用程序,我能够使用iPad3连接BLE设备。我可以访问blockdidiscoverservices,但无法从此处继续 我的问题是, 如何从蓝牙设备读取特征 如何读取蓝牙设备的其他信息 在这方面帮助我或提供任何建议 谢谢威廉森的回复 我从提到的区块中得到了以下信息: [0] - Service : <CBConcreteService: 0x1769a0> UUID: Generic Attribute Profile [1] - Service : <

我正在使用iOS核心蓝牙应用程序,我能够使用iPad3连接BLE设备。我可以访问block
didiscoverservices
,但无法从此处继续

我的问题是,

  • 如何从蓝牙设备读取特征
  • 如何读取蓝牙设备的其他信息
  • 在这方面帮助我或提供任何建议

    谢谢威廉森的回复

    我从提到的区块中得到了以下信息:

    [0] - Service : <CBConcreteService: 0x1769a0> UUID: Generic Attribute Profile
    [1] - Service : <CBConcreteService: 0x174470> UUID: Generic Access Profile
    [2] - Service : <CBConcreteService: 0x1744e0> UUID: Unknown (<00005301 00000041 4c505749 53450000>)
    
    Characteristic
    
    [0] - Characteristic : <CBConcreteCharacteristic: 0x15d410> UUID: Service Changed
    
    [0] - Characteristic : <CBConcreteCharacteristic: 0x1805b0> UUID: Device Name
    [1] - Characteristic : <CBConcreteCharacteristic: 0x1806a0> UUID: Appearence
    
    [0] - Characteristic : <CBConcreteCharacteristic: 0x183810> UUID: Unknown (<00004301 00000041 4c505749 53450000>)
    [1] - Characteristic : <CBConcreteCharacteristic: 0x1838a0> UUID: Unknown (<00004302 00000041 4c505749 53450000>)
    
    [0]-服务:UUID:通用属性配置文件
    [1] -服务:UUID:通用访问配置文件
    [2] -服务:UUID:未知()
    特征
    [0]-特征:UUID:服务已更改
    [0]-特征:UUID:设备名称
    [1] -特征:UUID:外观
    [0]-特征:UUID:未知()
    [1] -特征:UUID:未知()
    

    现在,如何在didUpdateValueForCharacteristic块中从该特性中获得精确值?

    仔细阅读该框架。如果您已经做到了这一点,那么在查找“discoverCharacteristics”和外围代理回调“didiscovercharacteristics”时应该不会有任何问题。您需要知道服务的UUID以及要发现并将其应用于这些方法的特性

    然后可以使用“readValueForCharacteristic”和委托回调“didUpdateValueForCharacteristic”进行读取

    这是从我的手机发送的,所以我可能会在电脑前编辑一下。希望能有帮助

    新问题:

    [connectedPeripheral readValueForCharacteristic:wantedCharacteristic] 
    
    在外围代表处

    - (void) peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error{
    
    NSLog(@"Characteristic value : %@ with ID %@", characteristic.value, characteristic.UUID);
    [delegate characteristicValueRead:characteristic.value];
    }
    

    适用于我

    您可以获得特征值

     NSString *value = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
    
    NSLog(@"Value %@",value);
    
    只用


    我得到了characteristic.value=。我怎样才能从中得到准确的值?这取决于你打印它的方式。尝试
    NSLog(@“value=%@”,characteristic.value)    [LGUtils readDataFromCharactUUID:@"f045"
                              seriveUUID:@"5ec0"
                              peripheral:peripheral
                              completion:^(NSData *data, NSError *error) {
                                  NSLog(@"Data : %s Error : %@", (char *)[data bytes], error);
                              }];