Hello everyone.
I am developing an application that must establish a connection with an Android application that acts as a BLE peripheral device and transfer data to it.
I hadn't written apps for Garmin devices before. I studied the documentation and came to the conclusion that in order to transfer data from the device (I have a Garmin Montana 700i) to the Android application via BLE, I need to:
- The Android application must start BLE Advertising with the ability to connect.
- On the garmin app register a profile with UUIDs of services and characteristics that will be used using
BluetoothLowEnergy.registerProfile(profile).
- Start scanning using
BluetoothLowEnergy.setScanState(Ble.SCAN_STATE_SCANNING).
- Use
BluetoothLowEnergy.BleDelegate.onScanResults(scanState)
to receive scan results. - Find my device in the scan results by comparing deviceName or service UUID.
- If my device appears in the scan results, then make a request to create a pair using
BluetoothLowEnergy.pairDevice(scanResult).
- Wait for
BleDelegate.onConnectedStateChanged(device, state)
to be called and check thatstate == Ble.CONNECTION_STATE_CONNECTED.
- After that, I could use the device object to get its service and get the characteristic from it and make a request to write the value of the characteristic using
requestWrite(value).
I'm stuck at the pairing stage. In my case, BleDelegate.onConnectedStateChanged(device, state) is never called and I can't figure out what I'm doing wrong.
For testing on Android devices, I use BLE Advertiser created through the BLE Scanner application. I can connect and change its characteristics from another Android device using any BLE app (eg nRF Connect), but my Garmin app won't connect to it.
This BLE Advertiser from another Android device in nRF Connect looks like this:
I posted on GitHub the simple code of the garmin application that I use to test the work with BLE. It successfully scans and finds my device and requests pairing, but for some reason the connection is not established. Logs look like this:
BleTestApp.onStart
BleTestController.onSelect. Start scanning
BleDelegate.onScanResults
BleDelegate.onScanResults
BleDelegate.onScanResults. Device with the required UUID found
BleDelegate.onScanResults. Request for pairing
Maybe someone has encountered a similar problem or can see what I'm doing wrong?