ESP32的蓝牙扫描与MESH通信技术解析
1. 蓝牙设备扫描
在将ESP32微控制器连接到蓝牙设备时,需要知道蓝牙设备的名称。Evandro Luis Copercini开发的BluetoothSerial库可用于扫描蓝牙设备,当安装esp32 Boards Manager时,该库会一并安装。
以下是扫描蓝牙设备并显示设备名称和对应RSSI(接收信号强度指示)值的代码:
#include <BluetoothSerial.h> // include library and associate
BluetoothSerial SerialBT; // SerialBT with library
int Ndev, lag = 5000; // scan period of 5s
void setup()
{
Serial.begin(115200); // Serial Monitor baud rate
SerialBT.begin(); // initialize SerialBT
Serial.printf("\nscanning for %ds \n", lag/1000);
// scan for lag time
BTScanResults * BTdevs = SerialBT.discover(lag);
Ndev = BTdevs->getCount();
超级会员免费看
订阅专栏 解锁全文
700

被折叠的 条评论
为什么被折叠?



