简体   繁体   English

iOS BLE蓝牙8.1和更低版本的BLE订阅的特征通知无响应

[英]iOS BLE Bluetooth 8.1 and lower BLE subscribed characteristic notification no response

Hello I am new to iOS and objective c, this is my first app and I am not sure how to debug this issue. 您好,我是iOS和目标c的新手,这是我的第一个应用程序,我不确定如何调试此问题。

The app send a binary file to STM chips (firmware update over BT). 该应用程序将二进制文件发送到STM芯片(通过BT更新固件)。 When I run my app on ios9 iphone 6 it works well no problems the STM chip is flashed. 当我在ios9 iphone 6上运行我的应用程序时,它运行良好,没有问题,STM芯片已刷新。 When I run the app on iOS8 and lower it doesn't work. 当我在iOS8或更低版本上运行该应用程序时,它不起作用。

The flow of information: Central sends a character in Characteristics X = 0x61 信息流:中央发送特征X = 0x61中的字符

`        _dataToSend1 = [@"a" dataUsingEncoding:NSUTF8StringEncoding];
        [_discoveredPeripheral writeValue:_dataToSend1 forCharacteristic:_WriteChX type:CBCharacteristicWriteWithResponse];
        [_discoveredPeripheral readValueForCharacteristic:_WriteChX];`

Peripheral should respond via Characteristic Y notification: 外围设备应通过特征Y通知进行响应:

          - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error{
NSLog(@"Here");
        if ([characteristic.UUID isEqual:[CBUUIDUUIDWithString:TRANSFER_CHARACTERISTIC_UUIDY]]) {
         NSLog(@"Recived");
          .
          .{some other stuff}
          .
    }

On iOS 9 I get the notification, on older versions the program hangs because there is no response from CHY, if I put a brake point when I write value to CHX in debug console on older iOS it also works?! 在iOS 9上,我会收到通知,在较旧的版本上,程序会挂起,因为CHY没有响应,如果在较旧的iOS上的调试控制台中向CHX写入值时放了刹车点,它还可以吗? I really don't know how to debug this one... 我真的不知道该如何调试...

Edit: So I can read successfully characteristic X that value 61 was sent. 编辑:这样我就可以成功读取已发送值61的特征X。 But it seems like the device didn't receive it. 但似乎该设备未收到它。 if I send the same command 0x61 for the second time only then I get the correct response via notification... So I found a work around but not the cause... 如果我仅第二次发送相同的命令0x61,那么我会通过通知获得正确的响应...所以我找到了解决方法,但没有找到原因...

尝试给写和读之间的时间间隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM