How to create 2 BLE instances

Hi, I’m new to the world of Mbed and trying to simultaneously run a Gatt client and server.

I have read that to do so I need to create 2 different instances of the BLE service.

This is probably crazy easy, but being the noob that I am to C I’m not sure how to do that?

This is what I’m trying,

BLE ble1 = BLE(1);
BLE ble2 = BLE(2);

but I’m getting the error: “‘BLE::BLE(const BLE&)’ is private within this context” which doesn’t make sense to me since I’m not parsing in a BLE object.

It seems that BLE is implemented as a singleton class. This means that you can’t create more than one instance of a BLE object.

Hi Breda, thanks for your response. According to the documentation at https://os.mbed.com/docs/mbed-os/v5.14/mbed-os-api-doxy/class_b_l_e.html#aa1230029fa17cd3853786f97191495d9, it seems it is possible using this constructor, although it uses the same underlying transport object, I’m hoping that it works for what I’m trying to do:

BLE	(	InstanceID_t 	instanceID = DEFAULT_INSTANCE	)

This thread https://os.mbed.com/questions/84478/Can-I-have-the-nrf52-dk-acting-as-BLE-Se/ also seems to say it’s possible, although my approach is possibly wrong?

potentially I should be trying to use multiple BLEInstanceBase instead?