Application Core#

The Application Core component provides utilities common to most Wi-SUN applications with the following features:

  • A Wi-SUN connection helper function app_wisun_network_connect() configures the network size setting, the TX output power, the certificates, and keys. The last function action is to start the Wi-SUN connection process. The app_wisun_network_is_connected() function provides a simple connection status getter too.

  • Event handlers for basic Wi-SUN network events component includes the basic event handler implementations.

  • Available addresses. Retrieve known IPv6 addresses with the app_wisun_get_current_addresses() function.

  • Error Getter. Use app_wisun_core_get_error() function to get the status of the Stack API calls.

To use the component in your application, add it to your project and initialize it with app_wisun_core_init().

The Application Core component is designed to offer essential utilities commonly used in Wi-SUN applications with the following features:

To use the component in your application, add it to your project and initialize it with sl_wisun_app_core_init().

Modules#

Application Core API type definitions

#

void

Initialize Wi-SUN project information.

void

Print Wi-SUN project information.

const app_project_info_t *

Get Wi-SUN Project info.

void

Wait for the connection.

void

Connect and wait for connection.

bool

The network is connected.

void

Thread dispatch function.

Functions#

void
sl_wisun_app_core_get_current_addresses(sl_wisun_app_core_current_addr_t *const dest_addresses)

Get the current addresses.

bool

Return the state of the regional regulation.

sl_status_t
sl_wisun_app_core_get_regulation_thresholds(sl_wisun_app_core_reg_thresholds_t *thresholds_out)

Get the warning and alert levels for approaching/exceeded the TX budget.

sl_status_t
sl_wisun_app_core_get_remaining_tx_budget(uint32_t *const budget_out)

Get the remaining budget from the transmission quota.

sl_status_t
sl_wisun_app_core_get_state(uint32_t *const state)

Get application core state.

void
sl_wisun_app_core_get_time_stat(sl_wisun_app_core_time_stat_t *const tstat)

Get time statistic.

void

Initialize Wi-SUN application core.

void

Connect to the Wi-SUN network.

void

Set the regional regulation to active or passive.

void
sl_wisun_app_core_set_regulation_thresholds(const int8_t warning_level, const int8_t alert_level)

Set up warning and alert thresholds for the regional regulation.

sl_status_t
sl_wisun_app_core_wait_state(const uint32_t state, const uint32_t timeout)

Waiting for application core state flags.

sl_wisun_app_core_util_project_info_init#

void sl_wisun_app_core_util_project_info_init (const char * app_name)

Initialize Wi-SUN project information.

Parameters
TypeDirectionArgument NameDescription
const char *[in]app_name

Application name

Init internal instance


sl_wisun_app_core_util_project_info_print#

void sl_wisun_app_core_util_project_info_print (const bool json_format)

Print Wi-SUN project information.

Parameters
TypeDirectionArgument NameDescription
const bool[in]json_format

Json format required indicator

Print project info in pretty or json format.


sl_wisun_app_core_util_project_info_get#

const app_project_info_t * sl_wisun_app_core_util_project_info_get (void )

Get Wi-SUN Project info.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Get a constant instance of internal Wi-SUN project info Returns

  • app_project_info_t * Project info


sl_wisun_app_core_util_wait_for_connection#

void sl_wisun_app_core_util_wait_for_connection (void )

Wait for the connection.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This function doesn't call the sl_wisun_app_core_network_connect() function. The function provides a delay loop with optional heart beat printing till the connection state has not been changed.


sl_wisun_app_core_util_connect_and_wait#

void sl_wisun_app_core_util_connect_and_wait (void )

Connect and wait for connection.

Parameters
TypeDirectionArgument NameDescription
voidN/A

The function calls sl_wisun_app_core_network_connect() function and sl_wisun_app_core_util_wait_for_connection() function. It can be useful at the beginning of application thread.


sl_wisun_app_core_util_network_is_connected#

bool sl_wisun_app_core_util_network_is_connected (void )

The network is connected.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Wrapper function of join state getter Returns

  • true Connected

  • false Not connected


sl_wisun_app_core_util_dispatch_thread#

void sl_wisun_app_core_util_dispatch_thread (void )

Thread dispatch function.

Parameters
TypeDirectionArgument NameDescription
voidN/A

For low power LFN mode, the delay value is 'SL_WISUN_APP_CORE_THREAD_LP_DISPATCH_MS', for FFN mode, the delay is 1ms


Function Documentation#

sl_wisun_app_core_get_current_addresses#

void sl_wisun_app_core_get_current_addresses (sl_wisun_app_core_current_addr_t *const dest_addresses)

Get the current addresses.

Parameters
TypeDirectionArgument NameDescription
sl_wisun_app_core_current_addr_t *const[out]dest_addresses

Destination

Copy cached addresses into destination.


sl_wisun_app_core_get_join_state#

sl_wisun_join_state_t sl_wisun_app_core_get_join_state (void )

Get Wi-SUN join state.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Thread-safe getter to get connection state. Join state is stored in appropriate event callback. Returns

  • sl_wisun_join_state_t Join state value.


sl_wisun_app_core_get_regulation_active#

bool sl_wisun_app_core_get_regulation_active (void )

Return the state of the regional regulation.

Parameters
TypeDirectionArgument NameDescription
voidN/A

This function tells the caller if a regulation is currently active. Returns

  • Boolean indicating if a regional regulation is currently active.


sl_wisun_app_core_get_regulation_thresholds#

sl_status_t sl_wisun_app_core_get_regulation_thresholds (sl_wisun_app_core_reg_thresholds_t * thresholds_out)

Get the warning and alert levels for approaching/exceeded the TX budget.

Parameters
TypeDirectionArgument NameDescription
sl_wisun_app_core_reg_thresholds_t *[out]thresholds_out

pointer to the struct to hold the thresholds

Values representing percentages of the allowed transmission quota in ms are returned for the warning and alert levels, respectively. Returns

  • sl_status_t SL_STATUS_OK on success, otherwise SL_STATUS_FAIL


sl_wisun_app_core_get_remaining_tx_budget#

sl_status_t sl_wisun_app_core_get_remaining_tx_budget (uint32_t *const budget_out)

Get the remaining budget from the transmission quota.

Parameters
TypeDirectionArgument NameDescription
uint32_t *const[out]budget_out

pointer to return the remaining budget to.

Returns the state of the regional regulation and the remaining budget in ms if applicable, or zero budget if exceeded or not regulated. Returns

  • sl_status_t SL_STATUS_OK on success, otherwise SL_STATUS_FAIL


sl_wisun_app_core_get_state#

sl_status_t sl_wisun_app_core_get_state (uint32_t *const state)

Get application core state.

Parameters
TypeDirectionArgument NameDescription
uint32_t *const[out]state

is the indicator of the error

The function retrieves the application core state value (32 bits) Returns

  • sl_status_t SL_STATUS_OK on success, otherwise SL_STATUS_FAIL


sl_wisun_app_core_get_time_stat#

void sl_wisun_app_core_get_time_stat (sl_wisun_app_core_time_stat_t *const tstat)

Get time statistic.

Parameters
TypeDirectionArgument NameDescription
sl_wisun_app_core_time_stat_t *const[out]tstat

Time statistic structure

Create a copy of time statistic storage with up-to-date values


sl_wisun_app_core_init#

void sl_wisun_app_core_init (void )

Initialize Wi-SUN application core.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Initializing mutex, socket handler and set Wi-SUN settings.


sl_wisun_app_core_network_connect#

void sl_wisun_app_core_network_connect (void )

Connect to the Wi-SUN network.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Network initialization and connection. The function initializes the network with parameters (Network name, TX Power, Network size, etc.) by the stored settings in NVM if the settings component is added to the project, otherwise with the default settings.


sl_wisun_app_core_set_regulation_active#

void sl_wisun_app_core_set_regulation_active (bool enabled)

Set the regional regulation to active or passive.

Parameters
TypeDirectionArgument NameDescription
bool[in]enabled

(true = active, false = not active)

After a stack API call for regional regulation, this function can be used to store the status of the regulation (active or not).


sl_wisun_app_core_set_regulation_thresholds#

void sl_wisun_app_core_set_regulation_thresholds (const int8_t warning_level, const int8_t alert_level)

Set up warning and alert thresholds for the regional regulation.

Parameters
TypeDirectionArgument NameDescription
const int8_t[in]warning_level

new percentage for the warning threshold

const int8_t[in]alert_level

new percentage for the alert threshold

Sets up the percentages of warnings and alerts where the regulation indicate that the transmission quota is approached/exceeded.


sl_wisun_app_core_wait_state#

sl_status_t sl_wisun_app_core_wait_state (const uint32_t state, const uint32_t timeout)

Waiting for application core state flags.

Parameters
TypeDirectionArgument NameDescription
const uint32_t[in]state

state variable which includes the expected flags

const uint32_t[in]timeout

timeout for waiting

The function waits for application core states described in the state variable. Multiple state flags can be set. The function waits for all flags. Flags are not cleared in this function. Returns

  • sl_status_t SL_STATUS_OK on success, otherwise SL_STATUS_FAIL