21
21
22
22
#include " silabs_utils.h"
23
23
#include " sl_status.h"
24
+ #include < app/icd/server/ICDServerConfig.h>
24
25
25
26
#include " FreeRTOS.h"
26
27
#include " event_groups.h"
@@ -39,9 +40,12 @@ extern "C" {
39
40
40
41
#include " ble_config.h"
41
42
42
- #if SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
43
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
43
44
#include " rsi_rom_power_save.h"
44
45
#include " sl_si91x_button_pin_config.h"
46
+ #if DISPLAY_ENABLED
47
+ #include " sl_memlcd.h"
48
+ #endif // DISPLAY_ENABLED
45
49
extern " C" {
46
50
#include " sl_si91x_driver.h"
47
51
#include " sl_si91x_m4_ps.h"
@@ -50,7 +54,7 @@ extern "C" {
50
54
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
51
55
#define BUTTON_PRESSED 1
52
56
bool btn0_pressed = false ;
53
- #endif // SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
57
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
54
58
55
59
#include " dhcp_client.h"
56
60
#include " wfx_host_events.h"
@@ -70,19 +74,14 @@ extern "C" {
70
74
#include " sl_wifi.h"
71
75
#include " sl_wifi_callback_framework.h"
72
76
#include " wfx_host_events.h"
73
- #if TINYCRYPT_PRIMITIVES
77
+ #if SLI_SI91X_MCU_INTERFACE
74
78
#include " sl_si91x_trng.h"
75
79
#define TRNGKEY_SIZE 4
76
- #endif // TINYCRYPT_PRIMITIVES
77
- }
80
+ #endif // SLI_SI91X_MCU_INTERFACE
81
+ } // extern "C" {
78
82
79
83
WfxRsi_t wfx_rsi;
80
84
81
- // TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
82
- #ifdef SLI_SI91X_MCU_INTERFACE
83
- volatile uint32_t watchdog_reset = 0 ;
84
- #endif // SLI_SI91X_MCU_INTERFACE
85
-
86
85
/* Declare a variable to hold the data associated with the created event group. */
87
86
StaticEventGroup_t rsiDriverEventGroup;
88
87
@@ -246,10 +245,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
246
245
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING);
247
246
if (SL_WIFI_CHECK_IF_EVENT_FAILED (event))
248
247
{
249
- SILABS_LOG (" F: Join Event received with %u bytes payload\n " , result_length);
250
248
callback_status = *(sl_status_t *) result;
249
+ SILABS_LOG (" join_callback_handler: failed: 0x%X" , callback_status);
251
250
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
252
- is_wifi_disconnection_event = true ;
253
251
wfx_retry_interval_handler (is_wifi_disconnection_event, wfx_rsi.join_retries ++);
254
252
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
255
253
{
@@ -262,26 +260,22 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
262
260
* Join was complete - Do the DHCP
263
261
*/
264
262
memset (&temp_reset, 0 , sizeof (wfx_wifi_scan_ext_t ));
265
- SILABS_LOG (" join_callback_handler: join completed." );
266
- SILABS_LOG (" %c: Join Event received with %u bytes payload\n " , *result, result_length);
263
+ SILABS_LOG (" join_callback_handler: success" );
267
264
268
265
WfxEvent.eventType = WFX_EVT_STA_CONN;
269
266
WfxPostEvent (&WfxEvent);
270
267
wfx_rsi.join_retries = 0 ;
271
268
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
272
- if (is_wifi_disconnection_event)
273
- {
274
- is_wifi_disconnection_event = false ;
275
- }
276
- callback_status = SL_STATUS_OK;
269
+ // Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
270
+ is_wifi_disconnection_event = true ;
271
+ callback_status = SL_STATUS_OK;
277
272
return SL_STATUS_OK;
278
273
}
279
274
280
- #if SL_ICD_ENABLED
281
-
282
- #if SI917_M4_SLEEP_ENABLED
275
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
276
+ #if SLI_SI91X_MCU_INTERFACE
283
277
// Required to invoke button press event during sleep as falling edge is not detected
284
- void invoke_btn_press_event ()
278
+ void sl_si91x_invoke_btn_press_event ()
285
279
{
286
280
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
287
281
if (!RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN) && !btn0_pressed)
@@ -295,36 +289,28 @@ void invoke_btn_press_event()
295
289
}
296
290
}
297
291
298
- /* *
299
- * @brief Checks if the Wi-Fi module is ready for sleep.
300
- *
301
- * This function checks if the Wi-Fi module is ready to enter sleep mode.
302
- *
303
- * @return true if the Wi-Fi module is ready for sleep, false otherwise.
304
- */
305
- bool wfx_is_sleep_ready ()
306
- {
307
- // BRD4002A board BTN_PRESS is 0 when pressed, release is 1
308
- // sli_si91x_is_sleep_ready requires OS Scheduler to be active
309
- return ((RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN) != 0 ) && (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) &&
310
- sli_si91x_is_sleep_ready ());
311
- }
312
-
313
- /* *
314
- * @brief Sleeps for a specified duration and then wakes up.
315
- *
316
- * This function puts the SI91x host into sleep mode for the specified duration
317
- * in milliseconds and then wakes it up.
318
- *
319
- * @param sleep_time_ms The duration in milliseconds to sleep.
320
- */
321
- void sl_wfx_host_si91x_sleep (uint16_t * sleep_time_ms)
292
+ /* *****************************************************************
293
+ * @fn sl_app_sleep_ready()
294
+ * @brief
295
+ * Called from the supress ticks from tickless to check if it
296
+ * is ok to go to sleep
297
+ * @param[in] None
298
+ * @return
299
+ * None
300
+ *********************************************************************/
301
+ uint32_t sl_app_sleep_ready ()
322
302
{
323
- SL_ASSERT (sleep_time_ms != NULL );
324
- sl_si91x_m4_sleep_wakeup (sleep_time_ms);
303
+ if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
304
+ {
305
+ #if DISPLAY_ENABLED
306
+ // Powering down the LCD
307
+ sl_memlcd_power_on (NULL , false );
308
+ #endif /* DISPLAY_ENABLED */
309
+ return true ;
310
+ }
311
+ return false ;
325
312
}
326
-
327
- #endif // SI917_M4_SLEEP_ENABLED
313
+ #endif // SLI_SI91X_MCU_INTERFACE
328
314
329
315
/* *****************************************************************
330
316
* @fn wfx_rsi_power_save()
@@ -363,7 +349,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
363
349
}
364
350
return status;
365
351
}
366
- #endif /* SL_ICD_ENABLED */
352
+ #endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
367
353
368
354
/* ************************************************************************************
369
355
* @fn static int32_t wfx_wifi_rsi_init(void)
@@ -378,13 +364,6 @@ int32_t wfx_wifi_rsi_init(void)
378
364
SILABS_LOG (" wfx_wifi_rsi_init started" );
379
365
sl_status_t status;
380
366
status = sl_wifi_init (&config, NULL , sl_wifi_default_event_handler);
381
- #ifdef SLI_SI91X_MCU_INTERFACE
382
- // TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
383
- if ((MCU_FSM->MCU_FSM_WAKEUP_STATUS_REG ) & BIT (5 ))
384
- {
385
- watchdog_reset++;
386
- }
387
- #endif // SLI_SI91X_MCU_INTERFACE
388
367
if (status != SL_STATUS_OK)
389
368
{
390
369
return status;
@@ -449,15 +428,15 @@ static sl_status_t wfx_rsi_init(void)
449
428
return status;
450
429
}
451
430
#else // For SoC
452
- #if SL_ICD_ENABLED
431
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
453
432
uint8_t xtal_enable = 1 ;
454
433
status = sl_si91x_m4_ta_secure_handshake (SL_SI91X_ENABLE_XTAL, 1 , &xtal_enable, 0 , NULL );
455
434
if (status != SL_STATUS_OK)
456
435
{
457
436
SILABS_LOG (" Failed to bring m4_ta_secure_handshake: 0x%lx\r\n " , status);
458
437
return status;
459
438
}
460
- #endif /* SL_ICD_ENABLED */
439
+ #endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
461
440
#endif /* SLI_SI91X_MCU_INTERFACE */
462
441
463
442
sl_wifi_firmware_version_t version = { 0 };
@@ -477,7 +456,7 @@ static sl_status_t wfx_rsi_init(void)
477
456
return status;
478
457
}
479
458
480
- #ifdef TINYCRYPT_PRIMITIVES
459
+ #ifdef SLI_SI91X_MCU_INTERFACE
481
460
const uint32_t trngKey[TRNGKEY_SIZE] = { 0x16157E2B , 0xA6D2AE28 , 0x8815F7AB , 0x3C4FCF09 };
482
461
483
462
// To check the Entropy of TRNG and verify TRNG functioning.
@@ -495,7 +474,7 @@ static sl_status_t wfx_rsi_init(void)
495
474
SILABS_LOG (" TRNG Key Programming Failed" );
496
475
return status;
497
476
}
498
- #endif // TINYCRYPT_PRIMITIVES
477
+ #endif // SLI_SI91X_MCU_INTERFACE
499
478
500
479
wfx_rsi.events = xEventGroupCreateStatic (&rsiDriverEventGroup);
501
480
wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
@@ -520,12 +499,13 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
520
499
{
521
500
if (SL_WIFI_CHECK_IF_EVENT_FAILED (event))
522
501
{
523
- callback_status = *(sl_status_t *) scan_result;
502
+ callback_status = *(sl_status_t *) scan_result;
503
+ SILABS_LOG (" scan_callback_handler: failed: 0x%X" , callback_status);
524
504
scan_results_complete = true ;
525
505
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
526
506
wfx_rsi.sec .security = WFX_SEC_WPA3;
527
507
#else
528
- wfx_rsi.sec .security = WFX_SEC_WPA2;
508
+ wfx_rsi.sec .security = WFX_SEC_WPA2;
529
509
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
530
510
531
511
osSemaphoreRelease (sScanSemaphore );
@@ -541,9 +521,9 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
541
521
break ;
542
522
case SL_WIFI_WPA:
543
523
case SL_WIFI_WPA_ENTERPRISE:
544
- case SL_WIFI_WPA_WPA2_MIXED:
545
524
wfx_rsi.sec .security = WFX_SEC_WPA;
546
525
break ;
526
+ case SL_WIFI_WPA_WPA2_MIXED:
547
527
case SL_WIFI_WPA2:
548
528
case SL_WIFI_WPA2_ENTERPRISE:
549
529
wfx_rsi.sec .security = WFX_SEC_WPA2;
@@ -556,7 +536,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
556
536
case SL_WIFI_WPA3:
557
537
wfx_rsi.sec .security = WFX_SEC_WPA3;
558
538
#else
559
- wfx_rsi.sec .security = WFX_SEC_WPA2;
539
+ wfx_rsi.sec .security = WFX_SEC_WPA2;
560
540
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
561
541
break ;
562
542
default :
@@ -661,14 +641,18 @@ static sl_status_t wfx_rsi_do_join(void)
661
641
connect_security_mode = SL_WIFI_WEP;
662
642
break ;
663
643
case WFX_SEC_WPA:
664
- case WFX_SEC_WPA2:
665
644
connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
666
645
break ;
646
+ case WFX_SEC_WPA2:
667
647
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
648
+ connect_security_mode = SL_WIFI_WPA3_TRANSITION;
649
+ break ;
668
650
case WFX_SEC_WPA3:
669
651
connect_security_mode = SL_WIFI_WPA3_TRANSITION;
652
+ #else
653
+ connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
654
+ #endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION
670
655
break ;
671
- #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION*/
672
656
case WFX_SEC_NONE:
673
657
connect_security_mode = SL_WIFI_OPEN;
674
658
break ;
@@ -695,14 +679,14 @@ static sl_status_t wfx_rsi_do_join(void)
695
679
696
680
sl_wifi_set_join_callback (join_callback_handler, NULL );
697
681
698
- #if SL_ICD_ENABLED
682
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
699
683
// Setting the listen interval to 0 which will set it to DTIM interval
700
684
sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 };
701
685
status = sl_wifi_set_listen_interval (SL_WIFI_CLIENT_INTERFACE, sleep_interval);
702
686
703
687
sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
704
688
sl_wifi_set_advanced_client_configuration (SL_WIFI_CLIENT_INTERFACE, &client_config);
705
- #endif // SL_ICD_ENABLED
689
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
706
690
/* Try to connect Wifi with given Credentials
707
691
* untill there is a success or maximum number of tries allowed
708
692
*/
@@ -1006,47 +990,3 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
1006
990
wfx_rsi.dev_state |= WFX_RSI_ST_STA_READY;
1007
991
}
1008
992
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
1009
-
1010
- /* *******************************************************************************************
1011
- * @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off)
1012
- * @brief
1013
- * add the data into packet
1014
- * @param[in] p:
1015
- * @param[in] buf:
1016
- * @param[in] len:
1017
- * @param[in] off:
1018
- * @return
1019
- * None
1020
- **********************************************************************************************/
1021
- void wfx_rsi_pkt_add_data (void * p, uint8_t * buf, uint16_t len, uint16_t off)
1022
- {
1023
- sl_si91x_packet_t * pkt;
1024
- pkt = (sl_si91x_packet_t *) p;
1025
- memcpy (((char *) pkt->data ) + off, buf, len);
1026
- }
1027
-
1028
- #if !EXP_BOARD
1029
- /* *******************************************************************************************
1030
- * @fn int32_t wfx_rsi_send_data(void *p, uint16_t len)
1031
- * @brief
1032
- * Driver send a data
1033
- * @param[in] p:
1034
- * @param[in] len:
1035
- * @return
1036
- * None
1037
- **********************************************************************************************/
1038
- int32_t wfx_rsi_send_data (void * p, uint16_t len)
1039
- {
1040
- int32_t status;
1041
- sl_wifi_buffer_t * buffer;
1042
- buffer = (sl_wifi_buffer_t *) p;
1043
-
1044
- if (sl_si91x_driver_send_data_packet (SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME))
1045
- {
1046
- SILABS_LOG (" *ERR*EN-RSI:Send fail" );
1047
- return ERR_IF;
1048
- }
1049
- return status;
1050
- }
1051
-
1052
- #endif
0 commit comments