beegee-tokyo / WisBlock-API

WisBlock API takes care of all the LoRaWAN, BLE, AT command functionality. It makes development of event driven power savings applications easy.
MIT License
28 stars 15 forks source link

Johansmacias/default settings modifications #2

Closed johansmacias closed 3 years ago

johansmacias commented 3 years ago

When the definition of the s_lorawan_settings structure was in the project files (main.h before WisBlock API), I could modify it to achieve a different default configuration when the flash is reset. I mean the first time a previous configuration file doesn't exist in flash, or a reboot with the ATR command is performed.

I think it is convenient to allow modifications on these default settings according to the project requirements. To mention two scenarios:

Since the api_set_credentials() is intended for hardcoding the parameters and ignores any other interaction from flash I didn't consider it suitable for this purpose. However, my suggestion is based on a similar approach that I called api_enable_default_settings_modifications().

Example:

void setup_app(void)
{
    g_enable_ble = true;

    // Optional default settings modifications
    g_default_settings_modified.lora_region = 8;            // US915 region
    g_default_settings_modified.subband_channels = 2;       // Subband 2
    g_default_settings_modified.send_repeat_time = 300000;  // 5 minutes
    // Inform API modifications in the default_settings
    api_enable_default_settings_modifications();

}
beegee-tokyo commented 3 years ago

Implemented with https://github.com/beegee-tokyo/WisBlock-API/commit/186725899e14c1db04b36aae9726568291365854