BLE paring dialog doesn't shown if deleting paring information in peripheral device

I'm developing iOS application which works as BLE central with custom services and characteristics.

And the peripheral device is developed by a certain vendor.


The system needs pairing between central and peripheral to write characteristic value and now I have a problem regarding the pairing.


If I delete paring information on central(iPhone) side by [Forget This Device] in [Bluetooth] of [Settings], the paring sequence starts again when my application try to write characteristic value after connection and discover service and characteristic. (Paring dialog shows on my application)


The sequence is like below,

  1. Complete connection [_centralMgr centralManager:didConnectPeripheral:]
  2. Discover service [_centralMgr peripheral:didDiscoverServices:]
  3. Discover characteristic [_centralMgr peripheral:didDiscoverCharacteristicsForService:error:]
  4. Try to write characteristic value [_centralMgr peripheral:writeValue:forCharacteristic:tyep:]
  5. At this timing, paring dialog is shown and user tap [Paring] button
  6. Complete writing of characteristic value without error [AppBleCentralMgr peripheral:didWriteValueForCharacteristic:error:]


But if I delete paring information on peripheral device side (by reset the device), the paring sequence doesn't start when my application try to write characteristic value after connection and discover service and characteristic.

Paring dialog never shows and the response for write request doesn't return.

The sequence is like below,

  1. Complete connectiton
    [_centralMgr centralManager:didConnectPeripheral:]
  2. Discover service [_centralMgr peripheral:didDiscoverServices:]
  3. Discover characteristic [_centralMgr peripheral:didDiscoverCharacteristicsForService:error:]
  4. Try to write characteristic value [_centralMgr peripheral:writeValue:forCharacteristic:tyep:]
  5. At this timing, paring dialog is never shown
  6. Response of writing request(in STEP 4.) doesn't return


The vendor of peripheral device is saying that iPhone doesn't request paring even the peripheral device returns write error.


But my application(at least application layer in iOS) doesn't did receive the delegate API of writing error.


Is there anyone who have a same problem ?

I'd appreciate it if you would provide some hint or information.


Add the code of writing characteristic value


- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(nonnull CBService *)service error:(nullable NSError *)error
{
  NSArray* characteristics = service.characteristics;
    for (CBCharacteristic* characteristic in characteristics) {
        if (characteristic.properties & CBCharacteristicPropertyWrite) {
            if ([[characteristic.UUID UUIDString] isEqualToString:MY_CUSTOM_CHARACTERISTIC]) {
                NSData* data = MY_CUSTOM_DATA;
                [peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
                NSLog(@"writeValue:%@", data);
            }
        }
    }
}


In both case(after deleting pairing info. on central/peripheral side), it discovers completely the same characteristic and write same data.

But only in the latter case(deleted on peripheral side), pairing sequence doesn't start.

Answered by m.masa in 212687022

I asked same question to Apple as TSI(Technical Support Incident).


And the answer from Apple engineer is that the behavior is as spec.

For security purpose, iOS do nothing(not show pairing dialog nor return erro to application) in the following condition

- Central(iOS application) : Forget pairing information

- Peripheral(your device) : Keep pairing information


Thank you.

Accepted Answer

I asked same question to Apple as TSI(Technical Support Incident).


And the answer from Apple engineer is that the behavior is as spec.

For security purpose, iOS do nothing(not show pairing dialog nor return erro to application) in the following condition

- Central(iOS application) : Forget pairing information

- Peripheral(your device) : Keep pairing information


Thank you.

BLE paring dialog doesn't shown if deleting paring information in peripheral device
 
 
Q