Hi,
I am trying to connect two phones with nano33 IoT via Bluetooth. I could connect one device via Bluetooth with the code below. However, I could not connect two devices at the same time. Would you teach me how to solve this issue ?
#include <ArduinoBLE.h>
void setup() {
Serial.begin(9600); // initialize serial communication
while (!Serial);
if (!BLE.begin()) { // initialize BLE
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Nano33"); // Set name for connection
BLE.advertise(); // Start advertising
Serial.print("Peripheral device MAC: ");
Serial.println(BLE.address());
Serial.println("Waiting for connections...");
}
void loop() {
BLEDevice central = BLE.central(); // Wait for a BLE central to connect
if(central){
// if a central is connected to the peripheral:
Serial.print("MAC: ");
// print the central's BT address:
Serial.println(central.address());
delay(1000);
}
}
Thank you