@@ -100,16 +100,11 @@ bool ps_requirement_added = false;
100
100
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
101
101
102
102
bool hasNotifiedWifiConnectivity = false ;
103
- bool hasNotifiedIPV6 = false ;
104
- #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
105
- bool hasNotifiedIPV4 = false ;
106
- #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
107
103
108
104
wfx_wifi_scan_ext_t temp_reset;
109
105
110
106
osSemaphoreId_t sScanCompleteSemaphore ;
111
107
osSemaphoreId_t sScanInProgressSemaphore ;
112
- osTimerId_t sDHCPTimer ;
113
108
osMessageQueueId_t sWifiEventQueue = nullptr ;
114
109
115
110
sl_net_wifi_lwip_context_t wifi_client_context;
@@ -208,27 +203,6 @@ constexpr uint8_t kWfxQueueSize = 10;
208
203
// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
209
204
constexpr uint16_t kWifiScanTimeoutTicks = 10000 ;
210
205
211
- void DHCPTimerEventHandler (void * arg)
212
- {
213
- WifiEvent event = WifiEvent::kStationDhcpPoll ;
214
- sl_matter_wifi_post_event (event);
215
- }
216
-
217
- void CancelDHCPTimer (void )
218
- {
219
- VerifyOrReturn (osTimerIsRunning (sDHCPTimer ), ChipLogDetail (DeviceLayer, " CancelDHCPTimer: timer not running" ));
220
- VerifyOrReturn (osTimerStop (sDHCPTimer ) == osOK, ChipLogError (DeviceLayer, " CancelDHCPTimer: failed to stop timer" ));
221
- }
222
-
223
- void StartDHCPTimer (uint32_t timeout)
224
- {
225
- // Cancel timer if already started
226
- CancelDHCPTimer ();
227
-
228
- VerifyOrReturn (osTimerStart (sDHCPTimer , pdMS_TO_TICKS (timeout)) == osOK,
229
- ChipLogError (DeviceLayer, " StartDHCPTimer: failed to start timer" ));
230
- }
231
-
232
206
sl_status_t sl_wifi_siwx917_init (void )
233
207
{
234
208
sl_status_t status = SL_STATUS_OK;
@@ -357,7 +331,10 @@ sl_status_t SetWifiConfigurations()
357
331
VerifyOrReturnError (status == SL_STATUS_OK, status,
358
332
ChipLogError (DeviceLayer, " sl_wifi_set_listen_interval failed: 0x%lx" , status));
359
333
360
- sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
334
+ // This is be triggered on the disconnect use case, providing the amount of TA tries
335
+ // Setting the TA retry to 1 and giving the control to the M4 for improved power efficiency
336
+ // When max_retry_attempts is set to 0, TA will retry indefinitely.
337
+ sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 1 };
361
338
status = sl_wifi_set_advanced_client_configuration (SL_WIFI_CLIENT_INTERFACE, &client_config);
362
339
VerifyOrReturnError (status == SL_STATUS_OK, status,
363
340
ChipLogError (DeviceLayer, " sl_wifi_set_advanced_client_configuration failed: 0x%lx" , status));
@@ -514,11 +491,6 @@ sl_status_t sl_matter_wifi_platform_init(void)
514
491
sWifiEventQueue = osMessageQueueNew (kWfxQueueSize , sizeof (WifiEvent), nullptr );
515
492
VerifyOrReturnError (sWifiEventQueue != nullptr , SL_STATUS_ALLOCATION_FAILED);
516
493
517
- // Create timer for DHCP polling
518
- // TODO: Use LWIP timer instead of creating a new one here
519
- sDHCPTimer = osTimerNew (DHCPTimerEventHandler, osTimerPeriodic, nullptr , nullptr );
520
- VerifyOrReturnError (sDHCPTimer != nullptr , SL_STATUS_ALLOCATION_FAILED);
521
-
522
494
return status;
523
495
}
524
496
@@ -662,53 +634,29 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
662
634
663
635
// / NotifyConnectivity
664
636
// / @brief Notify the application about the connectivity status if it has not been notified yet.
665
- // / Helper function for HandleDHCPPolling.
666
637
void NotifyConnectivity (void )
667
638
{
668
639
VerifyOrReturn (!hasNotifiedWifiConnectivity);
669
640
wfx_connected_notify (CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac );
670
641
hasNotifiedWifiConnectivity = true ;
671
642
}
672
643
673
- void HandleDHCPPolling (void )
644
+ // / NotifySuccessfulConnection
645
+ // / @brief Processing function responsible for notifying the upper layers of a succesful connection attempt.
646
+ void NotifySuccessfulConnection (void )
674
647
{
675
- WifiEvent event;
676
-
677
- // TODO: Notify the application that the interface is not set up or Chipdie here because we are in an unkonwn state
678
648
struct netif * sta_netif = &wifi_client_context.netif ;
679
649
VerifyOrReturn (sta_netif != nullptr , ChipLogError (DeviceLayer, " HandleDHCPPolling: failed to get STA netif" ));
680
-
681
650
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
682
- uint8_t dhcp_state = dhcpclient_poll (sta_netif);
683
- if (dhcp_state == DHCP_ADDRESS_ASSIGNED && !hasNotifiedIPV4)
684
- {
685
- wfx_dhcp_got_ipv4 ((uint32_t ) sta_netif->ip_addr .u_addr .ip4 .addr );
686
- hasNotifiedIPV4 = true ;
687
- event = WifiEvent::kStationDhcpDone ;
688
- sl_matter_wifi_post_event (event);
689
- NotifyConnectivity ();
690
- }
691
- else if (dhcp_state == DHCP_OFF)
692
- {
693
- wfx_ip_changed_notify (IP_STATUS_FAIL);
694
- hasNotifiedIPV4 = false ;
695
- }
651
+ wfx_dhcp_got_ipv4 ((uint32_t ) sta_netif->ip_addr .u_addr .ip4 .addr );
696
652
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
697
- /* Checks if the assigned IPv6 address is preferred by evaluating
698
- * the first block of IPv6 address ( block 0)
699
- */
700
- if ((ip6_addr_ispreferred (netif_ip6_addr_state (sta_netif, 0 ))) && !hasNotifiedIPV6)
701
- {
702
- char addrStr[chip::Inet::IPAddress::kMaxStringLength ] = { 0 };
703
- VerifyOrReturn (ip6addr_ntoa_r (netif_ip6_addr (sta_netif, 0 ), addrStr, sizeof (addrStr)) != nullptr );
704
- ChipLogProgress (DeviceLayer, " SLAAC OK: linklocal addr: %s" , addrStr);
705
- wfx_ipv6_notify (GET_IPV6_SUCCESS);
706
- hasNotifiedIPV6 = true ;
707
- event = WifiEvent::kStationDhcpDone ;
708
- sl_matter_wifi_post_event (event);
709
- NotifyConnectivity ();
710
- }
653
+ char addrStr[chip::Inet::IPAddress::kMaxStringLength ] = { 0 };
654
+ VerifyOrReturn (ip6addr_ntoa_r (netif_ip6_addr (sta_netif, 0 ), addrStr, sizeof (addrStr)) != nullptr );
655
+ ChipLogProgress (DeviceLayer, " SLAAC OK: linklocal addr: %s" , addrStr);
656
+ wfx_ipv6_notify (GET_IPV6_SUCCESS);
657
+ NotifyConnectivity ();
711
658
}
659
+
712
660
void sl_matter_wifi_post_event (WifiEvent event)
713
661
{
714
662
sl_status_t status = osMessageQueuePut (sWifiEventQueue , &event, 0 , 0 );
@@ -720,19 +668,14 @@ void sl_matter_wifi_post_event(WifiEvent event)
720
668
// Chipdie, etc.
721
669
}
722
670
}
723
- // / ResetDHCPNotificationFlags
671
+ // / ResetConnectivityNotificationFlags
724
672
// / @brief Reset the flags that are used to notify the application about DHCP connectivity
725
- // / and emits a WifiEvent::kStationDoDhcp event to trigger DHCP polling checks. Helper function for ProcessEvent.
726
- void ResetDHCPNotificationFlags (void )
673
+ // / and emits a WifiEvent::kConnectionComplete event to trigger DHCP polling checks. Helper function for ProcessEvent.
674
+ void ResetConnectivityNotificationFlags (void )
727
675
{
728
-
729
- #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
730
- hasNotifiedIPV4 = false ;
731
- #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
732
- hasNotifiedIPV6 = false ;
733
676
hasNotifiedWifiConnectivity = false ;
734
677
735
- WifiEvent event = WifiEvent::kStationDoDhcp ;
678
+ WifiEvent event = WifiEvent::kConnectionComplete ;
736
679
sl_matter_wifi_post_event (event);
737
680
}
738
681
@@ -744,7 +687,7 @@ void ProcessEvent(WifiEvent event)
744
687
case WifiEvent::kStationConnect :
745
688
ChipLogDetail (DeviceLayer, " WifiEvent::kStationConnect" );
746
689
wfx_rsi.dev_state .Set (WifiState::kStationConnected );
747
- ResetDHCPNotificationFlags ();
690
+ ResetConnectivityNotificationFlags ();
748
691
break ;
749
692
750
693
case WifiEvent::kStationDisconnect : {
@@ -757,7 +700,7 @@ void ProcessEvent(WifiEvent event)
757
700
.Clear (WifiState::kStationDhcpDone );
758
701
759
702
/* TODO: Implement disconnect notify */
760
- ResetDHCPNotificationFlags ();
703
+ ResetConnectivityNotificationFlags ();
761
704
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
762
705
wfx_ip_changed_notify (0 ); // for IPV4
763
706
wfx_ip_changed_notify (IP_STATUS_FAIL);
@@ -834,20 +777,9 @@ void ProcessEvent(WifiEvent event)
834
777
JoinWifiNetwork ();
835
778
break ;
836
779
837
- case WifiEvent::kStationDoDhcp :
838
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDoDhcp" );
839
- StartDHCPTimer (WFX_RSI_DHCP_POLL_INTERVAL);
840
- break ;
841
-
842
- case WifiEvent::kStationDhcpDone :
843
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDhcpDone" );
844
- CancelDHCPTimer ();
845
- break ;
846
-
847
- case WifiEvent::kStationDhcpPoll :
848
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDhcpPoll" );
849
- HandleDHCPPolling ();
850
- break ;
780
+ case WifiEvent::kConnectionComplete :
781
+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kConnectionComplete" );
782
+ NotifySuccessfulConnection ();
851
783
852
784
default :
853
785
break ;
0 commit comments