dbinfrago / libpax

Apache License 2.0
21 stars 13 forks source link

Evaluate nimBLE vs Bluedroid #4

Closed FlorianLudwig closed 2 years ago

FlorianLudwig commented 3 years ago

Experimenting results

Setup

Results

esp32 scanner (NimBLE) vs. esp32 scanner (Bluedroid)

In a scanning period of 15 minutes, a bluedroid scanner registered 864 ble advertising packages while a nimble scanner only registered 128. Both scanners were configured with similar scan settings. However, nimble can be tewaked to scan faster. With these tweaked settings, simultaneously advertising seems to make a little difference.

-- @ju-mueller

ju-mueller commented 3 years ago

I did some tests comparing a nimble scanners with and without advertising as well as nimlbe scanners with bluedroid scanners. The code I used and my test results can be found here

cyberman54 commented 3 years ago

How about the RF setup in this experiment? Were all 3 devices screened from outer RF, e.g. put in a microwave oven or metal box?

FlorianLudwig commented 3 years ago

Hi @cyberman54 ,

the tests without any special RF setup. The counting was just limited to a specific mac address, as the test did not test mac/device counting but package counting.

Most of the test did focus on the effect of having advertising on, while in listening mode, to get an estimate how much the multiplexing for the advertising does influence the listening.

FlorianLudwig commented 3 years ago

Another option would be to work without nimble or bluedroid:

https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/hci/ble_adv_scan_combined

cyberman54 commented 3 years ago

Probably the best option, since it avoids useless code overhead and can be tweaked exactly to the use case.

FlorianLudwig commented 3 years ago

@cyberman54 what is your opinion on making it a compile-time option?

This way libpax can be integrated into projects that use bluetooth already for something else than couting. But they must use the same bluetooth lib to be able to co-exist.

cyberman54 commented 3 years ago

@FlorianLudwig compile-time option is probably the most straight forward way. Another option would be to have a separate branch.

cyberman54 commented 3 years ago

@FlorianLudwig i created a quick & dirty version for testing. It compiles and runs, but not sure if it does what it should.

Note: If you test it with paxcounter, set #define BLESCANTIME 5 in paxcounter.conf !

cyberman54 commented 3 years ago

@FlorianLudwig i cleaned up the code in hci branch, it now does what it should. Saving lots of ressources, compared with a full-fledged bluetooth stack.

We now have a bunch of fine tuning parameters, affecting both the scope (= total number of seen packets) and the focus (= filtered packets) of MACs to be counted as pax.

Probably affecting scope:

Probably affecting focus:

I think we need deeper investigation here, to find optimum settings for the use case.

/cc @spmrider

oliverbrandmueller commented 2 years ago

1.0.0 RC2 introduces stackless BLE and thus the stack decision is done and void.