Application Settings#

The Application Settings component provides the fundamental API for getting and setting Wi-SUN related settings within the application code. After initializing with the app_wisun_setting_init() function, the setters and getters can be used in the application to interface with runtime settings such as network name, network size, TX power, and PHY configuration.

A notification mechanism is implemented and is triggered by the appropriate settings changes.

The following code snippet demonstrates the API usage:

#include "sl_wisun_api.h"
#include "sl_wisun_app_setting.h"
#include "sl_wisun_app_core_util.h"

static void change_settings(void) {
  app_setting_wisun_t setting = { 0 };
  sl_status_t status = SL_STATUS_FAIL;

  // Disconnect before setting new values
  sl_wisun_disconnect();

  // Get all the settings
  status = app_wisun_setting_get(&setting);
  if (status != SL_STATUS_OK) {
    // Error handling
    return;
  }

  // Increasing TX power
  setting.tx_power += 10;

  status = app_wisun_setting_set_tx_power(&setting.tx_power);
  if (status != SL_STATUS_OK) {
    // Error handling
    return;
  }

  // Connect with the new settings
  sl_wisun_app_core_util_connect_and_wait();
}