Connecting directly to a specific BLE Device

Hi guys,

Stepped myself through Jim's ConnectIQ BLE example which has been very helpful. I'm can read and write to and from my own hardware now, but onto the next thing.

Question
If I have multiple BLE devices in range, that are all advertising the same characteristic, is there a way I can specifically set which device I want to connect to via mac or some other method?

Cheers,
Matt

  • All my CIQ apps with BLE are working fine on real devices withe the latest version of CIQ without using setConnectionStratigy and using non-bonded connections.  Including to the Garmin HRM-PRO.  You really need to get something CIQ is known to work with and then use that to try things with and help you understand what is happening with your scale.

    Here for example is a DF that uses the thing52, displays the device name, time data was received, the temperature, and the battery level of the thingy52. It works on devices with the latest CIQ...  I put it together in a short time a few days back,

  • Thingy seems to open a whole new playground :-)

    But remember my scale named QN-Scale does not connect to your app BleScan either (does not turn green). So maybe CIQ really needs a extension. 

  • BleScan doesn't do anything with bonding so that's an option on some devices.

    Be it a Thingy52 or something like a HRM, things could get easier if you have a device CIQ Ble works with to try things - you start with a known

  • I have tried to connect with some Apple device also seen within the BLE advertisements. This was successful as

    onConnectedStateChanged is called asynchronously.

    10:08:05 -- RawData: 02 01 1A 02 0A 0C 0A FF 4C 00 10 05 09 14 D1 B8 D2 from device named: null
    10:08:05 ManufacturerData: 004C - Data: 10 05 09 14 D1 B8 D2
    10:08:05 Scanning: finished - found 1 results
    10:08:05 Post-processing: UUID check - count #0 - found 1 UUIDs
    10:08:05 Post-processing: - parsing data of UUID = 004C
    10:08:05 getAvailableConnectionCount() = 3
    10:08:05 Pairing initiated with device named: null
    10:08:05 Unpaired device name: null
    10:08:05 Total unpaired devices: 1
    10:08:06 -- RawData: 07 FF 4C 00 12 02 00 01 from device named: null
    10:08:06 ManufacturerData: 004C - Data: 12 02 00 01
    10:08:06 Scanning: finished - found 1 results
    10:08:06 Post-processing: UUID check - count #0 - found 1 UUIDs
    10:08:06 Post-processing: - parsing data of UUID = 004C
    10:08:09 +++++++++++++++BleScaleSensor.onConnectedStateChanged
    10:08:09  Device is connected: true
    10:08:09  Device name: null
    10:08:09  CONNECTION_STATE_CONNECTED
    10:08:09  CONNECTION_STATE_CONNECTED
    10:08:09  Service not found

    At least my code seems to be right. How this can help with the connection to QN-Scale? At least nrf Connect on my smartphone can successfully connect the scale.

    Any idea what I can influence to get a connection with CIQ?

  • nRFConnect can give you false positives on things you can't do with CIQ,  With CIQ, it's a very basic/minimal implementation of BLE

    For example, noting like UUIDs is learned over the connection with CIQ.  Every service/characteristic used must be defined when you register profile.

  • I understand that Garmin BLE Stack is very basic. I feel it is not very good described in the documentation where the limitations are.

    The fact that you have no service autodiscovery, but have to declare your profile is such limitatation. The profile you need to enable notifications, indications or read and write to characteristics. That means it should not be relevant for initial connection establishment.

    It may be that the BLE stack refuses to connect if the peripheral is not able to enter key exchange protocol? Therefore I proposed Ble.CONNECTION_STRATEGY_INSECURE;

  • New to me. Thanks for sharing.

    @21:37 Greg said: pairing does not guarantee that connection establishment will succeed. Several reasons for:

    • you used up all avaliable connection (max 3) or 
    • if the device stops advertising or
    • if the device goes out of range
    • connections will always be Security Mode 1, Level 1
    • CIQ BLE stack only works on MTU max size = 20. Peripheral must accept this MTU size.
  • I was sitting in the front row during that presentation.  That security mode is "no security".  I also talked to the two presenters afterwards. and came home with HW  Everyone there got a dongle, a DK, and a Thingy52, 

  • Besides all other limitations / prerequisites, be aware that CIQ BLE stack only works on MTU max size = 20. That means the device to connect to, must accept this MTU size, otherwise connection will not be established. Data flows are also limited to 20 bytes each, and are not automatically chunked.