react-native-esp-idf-provisioning icon indicating copy to clipboard operation
react-native-esp-idf-provisioning copied to clipboard

Connect method doesn't resolve (BLE)

Open mtoninelli opened this issue 1 year ago • 7 comments

Hi Mateo,

I'm so happy to have found this package. It's exactly what I'm looking for. Thanks for sharing it!

I've installed and run succesfully the example. I'm unsing BLE.

The bluetooth scan works fine and it lists the device.

I got stuck on the follow step when I try to connect it (without any security).

This connect method never resolves. https://github.com/orbital-systems/react-native-esp-idf-provisioning/blob/f8ff66fcfc207d1829f5dcc66c7b5e03e49d5c21/src/index.tsx#L63

Any ideas?

Thank you very much

mtoninelli avatar May 28 '24 15:05 mtoninelli

Thank you for your kind words! Are you using iOS or android? Do you have access to logs on the esp device?

mateogianolio avatar Jun 05 '24 13:06 mateogianolio

I have the same issue @mateogianolio, what logs do you need?

I'm using the package using Expo on iOS

tygoegmond avatar Jul 05 '24 11:07 tygoegmond

Here are the logs from the ESPLog:

15:46:11.943 | ESPDevice.connect(delegate:completionHandler:) (165) : Connecting ESPDevice...
15:46:11.944 | ESPDevice.connect(delegate:completionHandler:) (169) : Start connecting ble device.
15:46:11.944 | ESPBleTransport.connect(peripheral:withOptions:delegate:) (159) : Connecting peripheral device...
XPC connection invalid
15:46:11.945 | ESPBleTransport.connect(peripheral:withOptions:delegate:) (169) : Initiating timeout for connection completion.
15:46:12.303 | ESPBleTransport.centralManager(_:didConnect:) (286) : Connected to peripheral. Discover services.
15:46:12.718 | ESPBleTransport.peripheral(_:didDiscoverServices:) (305) : Peripheral did discover services.
15:46:12.838 | ESPBleTransport.peripheral(_:didDiscoverCharacteristicsFor:error:) (316) : Peripheral did discover chatacteristics.
15:46:12.840 | ESPBleTransport.peripheral(_:didDiscoverDescriptorsFor:error:) (359) : Did discover descriptor for characterisitic: <CBCharacteristic: 0x300f8ebe0, UUID = FF01, properties = 0xC, value = (null), notifying = NO>
15:46:12.897 | ESPBleTransport.peripheral(_:didDiscoverDescriptorsFor:error:) (359) : Did discover descriptor for characterisitic: <CBCharacteristic: 0x300f8e4c0, UUID = FF02, properties = 0x12, value = (null), notifying = NO>
15:46:12.957 | ESPBleTransport.peripheral(_:didDiscoverDescriptorsFor:error:) (359) : Did discover descriptor for characterisitic: <CBCharacteristic: 0x300f8e820, UUID = FF11, properties = 0x4, value = (null), notifying = NO>
15:46:13.019 | ESPBleTransport.peripheral(_:didUpdateValueFor:error:) (366) : Did update value for descriptor: <CBDescriptor: 0x3024e9da0, UUID = Client Characteristic Configuration, value = (null)>

It seems to get stuck on the following function:

func peripheral(_: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error _: Error?) {
        ESPLog.log("Did update value for descriptor: \(descriptor)")
        utility.processDescriptor(descriptor: descriptor)
        readCounter -= 1
        if readCounter < 1 {
            if utility.peripheralConfigured {
                bleConnectTimer.invalidate()
                bleStatusDelegate?.peripheralConnected()
            }
        }
    }

tygoegmond avatar Jul 12 '24 13:07 tygoegmond

Does it happen all the time or just after you've already connected once? I've had some issues when connecting to a single device several times (without disconnecting in-between)

mateogianolio avatar Aug 19 '24 11:08 mateogianolio

Hey @mateogianolio! Same problem here. It fails to resolve or reject every time, regardless of if I have already connected to the device. I am running on IOS using Expo 51.

nat-jones avatar Aug 23 '24 16:08 nat-jones

@tygoegmond Did you end up finding a fix/workaround for this?

nat-jones avatar Aug 26 '24 19:08 nat-jones

#73 was fixed in 0.4.1 which might — or might not, I'm not familiar with expo — affect expo installations. Also esp-idf-provisioning-ios version in 0.4.0. If possible, please try the latest version.

mateogianolio avatar Sep 03 '24 14:09 mateogianolio

Latest version is compatible with react-native 0.76.2 and new architecture, should hopefully work with expo as well.

mateogianolio avatar Nov 22 '24 08:11 mateogianolio