Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SILABS] [RS917] Added support for Wi-Fi SDK 3.1.0 for 917 NCP #28943

Merged
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0d3a72e
Added changes for 917 NCP brignup
shgutte Aug 8, 2023
934d23a
Added changes for 917 ncp
shgutte Aug 8, 2023
6b128c0
Resolved build errors for 917 NCP
bhmanda-silabs Aug 9, 2023
e7a13a4
Resolved build errors for 917 NCP
bhmanda-silabs Aug 9, 2023
0f93645
added changes in efr32_sdk.gni for wifi sdk
bhmanda-silabs Aug 9, 2023
d128bf9
Build errors resolved
bhmanda-silabs Aug 9, 2023
e6d0d68
Fixed NCP build errors
bhmanda-silabs Aug 9, 2023
8703929
Added fix for sl wifi init
bhmanda-silabs Aug 11, 2023
55d61ad
Added BLE defines in efr32_sdk.gni
bhmanda-silabs Aug 11, 2023
2ffa513
Added changes for the 917 NCP
shgutte Aug 18, 2023
75024fd
Added changes 917 NCP
shgutte Aug 22, 2023
bd735f0
Added chnages for NCP rx buffer
shgutte Aug 28, 2023
63c3af3
changes for 917 NCP mode
shgutte Aug 29, 2023
d58dad9
Updated wifi sdk commit
shgutte Aug 29, 2023
5ac7537
removed the commented code
shgutte Aug 29, 2023
5a1aa25
Removed the commented code and required changes for SDk 3.0
shgutte Aug 30, 2023
d7662b2
Merge branch 'master' of https://github.com/project-chip/connectedhom…
shgutte Aug 30, 2023
7269e98
Added changes for RS9116 build
shgutte Aug 31, 2023
b6f9282
Added fix for RS9116 build issue
shgutte Aug 31, 2023
5eb7794
Removed the unused code
shgutte Sep 1, 2023
fde6f95
Fixed warning changes for the 917 ncp
shgutte Sep 1, 2023
5a60ced
Added licence for the file
shgutte Sep 1, 2023
0a493b8
Merge branch 'master' of https://github.com/project-chip/connectedhom…
shgutte Sep 4, 2023
e48741d
Merge branch 'master' of https://github.com/project-chip/connectedhom…
shgutte Sep 5, 2023
7f6a3ea
Added changes for the SOC and NCP
shgutte Sep 5, 2023
06c49ea
Removed the sl_wifi_if duplicate file
shgutte Sep 7, 2023
1c3b7c8
Added changes related to efr32_sdk
shgutte Sep 7, 2023
7fd0c16
Added changes for define
shgutte Sep 7, 2023
ad8a2b9
Added changes for rs9116 and SOC error
shgutte Sep 7, 2023
94e9181
Added wifi component for 917 NCP
shgutte Sep 8, 2023
5c041a4
Fixeed the hardfault for 917 NCP
shgutte Sep 12, 2023
333f965
Removed EFR32 MG12 for the SI917
shgutte Sep 12, 2023
1ebe2f5
Restyled by whitespace
restyled-commits Sep 12, 2023
d070155
Added changes for the comments
shgutte Sep 12, 2023
c6bd8a5
Added chnages for sdk 3.1.0
shgutte Sep 14, 2023
e3469dd
Adds wifi-sdk 3.1.0 and required changes for it
silabs-srishylam Sep 13, 2023
6bc8d39
Added SOC and Common flash fixes
shgutte Sep 15, 2023
d251ac9
Added changes for retyle commit
shgutte Sep 18, 2023
dd51bfb
Added restyle changes
shgutte Sep 18, 2023
d696a13
Added changes for the third party silabs sdk
shgutte Sep 18, 2023
c09210f
Restyled by gn
restyled-commits Sep 18, 2023
10a7122
Merge branch 'master' of https://github.com/project-chip/connectedhom…
shgutte Sep 18, 2023
1d1cbcc
Added changes for the rs9117 NCP file
shgutte Sep 18, 2023
e015daf
Added changes according to CSA comment
shgutte Sep 18, 2023
a55a75d
Restyled by gn
restyled-commits Sep 18, 2023
3a7cf30
Added func return type
shgutte Sep 18, 2023
995bb23
Added micro changes for the command buffer time
shgutte Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 84 additions & 72 deletions examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "task.h"
#include "wfx_host_events.h"

#include "rsi_ble_config.h"
#include "ble_config.h"

#include "dhcp_client.h"
#include "lwip/nd6.h"
Expand Down Expand Up @@ -66,7 +66,7 @@ bool is_wifi_disconnection_event = false;
/* Declare a variable to hold connection time intervals */
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
volatile bool scan_results_complete = false;
#define WIFI_SCAN_TIMEOUT 10000 // WiFi Scan interval
#define WIFI_SCAN_TIMEOUT_TICK 10000

extern osSemaphoreId_t sl_rs_ble_init_sem;

Expand All @@ -89,13 +89,12 @@ volatile sl_status_t callback_status = SL_STATUS_OK;
int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap)
{
sl_status_t status = SL_STATUS_OK;
uint8_t rssi = 0;
int32_t rssi = 0;
ap->security = wfx_rsi.sec.security;
ap->chan = wfx_rsi.ap_chan;
memcpy(&ap->bssid[0], &wfx_rsi.ap_mac.octet[0], BSSID_MAX_STR_LEN);
sl_wifi_get_signal_strength(SL_WIFI_CLIENT_INTERFACE, &rssi);
ap->rssi = rssi;

return status;
}

Expand Down Expand Up @@ -182,12 +181,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
/*
* Join was complete - Do the DHCP
*/
SILABS_LOG("Join Completed %c: Join Event received with %u bytes payload\n", *result, result_length);
SILABS_LOG("join_callback_handler: join completed.");
SILABS_LOG("%c: Join Event received with %u bytes payload\n", *result, result_length);
xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_CONN);
wfx_rsi.join_retries = 0;
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
if (is_wifi_disconnection_event)
is_wifi_disconnection_event = false;
callback_status = SL_STATUS_OK;
return SL_STATUS_OK;
}
Expand Down Expand Up @@ -234,12 +230,12 @@ int32_t wfx_rsi_power_save()
*****************************************************************************************/
int32_t wfx_wifi_rsi_init(void)
{
SILABS_LOG("wfx_wifi_rsi_init started");
sl_status_t status;
status = sl_wifi_init(&config, default_wifi_event_handler);
if (status != SL_STATUS_OK)
{
SILABS_LOG("wfx_wifi_rsi_init failed %x", status);
return status;
}
return status;
jmartinez-silabs marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -252,9 +248,19 @@ int32_t wfx_wifi_rsi_init(void)
* @return
* None
*****************************************************************************************/
static int32_t wfx_rsi_init(void)
static sl_status_t wfx_rsi_init(void)
{
sl_status_t status;

#ifndef RSI_M4_INTERFACE
status = wfx_wifi_rsi_init();
if (status != SL_STATUS_OK)
{
SILABS_LOG("wfx_rsi_init failed %x", status);
return status;
}
#endif

status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, (sl_mac_address_t *) &wfx_rsi.sta_mac.octet[0]);
if (status != SL_STATUS_OK)
{
Expand All @@ -269,13 +275,18 @@ static int32_t wfx_rsi_init(void)
}

/*************************************************************************************
* @fn sl_status_t scan_callback_handler
* @fn void wfx_show_err(char *msg)
* @brief
* scan callback handler
* driver shows error message
* @param[in] msg
* @return
* sl_status_t
* None
*****************************************************************************************/
void wfx_show_err(char * msg)
{
SILABS_LOG("wfx_show_err: message: %d", msg);
}

sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_result, uint32_t result_length, void * arg)
{
if (CHECK_IF_EVENT_FAILED(event))
Expand All @@ -291,7 +302,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
}
wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED;
wfx_rsi.ap_chan = scan_result->scan_info[0].rf_channel;
memcpy(&wfx_rsi.ap_mac.octet[0], scan_result->scan_info[0].bssid[0], BSSID_MAX_STR_LEN);
memcpy(&wfx_rsi.ap_mac.octet, scan_result->scan_info[0].bssid, BSSID_MAX_STR_LEN);
switch (scan_result->scan_info[0].security_mode)
{
case SL_WIFI_OPEN:
Expand Down Expand Up @@ -323,26 +334,16 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
scan_results_complete = true;
return SL_STATUS_OK;
}

/*************************************************************************************
* @fn sl_status_t show_scan_results
* @brief
* driver shows scan results
* @param[in] msg
* @return
* sl_status_t
*****************************************************************************************/
sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
{
ARGS_CHECK_NULL_POINTER(scan_result);
int x;
wfx_wifi_scan_result_t ap;
if (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED)
{
for (x = 0; x < scan_result->scan_count; x++)
for (x = 0; x < (int) scan_result->scan_count; x++)
{
strcpy(&ap.ssid[0], (char *) &scan_result->scan_info[x].ssid);
uint8_t * bssid = (uint8_t *) &scan_result->scan_info[x].bssid;
if (wfx_rsi.scan_ssid)
{
SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid);
Expand Down Expand Up @@ -373,15 +374,6 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
}
return SL_STATUS_OK;
}

/*************************************************************************************
* @fn bg_scan_callback_handler
* @brief
* scan for wifi events in background
* @param[in]
* @return
* SL_STATUS_OK
*****************************************************************************************/
sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * result, uint32_t result_length, void * arg)
{
callback_status = show_scan_results(result);
Expand Down Expand Up @@ -409,13 +401,12 @@ static void wfx_rsi_save_ap_info() // translation
if (SL_STATUS_IN_PROGRESS == status)
{
const uint32_t start = osKernelGetTickCount();
while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT)
while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK)
{
osThreadYield();
}
status = scan_results_complete ? callback_status : SL_STATUS_TIMEOUT;
}
return status;
}

/********************************************************************************************
Expand All @@ -425,9 +416,9 @@ static void wfx_rsi_save_ap_info() // translation
* @return
* None
**********************************************************************************************/
static void wfx_rsi_do_join(void)
static sl_status_t wfx_rsi_do_join(void)
{
int32_t status;
sl_status_t status = SL_STATUS_OK;
sl_wifi_security_t connect_security_mode;
switch (wfx_rsi.sec.security)
{
Expand All @@ -445,8 +436,8 @@ static void wfx_rsi_do_join(void)
connect_security_mode = SL_WIFI_OPEN;
break;
default:
SILABS_LOG("%s: error: unknown security type.");
return;
SILABS_LOG("error: unknown security type.");
return status;
}

if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED))
Expand All @@ -466,12 +457,7 @@ static void wfx_rsi_do_join(void)
*/
wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTING;

status = sl_wifi_set_join_callback(join_callback_handler, NULL);
if (SL_STATUS_OK != status)
{
SILABS_LOG(" Set Join Callback fail ");
return status;
}
sl_wifi_set_join_callback(join_callback_handler, NULL);

/* Try to connect Wifi with given Credentials
* untill there is a success or maximum number of tries allowed
Expand All @@ -487,6 +473,7 @@ static void wfx_rsi_do_join(void)
status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey));
if (SL_STATUS_OK != status)
{
SILABS_LOG("wfx_rsi_do_join: RSI callback register join failed with status: %02x", status);
return status;
}

Expand All @@ -509,21 +496,18 @@ static void wfx_rsi_do_join(void)
}
else
{
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
while (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
{
SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries);
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0],
wfx_rsi.join_retries);
wfx_rsi.join_retries += 1;
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
if (wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT)
{
xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
}
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
}
}
}
return status;
}

/*********************************************************************************
Expand All @@ -543,18 +527,18 @@ void wfx_rsi_task(void * arg)
TickType_t last_dhcp_poll, now;
struct netif * sta_netif;
(void) arg;
uint32_t rsi_status = wfx_rsi_init();
if (rsi_status != RSI_SUCCESS)
sl_status_t status = wfx_rsi_init();
if (status != RSI_SUCCESS)
{
SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status);
SILABS_LOG("wfx_rsi_task: error: wfx_rsi_init with status: %02x", status);
return;
}
wfx_lwip_start();
last_dhcp_poll = xTaskGetTickCount();
sta_netif = wfx_get_netif(SL_WFX_STA_INTERFACE);
wfx_started_notify();

SILABS_LOG("%s: starting event wait", __func__);
SILABS_LOG("wfx_rsi_task: starting event wait");
for (;;)
{
/*
Expand Down Expand Up @@ -604,6 +588,14 @@ void wfx_rsi_task(void * arg)
hasNotifiedIPV4 = false;
}
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
/*
* Checks if the IPv6 event has been notified, if not invoke the nd6_tmr,
* which starts the duplicate address detectation.
*/
if (!hasNotifiedIPV6)
{
nd6_tmr();
}
/* Checks if the assigned IPv6 address is preferred by evaluating
* the first block of IPv6 address ( block 0)
*/
Expand All @@ -625,7 +617,7 @@ void wfx_rsi_task(void * arg)
// saving the AP related info
wfx_rsi_save_ap_info();
// Joining to the network
wfx_rsi_do_join();
status = wfx_rsi_do_join();
}
if (flags & WFX_EVT_STA_CONN)
{
Expand Down Expand Up @@ -664,9 +656,8 @@ void wfx_rsi_task(void * arg)
if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED))
{
SILABS_LOG("%s: start SSID scan", __func__);
int x;
sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 };
wfx_wifi_scan_result_t ap;

// TODO: Add scan logic
sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 };
int32_t status;
Expand All @@ -676,23 +667,16 @@ void wfx_rsi_task(void * arg)
advanced_scan_configuration.trigger_level_change = ADV_RSSI_TOLERANCE_THRESHOLD;
advanced_scan_configuration.enable_multi_probe = ADV_MULTIPROBE;
status = sl_wifi_set_advanced_scan_configuration(&advanced_scan_configuration);
VERIFY_STATUS_AND_RETURN(status);
/* Terminate with end of scan which is no ap sent back */
wifi_scan_configuration.type = SL_WIFI_SCAN_TYPE_ADV_SCAN;
wifi_scan_configuration.periodic_scan_interval = ADV_SCAN_PERIODICITY;

status = sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL);
if (SL_STATUS_OK != status)
{
return status;
}

sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL);
status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, NULL, &wifi_scan_configuration);
if (SL_STATUS_IN_PROGRESS == status)
{
printf("Scanning...\r\n");
const uint32_t start = osKernelGetTickCount();
while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT)
while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK)
{
osThreadYield();
}
Expand Down Expand Up @@ -740,6 +724,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
}
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */

#if !EXP_BOARD
/*
* WARNING - Taken from RSI and broken up
* This is my own RSI stuff for not copying code and allocating an extra
Expand All @@ -763,13 +748,14 @@ void * wfx_rsi_alloc_pkt(uint16_t data_length)
/* Confirm if packet is allocated */

status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + data_length,
SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME);
SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS);
if (packet == NULL)
{
return SL_STATUS_ALLOCATION_FAILED;
}
return (void *) packet;
}
#endif

/********************************************************************************************
* @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off)
Expand All @@ -788,3 +774,29 @@ void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off)
pkt = (sl_si91x_packet_t *) p;
memcpy(((char *) pkt->data) + off, buf, len);
}

#if !EXP_BOARD
/********************************************************************************************
* @fn int32_t wfx_rsi_send_data(void *p, uint16_t len)
* @brief
* Driver send a data
* @param[in] p:
* @param[in] len:
* @return
* None
**********************************************************************************************/
int32_t wfx_rsi_send_data(void * p, uint16_t len)
{
int32_t status;
sl_wifi_buffer_t * buffer;
buffer = (sl_wifi_buffer_t *) p;

if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME))
{
SILABS_LOG("*ERR*EN-RSI:Send fail");
return ERR_IF;
}
return status;
}

#endif
5 changes: 4 additions & 1 deletion examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ if (chip_enable_wifi) {
assert(use_rs9116 || use_wf200 || use_SiWx917)
import("${chip_root}/src/platform/silabs/wifi_args.gni")

if (use_rs9116 || use_SiWx917) {
if (use_rs9116) {
wiseconnect_sdk_root =
"${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk"
import("rs911x/rs911x.gni")
} else if (use_SiWx917) {
wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk"
import("rs911x/rs9117.gni")
}
if (use_wf200) {
import("wf200/wf200.gni")
Expand Down
Loading