Hi, Last week I drowned my rpi-zero in a terrible yeast overflow (Brewing beer) and now I try to replace it with a smaller ESP32.
In my fermenter I've got a tilt hydrometer floating around which is an iBeacon broadcasting the gravity and temperature reading in the major and minor.
When I use the BLE_Scan sample I do indeed see the message of this sensor among the other BLE readings.
Now my question is: How do I convert the BLEAdvertisedDevice from the scan result into the BLEBeacon so that I can send the sensor readings to the web.
scanned BLEAdvertisedDevice to BLEBeacon
Re: scanned BLEAdvertisedDevice to BLEBeacon
It looks like the BLEBeacon class has a method called setData() which can be passed a representation of a Beacon record. Once that data is ensconced in a BLEBeacon object, you can use the getters of BLEBeacon to retrieve the relevant properties.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: scanned BLEAdvertisedDevice to BLEBeacon
I did indeed find the SetData() method and it is indeed working.
also found out that I have to use __builtin_bswap16 to get the correct values from the major and minor.
Next step is to push the data to influxdb
also found out that I have to use __builtin_bswap16 to get the correct values from the major and minor.
Next step is to push the data to influxdb
Re: scanned BLEAdvertisedDevice to BLEBeacon
Hi @kolban,
I am trying to do something similar... Using ESP32 for Arduino, I have followed your excellent book and examples, but getting stuck...
Is it possible to have a non-blocking call for iBeacon scanning? In my application, I need the code to continue execution and the callback called when a new result is issued. Thanks in advance!
I am trying to do something similar... Using ESP32 for Arduino, I have followed your excellent book and examples, but getting stuck...
Is it possible to have a non-blocking call for iBeacon scanning? In my application, I need the code to continue execution and the callback called when a new result is issued. Thanks in advance!
Re: scanned BLEAdvertisedDevice to BLEBeacon
Currently, the design of the BLEScan::start() function is blocking until the scan has completed. We could re-design the solution so that BLEScan::start() can optionally return immediately. At that point you would have had to have registered callback functions to be able to be informed when a scan response is available. I'm also imagining you will want to know when the scan duration has completed.
We might want to change the implementation signature from the current:
BLEScan::start(duration)
to
BLEScan::start(duration, completionCallback)
The completionCallback would be optional and, if omitted, the semantics would be as they are today. However, if the completionCallback were supplied, that would indicate that you want BLEScan::start() to return immediately and invoke completionCallback when the scan has completed.
We might want to change the implementation signature from the current:
BLEScan::start(duration)
to
BLEScan::start(duration, completionCallback)
The completionCallback would be optional and, if omitted, the semantics would be as they are today. However, if the completionCallback were supplied, that would indicate that you want BLEScan::start() to return immediately and invoke completionCallback when the scan has completed.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: scanned BLEAdvertisedDevice to BLEBeacon
Maybe i dont understand something but:
- you can scan continually with BLEScan::Start(0),
- you can have callback for Scan::onResult which is called every time when new scan is performed and found any device
https://github.com/nkolban/esp32-snippe ... n.cpp#L116,
also you may want to scan all devices even device has been seen previously.
- you can scan continually with BLEScan::Start(0),
- you can have callback for Scan::onResult which is called every time when new scan is performed and found any device
https://github.com/nkolban/esp32-snippe ... n.cpp#L116,
also you may want to scan all devices even device has been seen previously.
Re: scanned BLEAdvertisedDevice to BLEBeacon
@chegewara
I think what the original poster wants is to make a call to BLEScan::start(0) and have that call return immediately while continuing to scan in the background. My understanding is that if we call BLEScan::start() today, it will block until the scan interval expires or otherwise the scanning is explicitly terminated.
I think what the original poster wants is to make a call to BLEScan::start(0) and have that call return immediately while continuing to scan in the background. My understanding is that if we call BLEScan::start() today, it will block until the scan interval expires or otherwise the scanning is explicitly terminated.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: scanned BLEAdvertisedDevice to BLEBeacon
I am using BLEScan::start(0) and i am running BLEServer at the same time. Again, i may not understand the nature of this problem, but if BLEScan::start(0) really is blocking then to achieve this (
We have scan performed in background in another task, and we can continue executing code.
) there is very simple solution:to make a call to BLEScan::start(0) and have that call return immediately while continuing to scan in the background
Code: Select all
BLEScan *pScan;
void scanTask(void*){
pScan->start(0);
}
xCreateTask(&scanTask, "task", ....);
//more user code
Re: scanned BLEAdvertisedDevice to BLEBeacon
Apparently the user is working in Arduino land and has explicitly chosen not to use threading/tasks. However, your thinking appears solid to my eyes.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Who is online
Users browsing this forum: No registered users and 86 guests