I recently start BLE with BlueDuino Rev2.
I would like to let it looking for other devices by itself and connect with other device by mac address.
Here’s my code for it
#include <AB_BLE.h>
#define BAUD_RATE 9600
AB_BLE ble(&Serial1);
String tmp;
void setup() {
Serial.begin(BAUD_RATE);
Serial1.begin(BAUD_RATE);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Hello BlueDuino!");
ble.write("AT+ROLE1\n");
delay(1000);
ble.println("AT+SCAN1\n");
delay(50000);
ble.println("AT+ROLE?");
delay(1000);
ble.println("AT+CONN008098BC9AA03\n");
delay(10000);
ble.println("AT+NAME?\r");
delay(100);
ble.println("AT+VERS?\r");
delay(100);
ble.println("AT+ADDR?\r");
delay(1000);
}
void loop() {
ble.println("AT+CONN?\n");
delay(100);
while (ble.available() > 0) {
tmp += char(ble.read());
delay(2);
}
if(tmp.length() > 0) {
Serial.println(tmp);
tmp = "";
}
if (Serial.available()) {
ble.write(Serial.read());
}
}
But it doesn’t show all reply of At command in serial monitor