onConnectedStateChanged() is never called after a BLE pairing request

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 that state == 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?

  • Are you already connected to the phone with the Montana?  nRfConnect can see things that a CIQ app can't.

    Try blescan - I added the Montana as a device.

    BleScan | Garmin Connect IQ

    It can scan and allows you to try to pair.

    With the CIQ Sim, you need nordic WW to test.  See 

    Getting Started with Connect IQ BLE Development - Wiki - Connect IQ - Garmin Forums

    .

  • Hello. Are there any updates to this? We are in the exact same situation and took the exact same steps. I found this post with hopes of finding an answer to the issue. No matter what I try or how long I wait, BleDelegate.onConnectedStateChanged(device, state) never gets called. I have logs in my Android Gatt server app which shows that the device is connected:

    2024-05-02 14:22:24.618 30662-30677 MainActivity com.example.blegattservertest I BluetoothDevice CONNECTED: EB:79:DC:A2:19:87
    2024-05-02 14:22:32.008 30662-30677 BluetoothGattServer com.example.blegattservertest D onConnectionUpdated() - Device=EB79DC_7 interval=36 latency=0 timeout=400 status=0

  • Have you tried the blescan aoo I mentioned in an earlier post?

    Are you trying to connect to the same android device your device is already paired to?  I'm not sure anyone has even gotten that to work, as the two devices are already paired. (same MAC addresses)

  • I found a resolution to this issue. For me, in order to get the Android app to be discovered by the Garmin BLE, I had to pair the watch to the phone using the Garmin Connect app. To get BleDelegate.onConnectedStateChanged(device, state) to be called, you have to go to the watch settings and turn off the phone connection first. Once the watch is no longer paired to the Garmin Connect app, you can then scan for and connect to the phone. I was then able to send data from the phone to the watch.