Callback Framework#

This section provides a reference to Wi-Fi API callback handling functions.

Note

  • Stack overflows may occur when invoking functions or using your own variables or data structures while handling callbacks. Configure the stack size by modifying the pre-processor macro SL_SI91X_EVENT_HANDLER_STACK_SIZE as per your application's requirements. See here for the instructions in modifying a pre-processor macro.

  • Event/Callback handlers must not contain function calls or code which can block or delay the execution of the event/callback handler as it will cause all the other events to queue up and delay the execution of other events since all the events are invoked and handled from a single thread.

  • Do not call any synchronous SDK APIs from within the Event/Callback handlers.

Typedefs#

typedef sl_status_t(*
sl_wifi_callback_function_t)(sl_wifi_event_t event, void *data, uint32_t data_length, void *arg)

Generic callback for Wi-Fi group event of type sl_wifi_event_group_t.

typedef sl_status_t(*
sl_wifi_scan_callback_t)(sl_wifi_event_t event, sl_wifi_scan_result_t *data, uint32_t data_length, void *optional_arg)

Callback for SL_WIFI_SCAN_RESULT_EVENTS group event.

typedef sl_status_t(*
sl_wifi_stats_callback_t)(sl_wifi_event_t event, void *data, uint32_t data_length, void *optional_arg)

Callback for SL_WIFI_STATS_RESPONSE_EVENTS group events.

typedef sl_status_t(*
sl_wifi_join_callback_t)(sl_wifi_event_t event, char *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_JOIN_EVENTS group events.

typedef sl_status_t(*
sl_wifi_twt_config_callback_t)(sl_wifi_event_t event, sl_si91x_twt_response_t *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_TWT_RESPONSE_EVENTS group events.

typedef sl_status_t(*
sl_wifi_transceiver_callback_t)(sl_wifi_event_t event, void *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_TRANSCEIVER_EVENTS group events.

Functions#

sl_status_t
sl_wifi_set_callback(sl_wifi_event_group_t group, sl_wifi_callback_function_t function, void *optional_arg)

Register a callback for selected event group.

sl_status_t
sl_wifi_default_event_handler(sl_wifi_event_t event, sl_wifi_buffer_t *buffer)

Default Wi-Fi event handler to passed to sl_wifi_init.

sl_status_t
sl_wifi_set_scan_callback(sl_wifi_scan_callback_t function, void *optional_arg)

Register callback for SL_WIFI_SCAN_RESULT_EVENTS group event from sl_wifi_event_group_t.

sl_status_t
sl_wifi_set_join_callback(sl_wifi_join_callback_t function, void *optional_arg)

Register callback for SL_WIFI_JOIN_EVENTS group event from sl_wifi_event_group_t.

sl_status_t
sl_wifi_set_twt_config_callback(sl_wifi_twt_config_callback_t function, void *optional_arg)

Register callback for SL_WIFI_TWT_RESPONSE_EVENTS group event from sl_wifi_event_group_t.

sl_status_t
sl_wifi_set_stats_callback(sl_wifi_stats_callback_t function, void *optional_arg)

Register callback for SL_WIFI_STATS_RESPONSE_EVENTS group event from sl_wifi_event_group_t.

sl_status_t
sl_wifi_set_transceiver_callback(sl_wifi_transceiver_callback_t function, void *optional_arg)

Register callback for SL_WIFI_TRANSCEIVER_EVENTS group event from sl_wifi_event_group_t.

Macros#

#define

Generic macro for callback functions to check if the event has Failed.

Typedef Documentation#

sl_wifi_callback_function_t#

sl_wifi_callback_function_t )(sl_wifi_event_t event, void *data, uint32_t data_length, void *arg)

Generic callback for Wi-Fi group event of type sl_wifi_event_group_t.

Parameters
N/Aevent

Wi-Fi event of type sl_wifi_event_t

N/Adata

Data received

N/Adata_length

Data length

N/Aoptional_arg

Optional user provided argument passed in sl_wifi_set_callback

Returns

Note

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored


Definition at line 47 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_scan_callback_t#

sl_wifi_scan_callback_t )(sl_wifi_event_t event, sl_wifi_scan_result_t *data, uint32_t data_length, void *optional_arg)

Callback for SL_WIFI_SCAN_RESULT_EVENTS group event.

Parameters
N/Aevent

Wi-Fi event of type sl_wifi_event_t

N/Adata

Scan results of type sl_wifi_scan_result_t

N/Adata_length

Data length

N/Aoptional_arg

Optional user provided argument passed in sl_wifi_set_scan_callback

Returns

Note

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored


Definition at line 65 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_stats_callback_t#

sl_wifi_stats_callback_t )(sl_wifi_event_t event, void *data, uint32_t data_length, void *optional_arg)

Callback for SL_WIFI_STATS_RESPONSE_EVENTS group events.

Parameters
N/Aevent

Wi-Fi event of type sl_wifi_event_t Individual Wi-Fi events related to SL_WIFI_STATS_RESPONSE_EVENTS is as follows.

sl_wifi_event_t

DataType

SL_WIFI_STATS_EVENT

Not supported in current release

SL_WIFI_STATS_AYSNC_EVENT

sl_si91x_async_stats_response_t

SL_WIFI_STATS_ADVANCE_EVENT

Not supported in current release

SL_WIFI_STATS_TEST_MODE_EVENT

Not supported in current release

SL_WIFI_STATS_MODULE_STATE_EVENT

sl_si91x_module_state_stats_response_t

N/Adata

Data received.

N/Adata_length

Data length

N/Aoptional_arg

Optional user provided argument passed in sl_wifi_set_stats_callback

Returns

Note

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored.


Definition at line 94 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_join_callback_t#

sl_wifi_join_callback_t )(sl_wifi_event_t event, char *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_JOIN_EVENTS group events.

Parameters
N/Aevent

Wi-Fi event of type sl_wifi_event_t

N/Adata

Data received in string.

Data received

Description

C

Module connection success

F

Module connection failed

N/Adata_length

Data length

N/Aoptional_arg

Optional user provided argument passed in sl_wifi_set_join_callback

Returns

Note

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored


Definition at line 119 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_twt_config_callback_t#

sl_wifi_twt_config_callback_t )(sl_wifi_event_t event, sl_si91x_twt_response_t *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_TWT_RESPONSE_EVENTS group events.

Parameters
N/Aevent

Wi-Fi event of type sl_wifi_event_t Individual Wi-Fi events related to SL_WIFI_TWT_RESPONSE_EVENTS is as follows.

sl_wifi_event_t

SL_WIFI_TWT_UNSOLICITED_SESSION_SUCCESS_EVENT

SL_WIFI_TWT_AP_REJECTED_EVENT

SL_WIFI_TWT_OUT_OF_TOLERANCE_EVENT

SL_WIFI_TWT_RESPONSE_NOT_MATCHED_EVENT

SL_WIFI_TWT_UNSUPPORTED_RESPONSE_EVENT

SL_WIFI_TWT_TEARDOWN_SUCCESS_EVENT

SL_WIFI_TWT_AP_TEARDOWN_SUCCESS_EVENT

SL_WIFI_TWT_FAIL_MAX_RETRIES_REACHED_EVENT

SL_WIFI_TWT_INACTIVE_DUE_TO_ROAMING_EVENT

SL_WIFI_TWT_INACTIVE_DUE_TO_DISCONNECT_EVENT

SL_WIFI_TWT_INACTIVE_NO_AP_SUPPORT_EVENT

SL_WIFI_RESCHEDULE_TWT_SUCCESS_EVENT

SL_WIFI_TWT_INFO_FRAME_EXCHANGE_FAILED_EVENT

N/Adata

Data received of type sl_si91x_twt_response_t.

N/Adata_length

Data length

N/Aoptional_arg

Optional user provided argument passed in sl_wifi_set_twt_config_callback

Returns

Note

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored


Definition at line 153 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_transceiver_callback_t#

sl_wifi_transceiver_callback_t )(sl_wifi_event_t event, void *data, uint32_t data_length, void *arg)

Callback for SL_WIFI_TRANSCEIVER_EVENTS group events.

Parameters
[out]event

Wi-Fi event of type sl_wifi_event_t. Individual Wi-Fi events related to SL_WIFI_TRANSCEIVER_EVENTS are as follows.

sl_wifi_event_t

SL_WIFI_TRANSCEIVER_RX_DATA_RECEIVE_CB

SL_WIFI_TRANSCEIVER_TX_DATA_STATUS_CB

[out]data
[out]data_length

Reserved

[out]optional_arg

Optional user provided argument passed in sl_wifi_set_transceiver_callback

Returns

Note

  • This API is only supported in Wi-Fi Transceiver opermode (7).

  • In case of event failure, SL_WIFI_FAIL_EVENT_STATUS_INDICATION bit is set in event, data will be of type sl_status_t and data_length can be ignored.


Definition at line 180 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

Function Documentation#

sl_wifi_set_callback#

sl_status_t sl_wifi_set_callback (sl_wifi_event_group_t group, sl_wifi_callback_function_t function, void *optional_arg)

Register a callback for selected event group.

Parameters
[in]group

group id of the event. See sl_wifi_event_group_t

[in]function

Function pointer to callback of type sl_wifi_callback_function_t

[in]optional_arg

Optional user provided argument. This will be passed back to callback handler of type sl_wifi_callback_function_t

All the individual Wi-Fi events related to specific group will be triggered via this group callback

  • Pre-conditions:

    • Pre-conditions:

    • Pre-conditions:

    • sl_wifi_init should be called before this API.

Returns

Note


Definition at line 204 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_default_event_handler#

sl_status_t sl_wifi_default_event_handler (sl_wifi_event_t event, sl_wifi_buffer_t *buffer)

Default Wi-Fi event handler to passed to sl_wifi_init.

Parameters
[in]event

Wi-Fi event of type of sl_wifi_event_t

[in]buffer

Buffer containing raw data from TA firmware

This function will dispatch Wi-Fi events and invokes respective Wi-Fi group event callback Returns

Note

  • Passing this event handler is optional. User can implement his own event dispatching framework.


Definition at line 218 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_set_scan_callback#

static sl_status_t sl_wifi_set_scan_callback (sl_wifi_scan_callback_t function, void *optional_arg)

Register callback for SL_WIFI_SCAN_RESULT_EVENTS group event from sl_wifi_event_group_t.

Parameters
[in]function

Optional user provided argument. This will be passed back to callback handler of type sl_wifi_scan_callback_t

N/Aoptional_arg
  • Pre-conditions:

    • Pre-conditions:

    • Pre-conditions:

    • sl_wifi_init should be called before this API.

Returns

Note

  • All the individual Wi-Fi events related to this group will be triggered via this callback


Definition at line 235 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_set_join_callback#

static sl_status_t sl_wifi_set_join_callback (sl_wifi_join_callback_t function, void *optional_arg)

Register callback for SL_WIFI_JOIN_EVENTS group event from sl_wifi_event_group_t.

Parameters
[in]function

Function pointer to callback. This will be passed back to callback handler of type sl_wifi_join_callback_t

[in]optional_arg

Optional user provided argument. This will be passed back to callback handler.

  • Pre-conditions:

    • Pre-conditions:

    • Pre-conditions:

    • sl_wifi_init should be called before this API.

Returns

Note

  • All the individual Wi-Fi events related to this group will be triggered via this callback


Definition at line 257 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_set_twt_config_callback#

static sl_status_t sl_wifi_set_twt_config_callback (sl_wifi_twt_config_callback_t function, void *optional_arg)

Register callback for SL_WIFI_TWT_RESPONSE_EVENTS group event from sl_wifi_event_group_t.

Parameters
[in]function

Function pointer to callback. This will be passed back to callback handler of type sl_wifi_twt_config_callback_t

[in]optional_arg

Optional user provided argument. This will be passed back to callback handler.

  • Pre-conditions:

    • Pre-conditions:

    • Pre-conditions:

    • sl_wifi_init should be called before this API.

Returns

Note

  • All the individual Wi-Fi events related to this group will be triggered via this callback.


Definition at line 279 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_set_stats_callback#

static sl_status_t sl_wifi_set_stats_callback (sl_wifi_stats_callback_t function, void *optional_arg)

Register callback for SL_WIFI_STATS_RESPONSE_EVENTS group event from sl_wifi_event_group_t.

Parameters
[in]function

Function pointer to callback. This will be passed back to callback handler of type sl_wifi_stats_callback_t

[in]optional_arg

Optional user provided argument. This will be passed back to callback handler.

  • Pre-conditions:

    • Pre-conditions:

    • Pre-conditions:

    • sl_wifi_init should be called before this API.

Returns

Note

  • All the individual Wi-Fi events related to this group will be triggered via this callback.


Definition at line 301 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

sl_wifi_set_transceiver_callback#

static sl_status_t sl_wifi_set_transceiver_callback (sl_wifi_transceiver_callback_t function, void *optional_arg)

Register callback for SL_WIFI_TRANSCEIVER_EVENTS group event from sl_wifi_event_group_t.

Parameters
[in]function

Function pointer to callback. This will be passed back to callback handler of type sl_wifi_transceiver_callback_t

[in]optional_arg

Optional user provided argument. This will be passed back to callback handler.

  • Pre-conditions:

Returns

Note

  • All the individual Wi-Fi events related to this group will be triggered via this callback.


Definition at line 320 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h

Macro Definition Documentation#

SL_WIFI_CHECK_IF_EVENT_FAILED#

#define SL_WIFI_CHECK_IF_EVENT_FAILED
Value:
(event)

Generic macro for callback functions to check if the event has Failed.


Definition at line 29 of file components/protocol/wifi/inc/sl_wifi_callback_framework.h