【问题标题】:Core Bluetooth characteristic value write error核心蓝牙特征值写入错误
【发布时间】:2014-10-15 13:55:31
【问题描述】:

我在其他设备上使用核心蓝牙。我尝试发送数据并从外围设备接收相同的数据。 但是,在“writeVal:f​​orCharacteristic:type”中,特征值始终为“null”。下面是我的代码。您能否展示该代码并建议解决此问题。

NSString *test_s = @"test";
self.sendData = [test_s dataUsingEncoding:NSASCIIStringEncoding];
[self.connectedPeripheral writeValue:self.sendData forCharacteristic:self.aChar type:CBCharacteristicWriteWithResponse];
NSLog(@"%@", self.aChar);

我可以在我的外围设备上显示特征的属性。

【问题讨论】:

    标签: ios bluetooth


    【解决方案1】:

    核心蓝牙使用委托方法!将您的“自我”设置为 connectedPeripheral 的代表并实现 peripheral:didUpdateValueForCharacteristic:error: 方法。检查此方法中的特征值(以及错误参数)。

    要有效地更改特征值,您应该这样做:

    [self.connectedPeripheral readValueForCharacteristic:self.aChar];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 2015-01-26
      • 2014-11-25
      • 1970-01-01
      相关资源
      最近更新 更多