FireBeetle-ESP32+Arduino IDE如何读取搜索到的蓝牙的RSSI
2017-10-231.5万
AI 快速预览详细
本文介绍了如何在FireBeetle-ESP32上使用Arduino IDE读取蓝牙设备的RSSI值。通过BLEDevice库和BLEAdvertisedDevice回调函数,用户可以在扫描到的蓝牙设备列表中获取每个设备的RSSI值。具体步骤包括初始化BLE设备、设置扫描参数、定义回调函数并在其中添加读取RSSI值的代码。通过这些步骤,用户可以轻松实现蓝牙设备信号强度的读取,为项目提供更准确的数据支持。
|
最近一直在找方法读取ESP32蓝牙的RSSI,一直没有结果请求各位帮忙。在demo中要加什么才能读取RSSI。 #include <BLEDevice.h> #include <BLEUtils.h> #include <BLEScan.h> #include <BLEAdvertisedDevice.h> int scanTime = 30; //In seconds class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice advertisedDevice) { Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str()); } }; void setup() { Serial.begin(115200); Serial.println("Scanning..."); BLEDevice::init(""); BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster BLEScanResults foundDevices = pBLEScan->start(scanTime); Serial.print("Devices found: "); Serial.println(foundDevices.getCount()); Serial.println("Scan done!"); } void loop() { // put your main code here, to run repeatedly: delay(2000); } |



