Simultaneous Central & Peripheral roles on one device?

Has anybody successfully run a device in both the Central and Peripheral roles at the same time to allow data to be forwarded from one device onto another?

Device A <-> Device B <-> Device C

Central <-> Peripheral & Central <-> Peripheral

I’ve had this working using the Nano 33 IOT, but have had no luck on the Nano 33 BLE. On the 33 BLE’s, Device B receives a connection from A, but it’s immediately followed by a matching Disconnect. This occurs whether there is a Device C active or not.

Should it work? If so, does anybody have any suggestions as to what I might be doing wrong or where to start looking?

Thanks.

Would also love to hear any feedback or ideas on this. I have been struggling too.
I have a remote sensor (nano ble) that needs to feed back to a central (nano ble). Once finished that would suffice but at the moment I need to pass the data wirelessly onto a phone in order to analyse etc.
A couple of times I have managed to have all 3 devices paired but it is intermittent and drops out.

I am also interested in this. Would you mind sharing your code?

IMHO, the hardware allows it but at moment the default library (ArduinoBLE) does not. So, requires a rewrite/amendment or, alternatively, you could hunt around for another library or create your own code.

One idea that I am following at the moment (input and thoughts welcome) is to broadcast from the peripheral device. Lets set the scene:

Target: Central <-> Peripheral & Central <-> Peripheral

Proposed: Central <-> Peripheral ← Broadcaster

Therefore the data would be sent without a connection leaving the second device (previously needing to be a peripheral and central) as a peripheral that is free to make a connection to the central.

This isn’t ideal but could work…the problem I am having is that I am not yet able to broadcast (which should be feasible) and there is little information out there on this topic.

Thanks

Lewis

If you can advertise you should also be able t broadcast.
IMHO there is not much different, just a matter of different payload.

However, real concurrent use is probably not possible with the existing ArduinoBLE library.

I am now looking into Micropython as this works on my board. There is a rather low-level library for BLE.
It looks quite promising.

It is theoretically possible with the MBED BLE library too...

Just be careful which documentation version of MBED you are looking at, as they have just released MBED OS version 6. I believe Arduino uses a hybrid MBED version 5.14.

https://os.mbed.com/docs/mbed-os/v5.14/apis/bluetooth.html

The BLE examples can be found on their GitHub repository, here: GitHub - ARMmbed/mbed-os-example-ble: BLE demos using mbed OS and mbed cli

I have the BLE_HeartRate example working on my Arduino Nano 33 BLE board.

I've discovered that BLE_GattServer and the BLE_LED examples are for a customised peripheral device and the BLE_GattClient and the BLE_LEDBlinker are for a customised central device.

BLE_LED uses 16bit URL's, which is bit of a hack, in my opinion. But you can get this working on an Arduino Nano 33 BLE.

BLE_GattServer and BLE_GattClient are the more comprehensive implementations, although probably over-complicated with the use of class templates and the use of "platform/callback.h" library. These examples reveal the full potential of MBED BLE but I have yet to get these working.

I looked again into the ArduinoBLE library.
It is actually possible to have central and peripheral in one device.
The key is to use the callback API.

More specifically one needs to set eventHandlers.

  // set the discovered peripheral event handle - needed as a central and mores specifically scaling
  BLE.setEventHandler(BLEDiscovered, bleCentralDiscoverHandler);

  // set event central connection Handler - need as acting as peripheral 
  BLE.setEventHandler(BLEConnected, bleCentralConnectHandler);
  BLE.setEventHandler(BLEDisconnected, bleCentralDisconnectHandler);

Scanning and advertising is simply initiated with

  // Start advertising (Advertised Service)
  BLE.advertise();
  // start scanning for peripherals with duplicates
  BLE.scan(true);

Wow that's pretty cool. Well done for figuring that out.

redyellow:
I looked again into the ArduinoBLE library.
It is actually possible to have central and peripheral in one device.
The key is to use the callback API.

More specifically one needs to set eventHandlers.

  // set the discovered peripheral event handle - needed as a central and mores specifically scaling

BLE.setEventHandler(BLEDiscovered, bleCentralDiscoverHandler);

// set event central connection Handler - need as acting as peripheral
  BLE.setEventHandler(BLEConnected, bleCentralConnectHandler);
  BLE.setEventHandler(BLEDisconnected, bleCentralDisconnectHandler);




Scanning and advertising is simply initiated with


// Start advertising (Advertised Service)
  BLE.advertise();
  // start scanning for peripherals with duplicates
  BLE.scan(true);

Did that work to you? I've been trying the same unsuccessfully :frowning: