Bluetooth pairing in "client" mode
Posted: Tue Jul 09, 2019 10:35 am
Experts!
In my project, I'm using BT SPP to communicate between ESP32 and an Android device. I'm using the Arduino IDE and currently works fine. When the ESP32 comes up, I connect the Android device to the already paired ESP32 over BT. I use a Bluetooth Serial Terminal app on the Android. Data is sent and received on both devices - no issues.
Code that we're using effectively is this:
The problem I see is this: Any other device could just pair and connect to the ESP32 and send/receive data. In my project, security is needed and this issue leaves my design exposed.
What I'm looking for is:
1. How could I possibly setup the ESP32 as "client" and Android as "server". Once paired, the Android device will be in hidden/invisible/non-discoverable mode to new devices. Only the paired ESP32 "client" will be able to connect to the ANdroid device when it restarts.
2. Any "PIN" that I could set up on the ESP32 to provide some level of security?
3. Any other means by which I could make the design "intrusion" proof?
We've built quite a good system with our project using ESP32 and it has been performing very well, but this last bit is troubling us. Any help would be truly appreciated.
Regards,
Deepak
In my project, I'm using BT SPP to communicate between ESP32 and an Android device. I'm using the Arduino IDE and currently works fine. When the ESP32 comes up, I connect the Android device to the already paired ESP32 over BT. I use a Bluetooth Serial Terminal app on the Android. Data is sent and received on both devices - no issues.
Code that we're using effectively is this:
Code: Select all
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(20);
}
What I'm looking for is:
1. How could I possibly setup the ESP32 as "client" and Android as "server". Once paired, the Android device will be in hidden/invisible/non-discoverable mode to new devices. Only the paired ESP32 "client" will be able to connect to the ANdroid device when it restarts.
2. Any "PIN" that I could set up on the ESP32 to provide some level of security?
3. Any other means by which I could make the design "intrusion" proof?
We've built quite a good system with our project using ESP32 and it has been performing very well, but this last bit is troubling us. Any help would be truly appreciated.
Regards,
Deepak