简体   繁体   中英

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.

The app send a binary file to STM chips (firmware update over BT). When I run my app on ios9 iphone 6 it works well no problems the STM chip is flashed. When I run the app on iOS8 and lower it doesn't work.

The flow of information: Central sends a character in Characteristics X = 0x61

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

Peripheral should respond via Characteristic Y notification:

          - (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?! I really don't know how to debug this one...

Edit: So I can read successfully characteristic X that value 61 was sent. 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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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