Unexpected BLE connection problem

I'm working on an app that uses data from a remote pressure sensor and I believe I got stuck because of a rather unexpected problem. My Garmin Edge 1030 device is not being able to discover the sensor during BLE scan.

As a background, I want to state that I've successfully used connections to several other BLE enabled external devices in other CIQ apps on the same Edge 1030 device. So it is not that I'm missing out how to do it in principle.

The problem now is that the list of results that are returned to the BleDelegate after initiating a BLE scan on the Edge 1030 device just don't contain the sensor I'm playing with. 
All sorts of other devices can be seen there, but never this one.
Without discovering it via the built-in scan I cannot connect to it because the "pairDevice()" function accepts as a parameter a ScanResult object and a ScanResult object cannot be instantiated manually. It has to be created by the BLE scan..
 
Can anyone come up with a suggestion about why the sensor is not "visible" for the BLE scan that the Edge 1030  performs, while in the same time it is readily visible when I do a scan on my Android phone? 
Thank you in advance!
Nikolay
  • Not all sensors advertise in a way that are usable by CIQ.  That's what it sounds like here..  There's also a max of 3 devices CIQ can use at once - not each app, but in total.

    Here's an app I wrote which allows you to see what devices CIQ can see in a scan. (BleScan)

    https://apps-developer.garmin.com/apps/9bcc8b66-8385-4afb-b93e-f69e01422284

  • Thank you Jim

    That was actually helpful because I found out the following.

    Whereas in my scan results list I show only devices with non null names, you seem to present an unfiltered list.

    Then among the large number of devices there that have name=null I picked the one with the strongest signal and it was actually my sensor sitting on the table next to the Edge1030. Upon connection there is an LED on it that is being lit.

    However the sensor does advertise a name that is readily visible when running a scan on a phone for example. But for some reason the CIQ scan is unable to read this name.

    What would be your suggestion for the best way to recognize my device when iterating the the scan results when there's no name presented?

    What comes to mind is to try the."hasAddress()" function to search for the sensor's unique address that I can check beforehand.

    Best regards,

    Nick

  • I never look for a name.  On some devices with CIQ it's null and on others, it's an empty string.  CIQ only sees the first 30 or so bytes of raw data (you can see that by doing a "select" with BleScan).

    The way I look for a specific device is to compare the UUID seen.  You can see how to look for this in the ble delegate's "contains" function in the NordicThingy52 sample in the SDK.

    For example, in the sample, it's looking for a UUID of  

    BluetoothLowEnergy.longToUuid(0xEF6801009B354933L, 0x9B1052FFA9740042L);

    BleScan actually started with that sample, but the difference is I cache all UUIDS found when scanning.

  • Thank you Jim. Understood. I'll have this approach in mind.

    However it will not work for this particular case as I have two identical sensors (left and right) and they advertise the same service UUID.

    And I have to know which one is which,

    They have different names, but since CIQ is not able to read the names I'll have to resolve the situation by checking their unique Bluetooth addresses

  • CIQ can't see the BLE Mac addresses, you can configure them and then compare.

    Is there anything in one of the characteristics which you can check?

  • Checking for a match with already known MAC address worked fine for this rask.

    The two sensors are otherwise identical. They differ only by their addresses and configured names. 

  • Sorry for hijacking, but thanks Jim, the UUID-matching advice is useful. I’m doing that now and can reliably find the device even when the name is null.

    I’m now stuck at the next stage: bonding/passkey pairing.

    The device is a Meshtastic radio exposing a custom BLE service. CIQ can scan it by UUID, pairDevice(scanResult) connects, and I can resolve the registered service/characteristics. But the device is configured to require a PIN/passkey. When I write to the protected characteristic, CIQ gets STATUS_GATT_INSUFFICIENT_AUTHENTICATION_FAIL (18).

    I tried setConnectionStrategy(CONNECTION_STRATEGY_SECURE_PAIR_BOND). I also tried integrating with Garmin’s native sensor pairing flow using Sensor.SensorDelegate / notifyNewSensor / onPair / notifyPairComplete, following the NordicThingy52 sample. The watch shows the generic BLE sensor and my config screen, then says “connected”, but the Meshtastic device never shows a PIN prompt and device.isBonded() remains false.

    Calling Device.requestBond() from the app crashes the D2 Mach 2 with a native System Error, even if deferred outside the connection callback.

    Do you know if CIQ supports PIN/passkey bonding for generic BLE peripherals at all? Or is CIQ generic BLE limited to devices that don’t require passkey entry?