General

How do i know my Bluno is connected?

userHead djh_83 2015-03-21 21:37:54 20877 Views19 Replies
Hi,

I connect to the bluno with my iphone app over blue tooth. When I connect, a little led turns on, on the board and I can now send and receive bytes over Bluetooth. I'd like to know from within the bluno program that I am now connected with a device. The reason being is to only start sending serial data after a successful connection with the smart phone.

Thanks
2021-04-19 21:30:15 Damm even I am having a similar kind of issue, I have searched all over the internet and even have posted on number of threads on different forum, no solution seems to work. I am really frustrated, can anyone of you here help me resolve this issue, I am very much tired now. hellodear.in teatv userHeadPic praveendhaka812
2021-04-19 21:30:15 Damm even I am having a similar kind of issue, I have searched all over the internet and even have posted on number of threads on different forum, no solution seems to work. I am really frustrated, can anyone of you here help me resolve this issue, I am very much tired now. hellodear.in teatv userHeadPic praveendhaka812
2021-03-02 00:40:12 So, just in case someone else runs into this issue. It appears that pins 6 and 7 on the MCU are attached to the Link and Pair LEDs from the BLE module. This means you can test the state of pin 6 to tell whether you are linked or not. userHeadPic deanarnold.uk
2021-03-02 00:40:12 So, just in case someone else runs into this issue. It appears that pins 6 and 7 on the MCU are attached to the Link and Pair LEDs from the BLE module. This means you can test the state of pin 6 to tell whether you are linked or not. userHeadPic deanarnold.uk
2021-02-22 22:07:42 Just checking to see if anyone has found a better method. I have found the sketch above does not work great if you are going in and out of sleep mode. userHeadPic deanarnold.uk
2021-02-22 22:07:42 Just checking to see if anyone has found a better method. I have found the sketch above does not work great if you are going in and out of sleep mode. userHeadPic deanarnold.uk
2016-07-18 14:59:08 Hi timjanwall,

Sorry my bad, I didn't check the IIC interface of CC2540 before. Just now, I had a look at its datasheet, it seems that CC2540 only supports SPI interface but not IIC. http://www.ti.com/lit/ds/symlink/cc2540.pdf
userHeadPic Leff
2016-07-18 14:59:08 Hi timjanwall,

Sorry my bad, I didn't check the IIC interface of CC2540 before. Just now, I had a look at its datasheet, it seems that CC2540 only supports SPI interface but not IIC. http://www.ti.com/lit/ds/symlink/cc2540.pdf
userHeadPic Leff
2016-07-14 20:08:45 I think Leff ment i2c and i looking for the same solution as tiojoca, i will try dig in to how to get to the CC2540 with i2c. If you find enything usefull post here or pm :) userHeadPic timjanwall
2016-07-14 20:08:45 I think Leff ment i2c and i looking for the same solution as tiojoca, i will try dig in to how to get to the CC2540 with i2c. If you find enything usefull post here or pm :) userHeadPic timjanwall
2015-06-23 16:58:24 brilliant! userHeadPic Leff
2015-06-23 16:58:24 brilliant! userHeadPic Leff
2015-04-30 19:38:40 I ended up solving this using a totally different approach. I set the board to AT mode and use the AT+RSSI=? command to get the RSSI which will always be -000 if Bluno is not connected to a BT device. An example implementation of this solution:

Code: Select all
const int ledBLE = 13;
typedef enum {START, WAIT_AT, WAIT_RSSI, WAIT_EXIT, NORM_MODE, _TMP} state_type;
state_type state = START;
char chr;
String buffer, rssi, data;
bool reading = false;

void setup() {
   Serial.begin(115200);      //Initiate the Serial comm
   pinMode(ledBLE, OUTPUT);
   state = START;
 }

void loop() {
   if (state == START) {
      start();
   } else if (state == WAIT_AT) {
      wait_at();
   } else if (state == WAIT_RSSI) {
      wait_rssi();
   } else if (state == WAIT_EXIT) {
      wait_exit();
   } else if (state == NORM_MODE) {
      norm_mode();
   }
}

void start() {
   delay(10);
   Serial.print("+");
   Serial.print("+");
   Serial.print("+");
   data = "";
   state = WAIT_AT;
}

void wait_at() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == 'E') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      } else {
         data += chr;
      }
      if (reading && buffer == "Enter AT Mode\r\n") {
         Serial.println("AT+RSSI=?");
         reading = false;
         state = WAIT_RSSI;
      } else if (data == "led_on") {
         digitalWrite(ledBLE, HIGH);
         data = "";
      } else if (data == "led_off") {
         digitalWrite(ledBLE, LOW);
         data = "";
      }
   }
}

void wait_rssi() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == '-') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      }
      if (buffer.length() == 4) {
         rssi = buffer;
         Serial.println("AT+EXIT");
         reading = false;
         state = WAIT_EXIT;
         if (rssi == "-000") {
            digitalWrite(ledBLE, LOW);
         }
      }
   }
}

void wait_exit() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == 'O') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      }
      if (buffer == "OK\r\n") {
         reading = false;
         state = NORM_MODE;
      }
   }
}

void norm_mode() {
   Serial.println("\r\n<<<");
   Serial.println(rssi);
   Serial.println(">>>\r\n");
   Serial.flush();
   state = START;
}


Not sure this is the best way to do it, though. I'm not very comfortable with using Serial for all the different inputs/outputs of different sources: executing AT commands and getting their results, getting data from BT, and outputting data back to USB.

Does anyone have a better suggestion on how to do this?
userHeadPic tiojoca
2015-04-30 19:38:40 I ended up solving this using a totally different approach. I set the board to AT mode and use the AT+RSSI=? command to get the RSSI which will always be -000 if Bluno is not connected to a BT device. An example implementation of this solution:

Code: Select all
const int ledBLE = 13;
typedef enum {START, WAIT_AT, WAIT_RSSI, WAIT_EXIT, NORM_MODE, _TMP} state_type;
state_type state = START;
char chr;
String buffer, rssi, data;
bool reading = false;

void setup() {
   Serial.begin(115200);      //Initiate the Serial comm
   pinMode(ledBLE, OUTPUT);
   state = START;
 }

void loop() {
   if (state == START) {
      start();
   } else if (state == WAIT_AT) {
      wait_at();
   } else if (state == WAIT_RSSI) {
      wait_rssi();
   } else if (state == WAIT_EXIT) {
      wait_exit();
   } else if (state == NORM_MODE) {
      norm_mode();
   }
}

void start() {
   delay(10);
   Serial.print("+");
   Serial.print("+");
   Serial.print("+");
   data = "";
   state = WAIT_AT;
}

void wait_at() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == 'E') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      } else {
         data += chr;
      }
      if (reading && buffer == "Enter AT Mode\r\n") {
         Serial.println("AT+RSSI=?");
         reading = false;
         state = WAIT_RSSI;
      } else if (data == "led_on") {
         digitalWrite(ledBLE, HIGH);
         data = "";
      } else if (data == "led_off") {
         digitalWrite(ledBLE, LOW);
         data = "";
      }
   }
}

void wait_rssi() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == '-') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      }
      if (buffer.length() == 4) {
         rssi = buffer;
         Serial.println("AT+EXIT");
         reading = false;
         state = WAIT_EXIT;
         if (rssi == "-000") {
            digitalWrite(ledBLE, LOW);
         }
      }
   }
}

void wait_exit() {
   while (Serial.available() > 0) {
      chr = Serial.read();
      if (chr == 'O') {
         reading = true;
         buffer = "";
      }
      if (reading) {
         buffer += chr;
      }
      if (buffer == "OK\r\n") {
         reading = false;
         state = NORM_MODE;
      }
   }
}

void norm_mode() {
   Serial.println("\r\n<<<");
   Serial.println(rssi);
   Serial.println(">>>\r\n");
   Serial.flush();
   state = START;
}


Not sure this is the best way to do it, though. I'm not very comfortable with using Serial for all the different inputs/outputs of different sources: executing AT commands and getting their results, getting data from BT, and outputting data back to USB.

Does anyone have a better suggestion on how to do this?
userHeadPic tiojoca
2015-04-23 23:58:56 How do you do that? I'm a complete beginner and I've been looking for a solution like this for months (viewtopic.php?f=8&t=1350 ) and this seems like it could be it!

What's the IIC interface and how do you read pin8 from CC2540?

Thanks in advance!
userHeadPic tiojoca
2015-04-23 23:58:56 How do you do that? I'm a complete beginner and I've been looking for a solution like this for months (viewtopic.php?f=8&t=1350 ) and this seems like it could be it!

What's the IIC interface and how do you read pin8 from CC2540?

Thanks in advance!
userHeadPic tiojoca
2015-03-24 12:08:00 Hi,

http://www.dfrobot.com/image/data/DFR02 ... %20Sch.pdf
I found the led which turning on when connected with a ble devices is connected to CC2540 pin8, so you could read the pin state(HIGH OR LOW ) through IIC interface. ;)
userHeadPic Leff
2015-03-24 12:08:00 Hi,

http://www.dfrobot.com/image/data/DFR02 ... %20Sch.pdf
I found the led which turning on when connected with a ble devices is connected to CC2540 pin8, so you could read the pin state(HIGH OR LOW ) through IIC interface. ;)
userHeadPic Leff
2015-03-21 21:37:54 Hi,

I connect to the bluno with my iphone app over blue tooth. When I connect, a little led turns on, on the board and I can now send and receive bytes over Bluetooth. I'd like to know from within the bluno program that I am now connected with a device. The reason being is to only start sending serial data after a successful connection with the smart phone.

Thanks
userHeadPic djh_83