Forum >How do i know my Bluno is connected?
How do i know my Bluno is connected?

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
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
2025-03-05 15:02:59
tiojoca
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!

2025-03-05 15:02:36
tiojoca
您是如何做到的?我完全是个初学者,几个月来我一直在寻找这样的解决方案(viewtopic.php?f=8&t=1350),这似乎就是解决方案!@@什么是 IIC 接口,您如何从 CC2540 读取 pin8?@@提前致谢!

2025-03-05 15:02:05
Leff
嗨,timjanwall,@@抱歉,我之前没有检查过 CC2540 的 IIC 接口。刚才,我查看了它的数据表,似乎 CC2540 仅支持 SPI 接口,而不支持 IIC。http ://www.ti.com/lit/ds/symlink/cc2540.pdf

2021-03-02 08: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.
deanarnold.uk

2021-03-02 08: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.
deanarnold.uk

2021-02-23 06: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.
deanarnold.uk

2021-02-23 06: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.
deanarnold.uk

2016-07-15 04: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
timjanwall


2016-07-15 04: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
timjanwall


2015-05-01 03: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:
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?
tiojoca
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?

2015-05-01 03: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:
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?
tiojoca
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?

2015-03-22 05: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
djh_83
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
