espressif / esp-idf-provisioning-ios

Apache License 2.0
136 stars 63 forks source link

Connection failed #75

Open bpfingsten-crestron opened 12 months ago

bpfingsten-crestron commented 12 months ago

Description

After scanning and locating my ESP32 device I call the connect method, but this fails to connect and when I register a ESPBLEDelegate the periperalFailedToConnect is called with an error description of "Connection timeout. Unable to read BLE characteristic on time." I am able to use just CoreBluetooth code and discover my expected service (UUID: FFFF) and the characteristics of that service (UUID: FF01 and FF02). The device I am using has an LED that turns blue when it has a BLE connection which does happen for a few seconds before turning back to white indicating a waiting/pending status. The logs show that is discovering the service and characteristics...

10:08:36.637 | ESPBleTransport.peripheral(:didDiscoverServices:) (304) : Peripheral did discover services. 10:08:36.758 | ESPBleTransport.peripheral(:didDiscoverCharacteristicsFor:error:) (315) : Peripheral did discover chatacteristics. 10:08:36.762 | ESPBleTransport.peripheral(:didDiscoverDescriptorsFor:error:) (358) : Did sicover descriptor for characterisitic: <CBCharacteristic: 0x282bd02a0, UUID = FF01, properties = 0x8, value = (null), notifying = NO> 10:08:36.877 | ESPBleTransport.peripheral(:didDiscoverDescriptorsFor:error:) (358) : Did sicover descriptor for characterisitic: <CBCharacteristic: 0x282bd0120, UUID = FF02, properties = 0x12, value = (null), notifying = NO> 10:08:36.936 | ESPBleTransport.peripheral(_:didUpdateValueFor:error:) (365) : Did update value for descriptor: <CBDescriptor: 0x2801b05a0, UUID = Client Characteristic Configuration, value = (null)> 10:08:55.793 | ESPBleTransport.bleConnectionTimeout() (176) : Peripheral connection timeout occured.

I don't know how to proceed at this point.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....' ...

Frequency 100%

Expected behavior Should connect to the device

Screenshots

ESP Device Information:

iOS information:

Provisioning information:

Additional context Add any other context about the problem here.

bpfingsten-crestron commented 12 months ago

So after some review of the library code I see that its requiring a descriptor to be returned for each characteristic before it changes state to connected and my FF01 characteristic is not responding with a descriptor. ESPBleTransport::func peripheral(: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error : Error?) is the function involved and does the state change to connected or at least it kills the timer and signals the connected state.

vikas-chandra-mnnit commented 11 months ago

Hi @bpfingsten-crestron, your observation is accurate. The SDK attempts to read the value for each descriptor in a characteristic, after which it propagates the BLE connection successful message. A 20-second timer is established for this process, and if not completed, the connection terminates. Please feel free to reach out if you require additional assistance on this matter.