orbital-systems / react-native-esp-idf-provisioning

ESP IDF provisioning and custom data library for react-native
MIT License
24 stars 5 forks source link

Connect method doesn't resolve (BLE) #56

Open mtoninelli opened 3 months ago

mtoninelli commented 3 months ago

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

mateogianolio commented 3 months ago

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

tygoegmond commented 2 months ago

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

I'm using the package using Expo on iOS

tygoegmond commented 2 months ago

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()
            }
        }
    }
mateogianolio commented 3 weeks ago

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)

nat-jones commented 3 weeks ago

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 commented 2 weeks ago

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

mateogianolio commented 1 week ago

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.