For ZeroBeacon as role1 how to connecter other device


#1

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 :slight_smile:

#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


#2

You can try to type these AT command at serial monitor instead and view the response.

The mac address is incorrect. It should be 12 bytes not 13 bytes. Please double check this.

AT+CONN008098BC9AA03

BTW: Is other device also a BlueDuino? BlueDuino can only connect to another BlueDuino.


#3

Thany you for your reply.

I would like to know is there any method that can let BlueDuino connect to other device automatically by searching mac address?


#4

Please describe your application. What will you do after BlueDuino connected other device?


#5

It’s a device which can be connect by Bluetooth. I would like to let BlueDuino identifie this device and connect it and get information from it.


#6

Current BlueDuino do these things after connected

  1. Discover service and find service 0xFFF0
  2. Find characteristic 0xFFF1 and 0xFFF2
  3. Set notify on 0xFFF1

It will not get information from other device. If you just want to connect to other device, run these commands. Let’s say the mac address for other device is 0x008098BC9AA0

AT+SCAN?
AT+CONN008098BC9AA0

#7

Thank you for reply!!!