Migration Example#

This section provides an example of rewriting a WiSeConnect SDK v2.x Wi-Fi Access Point (AP) application with the v3.x API.

Some code, such as that for event handlers, is omitted for brevity.

In the example below:

  • In the main() function, we replaced the v2.x rsi_task_create() and rsi_start_os_scheduler() API calls with the FreeRTOS osThreadNew() API call, to create a new FreeRTOS task to run the application.

  • In the initialization function, we replaced the v2.x rsi_driver_init(), rsi_wlan_register_callbacks(), rsi_task_create(), and rsi_wireless_init() API calls with the v3.x sl_net_init() API call, to initialize the WiSeConnect SDK and SiWx917 device.

  • In the initialization function, we replaced the v2.x rsi_config_ipaddress() and rsi_wlan_ap_start() API calls with the v3.x sl_net_up() API call, to start the wireless access point and configure its IP address.

v2.x API Code

v3.x API Code

int32_t application_start() {

static void application_start(void *argument) {

int32_t status = rsi_driver_init(global_buf, GLOBAL_BUF_LEN);

sl_status_t status = sl_net_init(SL_NET_DEFAULT_WIFI_AP_INTERFACE, NULL, NULL, ap_event_handler);

rsi_wlan_register_callbacks(RSI_STATIONS_CONNECT_NOTIFY_CB, stations_connect_notify_handler);

rsi_wlan_register_callbacks(RSI_STATIONS_DISCONNECT_NOTIFY_CB, stations_disconnect_notify_handler);

status = rsi_device_init(LOAD_NWP_FW);

rsi_task_handle_t driver_task_handle = NULL;

rsi_task_create((rsi_task_function_t) rsi_wireless_driver_task, (uint8_t) "driver_task", RSI_DRIVER_TASK_STACK_SIZE, NULL, RSI_DRIVER_TASK_PRIORITY), &driver_task_handle);

status = rsi_wireless_init(6, 0);

status = rsi_config_ipaddress(RSI_IP_VERSION_4, RSI_STATIC, (uint8_t *) &ip_addr, (uint8_t *) &network_mask, (uint8_t *) &gateway, NULL, 0, 0);

status = sl_net_up(SL_NET_DEFAULT_WIFI_AP_INTERFACE, SL_NET_DEFAULT_WIFI_AP_PROFILE);

status = rsi_wlan_ap_start((int8_t *) SSID, CHANNEL_NO, SECURITY_TYPE, ENCRYPTION_TYPE, (uint8_t *) PSK, BEACON_INTERVAL, DTIM_INTERVAL);

while(1) { osDelay(osWaitForever); }

}

}

int main() {

void main(const void *unused) {

rsi_task_handle_t wlan_task_handle = NULL;

UNUSED_PARAMETER(unused);

rsi_task_create((rsi_task_function_t) application_start, (uint8_t *) "wlan_task", RSI_WLAN_TASK_STACK_SIZE, NULL, RSI_WLAN_TASK_PRIORITY, &wlan_task_handle);

osThreadNew((osThreadFunc_t) application_start, NULL,, &thread_attributes);

rsi_os_start_scheduler();

}

}