|
44 | 44 | #if SL_ICD_ENABLED && SIWX_917
|
45 | 45 | #include "rsi_rom_power_save.h"
|
46 | 46 | #include "sl_si91x_button_pin_config.h"
|
| 47 | +#include "sl_si91x_driver.h" |
47 | 48 | #include "sl_si91x_m4_ps.h"
|
48 | 49 |
|
49 | 50 | // TODO: should be removed once we are getting the press interrupt for button 0 with sleep
|
@@ -188,8 +189,8 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
|
188 | 189 | SILABS_LOG("F: Join Event received with %u bytes payload\n", result_length);
|
189 | 190 | callback_status = *(sl_status_t *) result;
|
190 | 191 | wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
|
191 |
| - wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); |
192 | 192 | is_wifi_disconnection_event = true;
|
| 193 | + wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); |
193 | 194 | if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
|
194 | 195 | {
|
195 | 196 | xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
|
@@ -256,28 +257,36 @@ void sl_wfx_host_si91x_sleep_wakeup()
|
256 | 257 | * @brief
|
257 | 258 | * Setting the RS911x in DTIM sleep based mode
|
258 | 259 | *
|
259 |
| - * @param[in] None |
| 260 | + * @param[in] sl_si91x_ble_state : State to set for the BLE |
| 261 | + sl_si91x_wifi_state : State to set for the WiFi |
260 | 262 | * @return
|
261 | 263 | * None
|
262 | 264 | *********************************************************************/
|
263 |
| -int32_t wfx_rsi_power_save() |
| 265 | +int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state) |
264 | 266 | {
|
265 | 267 | int32_t status;
|
266 |
| - status = rsi_bt_power_save_profile(2, 0); |
| 268 | + |
| 269 | + status = rsi_bt_power_save_profile(sl_si91x_ble_state, 0); |
267 | 270 | if (status != RSI_SUCCESS)
|
268 | 271 | {
|
269 | 272 | SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status);
|
270 | 273 | return status;
|
271 | 274 | }
|
272 |
| - |
273 |
| - sl_wifi_performance_profile_t wifi_profile = { .profile = ASSOCIATED_POWER_SAVE }; |
| 275 | + sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state }; |
274 | 276 | status = sl_wifi_set_performance_profile(&wifi_profile);
|
275 | 277 | if (status != RSI_SUCCESS)
|
276 | 278 | {
|
277 | 279 | SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status);
|
278 | 280 | return status;
|
279 | 281 | }
|
280 |
| - wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY; |
| 282 | + if (sl_si91x_wifi_state == HIGH_PERFORMANCE) |
| 283 | + { |
| 284 | + wfx_rsi.dev_state &= ~(WFX_RSI_ST_SLEEP_READY); |
| 285 | + } |
| 286 | + else |
| 287 | + { |
| 288 | + wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY; |
| 289 | + } |
281 | 290 | return status;
|
282 | 291 | }
|
283 | 292 | #endif /* SL_ICD_ENABLED */
|
@@ -376,7 +385,7 @@ static sl_status_t wfx_rsi_init(void)
|
376 | 385 | }
|
377 | 386 |
|
378 | 387 | // Initiate and program the key required for TRNG hardware engine
|
379 |
| - status = sl_si91x_trng_program_key(trngKey, TRNGKEY_SIZE); |
| 388 | + status = sl_si91x_trng_program_key((uint32_t *) trngKey, TRNGKEY_SIZE); |
380 | 389 | if (status != SL_STATUS_OK)
|
381 | 390 | {
|
382 | 391 | SILABS_LOG("TRNG Key Programming Failed");
|
@@ -581,10 +590,14 @@ static sl_status_t wfx_rsi_do_join(void)
|
581 | 590 |
|
582 | 591 | sl_wifi_set_join_callback(join_callback_handler, NULL);
|
583 | 592 |
|
| 593 | +#if SL_ICD_ENABLED |
584 | 594 | // Setting the listen interval to 0 which will set it to DTIM interval
|
585 | 595 | sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 };
|
586 | 596 | status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval);
|
587 | 597 |
|
| 598 | + sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 }; |
| 599 | + sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config); |
| 600 | +#endif // SL_ICD_ENABLED |
588 | 601 | /* Try to connect Wifi with given Credentials
|
589 | 602 | * untill there is a success or maximum number of tries allowed
|
590 | 603 | */
|
@@ -629,11 +642,11 @@ static sl_status_t wfx_rsi_do_join(void)
|
629 | 642 | wfx_rsi.join_retries);
|
630 | 643 | wfx_rsi.join_retries += 1;
|
631 | 644 | wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
|
| 645 | + wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries); |
632 | 646 | if (is_wifi_disconnection_event || wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT)
|
633 | 647 | {
|
634 | 648 | xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN);
|
635 | 649 | }
|
636 |
| - wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries); |
637 | 650 | }
|
638 | 651 | }
|
639 | 652 | }
|
|
0 commit comments