pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

Set iBeacon Advertising Power and Frequency For LoPy #41

Open proQreate opened 6 years ago

proQreate commented 6 years ago

Hi,

I've managed to setup the advertisement as such now it functions as an iBeacon. However, I can't find anywhere in the documentation for a way to set the advertising frequency and the actual transmitting power. By Tx Power I do not mean the RSSI which is at the end of the manufacture data. So I'm wondering if these can be set in some way.

Thanks,

QJ

jmarcelino commented 6 years ago

For now the advertising frequency is fixed in the C code at https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/mods/modbt.c#L202 - currently between adv_int_min (20) to adv_int_max (40ms).

You could change that and build a custom firmware image, adapt the code so it takes those as parameters or.. wait until someone else does.

However changing the TX power is not supported by Espressif (who make the ESP32 chip) so there is currently no way to do it.

jmarcelino commented 6 years ago

The latest ESP-IDF includes functions to set/get the transmit (TX) power for BLE.

esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)

in bt.c

It would be great if these could be imported into pycom-esp-idf

danicampora commented 6 years ago

@jmarcelino we'll do, thanks!

binloan commented 6 years ago

I want to vote on this issue - Especially on being able to set advertisement intervals.

This functionality is crucial, because if the WiPy/Lopy becomes a peripheral, some older smartphones do not detect the advertisements. This is due to a bad interval time. I would recommend that the default advertising interval is set to one which is specified in this document by Apple (https://developer.apple.com/library/content/qa/qa1931/_index.html)

The intervals there work pretty neat with many platforms and different Bluetooth chipsets. Especially on Android where the BT chip quality varies by quiet some degree.

Note: Also it looks like the scan response was disabled. Some centrals need the scan response to find a device. This should be set to True https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/mods/modbt.c#L1052