RAK11720 BLE Central

I have a RAK11720 chip, and I’d like for it to act as BLE central and connect to a BLE peripheral. The example code for scanning works fine, but I don’t see any code to connect to the devices scanned.

This question is similar, Pairing/Bonding rak4631 , but the answer refers to some external libraries I’ve not been able to get working - Arduino IDE only turns up “Adafruit BluefruitLE nRF51”, not 52 (and the library seems a lot different, and fails to compile citing a missing “SoftwareSerial.h”, I think). Without installing a library, it fails, missing “bluefruit.h”. If I manually clone and install the “Bluefruit52Lib” library that thread refers to, I get a fail for missing “ble.h”.

This other question asks a similar thing as me, but has no answers. RAK4631 Pairing BLE

How do I get the RAK11720 to initiate a connection to a BLE peripheral?

Welcome to the forum @Erhannis

The other post you linked to is for RAK4631 based on Arduino BSP, which is using other libraries than the RAK11720, that has it’s BLE communication libraries already built into its RUI3 BSP.

I will check with our R&D, but I don’t think the RAK11720 supports BLE central mode, only beacon and peripheral.

Ok, thanks; let me know what you hear back. If it’s not supported, is the limitation in software or in hardware?

Hi, it is a firmware limitation, not a hardware limitation.
There are no plans at the moment to add Central functionality.

Thanks. Is it the kind of thing adding a library would fix, or would it require a lot of chip-specific code?

It is not just a library, it is the complete Central functionality that has to be added.

Yowch; ok, thanks. So then, I figured we’d just add another chip - the RAK would advertise in peripheral mode, in addition to the other BLE peripheral sensor, and a third chip would connect in central mode to the sensor and to the RAK. The bridge chip would read from the sensor and write to the RAK. However, the examples only show how to send data from the RAK, not to it, and I don’t immediately see any good leads in the API. Once I’ve connected to the RAK (in peripheral mode) from another chip (in central mode), how do I write data to the RAK, like I would to e.g. write configuration data to the sensor we’re using?

You can create a custom characteristic and read and write from/to it.
Example code

Yeah, that was the example code I’d been looking at. Note how there’s a setWriteCallback, but (apparently) no setReadCallback? setWriteCallback seems to handle “the remote is trying to read from this characteristic, this is the data we’re WRITING to them.” I see no corresponding setReadCallback. Consider that RAKBleUart.h defines

typedef enum
    RAK_CHR_PROPS_READ = 2,	///< Set the charactristic property to be Read
    RAK_CHR_PROPS_NOTIFY = 16,	///< Set the charactristic property to be Notify

Notably, it only defines values for “READ” and “NOTIFY”, not for “WRITE”. (Nor for a few others I’m not interested in at the moment.) This suggests the RAK’s characteristics cannot be written to, remotely. The closest thing I can see is the value cccd_value passed to cccd_callback, and I get the impression that’s intended to carry bluetooth settings data, not custom data. I’m not even certain that value can be manually set, from the remote side. Is there something I’m missing?