Closed HanvanHulst closed 5 years ago
Lets start from a joke: https://github.com/nkolban/esp32-snippets/tree/master/BLE/scanner I think its oldest ble code that mr. Neil posted.
Now more serious. With this example and few more lines of code you have all you need: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleScan.cpp
I thought its done, but it requires to add few more lines here: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLEAdvertisedDevice.cpp#L237
Sorry to ask i am quite new to the ESP board, but it seams that you use the ESP IDF environment to write code for the board and net like me the Arduino IDE.
Wat is by the way the best environment to write code for the ESP8266 and the ESP32 including all kind of sensors?
regards Han
From my point of view both are good. And arduino can have library for less common sensors. I will make required changes so you can get and use raw advertising data, i already have it was required for my other (abandoned) project, i just need to prepare PR.
Great thanks for your help. I am looking forward to it
Added in PR #507
I found a solution and it seems to work fine; i still have to cleanup the code
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice advertisedDevice) { CapAddress = advertisedDevice.getAddress().toString().c_str(); CapData = String(advertisedDevice.toString().c_str()).substring(String(advertisedDevice.toString().c_str()).indexOf("data:")+6); CapName = advertisedDevice.getName().c_str(); Serial.println(" CO2 : " + String(strtoul(CapData.substring(4,8).c_str(),0,16))); Serial.println(" PM2.5 : " + String(strtoul(CapData.substring(8,12).c_str(),0,16))); Serial.println(" PM10 : " + String(strtoul(CapData.substring(12,16).c_str(),0,16))); Serial.println(" CO : " + String(strtoul(CapData.substring(16,18).c_str(),0,16))); Serial.println(" O3 : " + String(strtoul(CapData.substring(18,20).c_str(),0,16)));
You choice, code is ready anyway.
@HanvanHulst this issue seems solved, could you please close it to keep the issue list clean?
@chegewara
Hi,
Is it possible to use an ESP32 to scan and gather raw advertising data? At this moment i use a raspberry pi with HCIDUMP -Rx to get the following data;
I would like to store this raw BLE advertising data in a database. The data is from a Air Mentor Pro and contains PM2.5,PM10,CO2,TVOC, TEMP and humidity data.
Is there an example program to scan for raw data? or should i switch over to esp idf?
Kindly regards Han