Application Core#
The Application Core component is designed to offer utilities commonly used in Wi-SUN applications with the following features:
The sl_wisun_app_core_util_connect_and_wait() function configures the network size setting, the TX output power, the certificates and keys. The function is waiting for the connected state. Its final action is to initiate the Wi-SUN connection process. The sl_wisun_app_core_network_connect() and sl_wisun_app_core_util_network_is_connected() functions also provide an easy way to establish a connection and wait for it to be ready.
Event handlers for basic Wi-SUN network events include the basic event handler implementations.
Available addresses. The sl_wisun_app_core_get_current_addresses() function retrieves known IPv6 addresses.
Status Getter. Use sl_wisun_app_core_get_state() function to get the status of the Stack API calls. The sl_wisun_app_core_get_time_stat() function retrives the connection time, disconnection time stamps and total elapsed time in those states.
Limited Function Node (LFN) device support. Use sl_wisun_app_core_get_device_type() to get the selected device type for the project. The device type can be changed in the Wi-SUN configurator interface. sl_wisun_app_core_get_lfn_profile() and sl_wisun_app_core_get_lfn_params() provide an interface to access the selected LFN profile and its parameters.
The following code snippet shows how the connection can be performed in an application thread:
#include "sl_wisun_app_core.h"
#include "sl_wisun_app_core_util.h"
/*App task function*/
void app_task(void *args)
{
(void) args;
// Connect to the wisun network.
sl_wisun_app_core_util_connect_and_wait();
while (1) {
// Put your application code here.
osDelay(1);
}
}
Modules#
#
Initialize Wi-SUN project information.
Print Wi-SUN project information.
Get Wi-SUN Project info.
Wait for the connection.
Connect and wait for connection.
The network is connected.
Thread dispatch function.
Functions#
Get the current addresses.
Get Wi-SUN device type.
Get Wi-SUN join state.
Get LFN parameters.
Get Wi-SUN LFN profile.
Return the state of the regional regulation.
Get the warning and alert levels for approaching/exceeded the TX budget.
Get the remaining budget from the transmission quota.
Get application core state.
Get time statistic.
Initialize Wi-SUN application core.
Connect to the Wi-SUN network.
Set the regional regulation to active or passive.
Set up warning and alert thresholds for the regional regulation.
Waiting for application core state flags.
undefined Documentation#
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.
[in] | app_name | Application name |
Init internal instance
92
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
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.
[in] | json_format | Json format required indicator |
Print project info in pretty or json format.
99
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
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.
N/A |
Get a constant instance of internal Wi-SUN project info Returns
app_project_info_t * Project info
106
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
sl_wisun_app_core_util_wait_for_connection#
void sl_wisun_app_core_util_wait_for_connection (void )
Wait for the connection.
N/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.
114
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
sl_wisun_app_core_util_connect_and_wait#
void sl_wisun_app_core_util_connect_and_wait (void )
Connect and wait for connection.
N/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.
122
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
sl_wisun_app_core_util_network_is_connected#
bool sl_wisun_app_core_util_network_is_connected (void )
The network is connected.
N/A |
Wrapper function of join state getter Returns
true Connected
false Not connected
130
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
sl_wisun_app_core_util_dispatch_thread#
void sl_wisun_app_core_util_dispatch_thread (void )
Thread dispatch function.
N/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
137
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core_util.h
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.
[out] | dest_addresses | Destination |
Copy cached addresses into destination.
190
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_get_device_type#
sl_wisun_device_type_t sl_wisun_app_core_get_device_type (void )
Get Wi-SUN device type.
N/A |
Getter to get device type. Device type can be SL_WISUN_LFN or SL_WISUN_ROUTER (FFN) Returns
l_wisun_device_type_t Device type.
256
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
N/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.
240
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_get_lfn_params#
const sl_wisun_lfn_params_t * sl_wisun_app_core_get_lfn_params (void )
Get LFN parameters.
N/A |
Returns
sl_wisun_lfn_params_t pointer to the set profile paramaters of LFN.
271
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_get_lfn_profile#
sl_wisun_lfn_profile_t sl_wisun_app_core_get_lfn_profile (void )
Get Wi-SUN LFN profile.
N/A |
Getter to get LFN profile. Device type can be SL_WISUN_LFN_PROFILE_TEST, SL_WISUN_LFN_PROFILE_BALANCED or SL_WISUN_LFN_PROFILE_ECO Returns
sl_wisun_lfn_profile_t LFN profile.
265
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_get_regulation_active#
bool sl_wisun_app_core_get_regulation_active (void )
Return the state of the regional regulation.
N/A |
This function tells the caller if a regulation is currently active. Returns
Boolean indicating if a regional regulation is currently active.
205
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[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
232
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[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
214
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_get_state#
sl_status_t sl_wisun_app_core_get_state (uint32_t *const state)
Get application core state.
[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
160
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[out] | tstat | Time statistic structure |
Create a copy of time statistic storage with up-to-date values
247
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_init#
void sl_wisun_app_core_init (void )
Initialize Wi-SUN application core.
N/A |
Initializing mutex, socket handler and set Wi-SUN settings.
152
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
sl_wisun_app_core_network_connect#
void sl_wisun_app_core_network_connect (void )
Connect to the Wi-SUN network.
N/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.
183
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[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).
198
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[in] | warning_level | new percentage for the warning threshold |
[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.
223
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h
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.
[in] | state | state variable which includes the expected flags |
[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
172
of file /mnt/raid/workspaces/ws.obQFDUprC/overlay/gsdk/app/wisun/component/app_core/sl_wisun_app_core.h