Bluetooth advertisement problems
smarok last edited by smarok
Issue: How to send only one beacon at a time (Something Like Ruvvi Tag).
time_1 = 0.05 def adv_me(): while (True): print("Sending...") bluetooth.advertise(True) time.sleep(time_1) bluetooth.advertise(False) time.sleep(5)
I have set my tx_power at highest value available.
Also I played a little bit with adv_int_min and adv_int_max but I still get the results I was looking for,.
bluetooth.set_advertisement_params(adv_int_min=0x20, adv_int_max=0x40, adv_type=Bluetooth.ADV_TYPE_IND, #own_addr_type=Bluetooth.BLE_ADDR_TYPE_PUBLIC, channel_map=Bluetooth.ADV_CHNL_ALL, adv_filter_policy=Bluetooth.ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY)
If I use value of time_1 as 0.05 sec then sometimes it is detected by the gateway, sometimes it is not. No consistency.
If I use value of time_1 as 0.1 sec then gateway detects the advertisement multiple times.
I have tested many other time periods but none of them seem to give consistent results. I just want to send advertisement one time. Is there a way to disable advertisement after just one beacon ?
jcaron last edited by
@smarok Comparing BLE and LoRa is probably quite difficult given the differences in timing, range, etc.
You should probably start by increasing the advertising interval. I would probably set it to 1 second or more.
Also, if you intend to send actual data, a better option is probably to connect and send data via characteristics (use the write or notify mechanisms depending on the direction) rather than just broadcast via advertisements.
smarok last edited by
@jcaron I am trying to compare LoRa and BLE stablity :D. Node and gateway are kept just one meter apart. I am sending data to a cloud platform and comparing number of times data was sent by BLE and LoRa. Since, BLE is advertising data multiple times it becomes a little hard to do this job :).
I have alot of BLE beacons (not mine) near my place so I am guessing the FIFO buffer where BLE advertisements are stored gets full and gateway start to miss some data. nRF connect Android Application never misses data sent by my node (maybe a bigger buffer).
I can't do anything about other beacons so I thought maybe if I send only one advertisement at a time it might work better because eventually I will also be testing with multiple beacons. Also, I am sending data to cloud via LTE so I want to reduce the size of data. I can process data in gateway to save only one advcertisement but that will also consume some time (loosing more data, FIFO buffer). I am trying to make it as fast as possible so that FIFO buffer does not get full
jcaron last edited by
@smarok Is there a specific reason you only want one advertisement? This goes a bit against the whole principle of advertisements, especially as:
- an advertisement could be lost
- an advertisement is always sent 3 times on 3 different channels anyway
Anyone receiving the advertisements should be able to deduplicate them (it's actually sometimes more difficult to get each repeated advertisement than to receive each of them).
If you really want to do that, your best bet is probably to set
adv_int_min/maxto something around the time you have advertisements turned on, so that there should be one and only one advertisement during that time. Use a relatively large value for that interval, as there's probably quite a bit of uncertainty at both ends. For instance you could use 1 second and set the advertising interval to 16000.