@@ -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;
@@ -207,27 +202,6 @@ constexpr uint8_t kWfxQueueSize = 10;
207
202
// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
208
203
constexpr uint16_t kWifiScanTimeoutTicks = 10000 ;
209
204
210
- void DHCPTimerEventHandler (void * arg)
211
- {
212
- WifiEvent event = WifiEvent::kStationDhcpPoll ;
213
- sl_matter_wifi_post_event (event);
214
- }
215
-
216
- void CancelDHCPTimer (void )
217
- {
218
- VerifyOrReturn (osTimerIsRunning (sDHCPTimer ), ChipLogDetail (DeviceLayer, " CancelDHCPTimer: timer not running" ));
219
- VerifyOrReturn (osTimerStop (sDHCPTimer ) == osOK, ChipLogError (DeviceLayer, " CancelDHCPTimer: failed to stop timer" ));
220
- }
221
-
222
- void StartDHCPTimer (uint32_t timeout)
223
- {
224
- // Cancel timer if already started
225
- CancelDHCPTimer ();
226
-
227
- VerifyOrReturn (osTimerStart (sDHCPTimer , pdMS_TO_TICKS (timeout)) == osOK,
228
- ChipLogError (DeviceLayer, " StartDHCPTimer: failed to start timer" ));
229
- }
230
-
231
205
sl_status_t sl_wifi_siwx917_init (void )
232
206
{
233
207
sl_status_t status = SL_STATUS_OK;
@@ -513,11 +487,6 @@ sl_status_t sl_matter_wifi_platform_init(void)
513
487
sWifiEventQueue = osMessageQueueNew (kWfxQueueSize , sizeof (WifiEvent), nullptr );
514
488
VerifyOrReturnError (sWifiEventQueue != nullptr , SL_STATUS_ALLOCATION_FAILED);
515
489
516
- // Create timer for DHCP polling
517
- // TODO: Use LWIP timer instead of creating a new one here
518
- sDHCPTimer = osTimerNew (DHCPTimerEventHandler, osTimerPeriodic, nullptr , nullptr );
519
- VerifyOrReturnError (sDHCPTimer != nullptr , SL_STATUS_ALLOCATION_FAILED);
520
-
521
490
return status;
522
491
}
523
492
@@ -661,53 +630,29 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
661
630
662
631
// / NotifyConnectivity
663
632
// / @brief Notify the application about the connectivity status if it has not been notified yet.
664
- // / Helper function for HandleDHCPPolling.
665
633
void NotifyConnectivity (void )
666
634
{
667
635
VerifyOrReturn (!hasNotifiedWifiConnectivity);
668
636
wfx_connected_notify (CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac );
669
637
hasNotifiedWifiConnectivity = true ;
670
638
}
671
639
672
- void HandleDHCPPolling (void )
640
+ // / NotifySuccessfulConnection
641
+ // / @brief Processing function responsible for notifying the upper layers of a succesful connection attempt.
642
+ void NotifySuccessfulConnection (void )
673
643
{
674
- WifiEvent event;
675
-
676
- // TODO: Notify the application that the interface is not set up or Chipdie here because we are in an unkonwn state
677
644
struct netif * sta_netif = &wifi_client_context.netif ;
678
645
VerifyOrReturn (sta_netif != nullptr , ChipLogError (DeviceLayer, " HandleDHCPPolling: failed to get STA netif" ));
679
-
680
646
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
681
- uint8_t dhcp_state = dhcpclient_poll (sta_netif);
682
- if (dhcp_state == DHCP_ADDRESS_ASSIGNED && !hasNotifiedIPV4)
683
- {
684
- wfx_dhcp_got_ipv4 ((uint32_t ) sta_netif->ip_addr .u_addr .ip4 .addr );
685
- hasNotifiedIPV4 = true ;
686
- event = WifiEvent::kStationDhcpDone ;
687
- sl_matter_wifi_post_event (event);
688
- NotifyConnectivity ();
689
- }
690
- else if (dhcp_state == DHCP_OFF)
691
- {
692
- wfx_ip_changed_notify (IP_STATUS_FAIL);
693
- hasNotifiedIPV4 = false ;
694
- }
647
+ wfx_dhcp_got_ipv4 ((uint32_t ) sta_netif->ip_addr .u_addr .ip4 .addr )
695
648
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
696
- /* Checks if the assigned IPv6 address is preferred by evaluating
697
- * the first block of IPv6 address ( block 0)
698
- */
699
- if ((ip6_addr_ispreferred (netif_ip6_addr_state (sta_netif, 0 ))) && !hasNotifiedIPV6)
700
- {
701
- char addrStr[chip::Inet::IPAddress::kMaxStringLength ] = { 0 };
702
- VerifyOrReturn (ip6addr_ntoa_r (netif_ip6_addr (sta_netif, 0 ), addrStr, sizeof (addrStr)) != nullptr );
703
- ChipLogProgress (DeviceLayer, " SLAAC OK: linklocal addr: %s" , addrStr);
704
- wfx_ipv6_notify (GET_IPV6_SUCCESS);
705
- hasNotifiedIPV6 = true ;
706
- event = WifiEvent::kStationDhcpDone ;
707
- sl_matter_wifi_post_event (event);
708
- NotifyConnectivity ();
709
- }
649
+ char addrStr[chip::Inet::IPAddress::kMaxStringLength ] = { 0 };
650
+ VerifyOrReturn (ip6addr_ntoa_r (netif_ip6_addr (sta_netif, 0 ), addrStr, sizeof (addrStr)) != nullptr );
651
+ ChipLogProgress (DeviceLayer, " SLAAC OK: linklocal addr: %s" , addrStr);
652
+ wfx_ipv6_notify (GET_IPV6_SUCCESS);
653
+ NotifyConnectivity ();
710
654
}
655
+
711
656
void sl_matter_wifi_post_event (WifiEvent event)
712
657
{
713
658
sl_status_t status = osMessageQueuePut (sWifiEventQueue , &event, 0 , 0 );
@@ -719,19 +664,14 @@ void sl_matter_wifi_post_event(WifiEvent event)
719
664
// Chipdie, etc.
720
665
}
721
666
}
722
- // / ResetDHCPNotificationFlags
667
+ // / ResetConnectivityNotificationFlags
723
668
// / @brief Reset the flags that are used to notify the application about DHCP connectivity
724
- // / and emits a WifiEvent::kStationDoDhcp event to trigger DHCP polling checks. Helper function for ProcessEvent.
725
- void ResetDHCPNotificationFlags (void )
669
+ // / and emits a WifiEvent::kConnectionComplete event to trigger DHCP polling checks. Helper function for ProcessEvent.
670
+ void ResetConnectivityNotificationFlags (void )
726
671
{
727
-
728
- #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
729
- hasNotifiedIPV4 = false ;
730
- #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
731
- hasNotifiedIPV6 = false ;
732
672
hasNotifiedWifiConnectivity = false ;
733
673
734
- WifiEvent event = WifiEvent::kStationDoDhcp ;
674
+ WifiEvent event = WifiEvent::kConnectionComplete ;
735
675
sl_matter_wifi_post_event (event);
736
676
}
737
677
@@ -743,7 +683,7 @@ void ProcessEvent(WifiEvent event)
743
683
case WifiEvent::kStationConnect :
744
684
ChipLogDetail (DeviceLayer, " WifiEvent::kStationConnect" );
745
685
wfx_rsi.dev_state .Set (WifiState::kStationConnected );
746
- ResetDHCPNotificationFlags ();
686
+ ResetConnectivityNotificationFlags ();
747
687
break ;
748
688
749
689
case WifiEvent::kStationDisconnect : {
@@ -756,7 +696,7 @@ void ProcessEvent(WifiEvent event)
756
696
.Clear (WifiState::kStationDhcpDone );
757
697
758
698
/* TODO: Implement disconnect notify */
759
- ResetDHCPNotificationFlags ();
699
+ ResetConnectivityNotificationFlags ();
760
700
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
761
701
wfx_ip_changed_notify (0 ); // for IPV4
762
702
wfx_ip_changed_notify (IP_STATUS_FAIL);
@@ -833,20 +773,9 @@ void ProcessEvent(WifiEvent event)
833
773
JoinWifiNetwork ();
834
774
break ;
835
775
836
- case WifiEvent::kStationDoDhcp :
837
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDoDhcp" );
838
- StartDHCPTimer (WFX_RSI_DHCP_POLL_INTERVAL);
839
- break ;
840
-
841
- case WifiEvent::kStationDhcpDone :
842
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDhcpDone" );
843
- CancelDHCPTimer ();
844
- break ;
845
-
846
- case WifiEvent::kStationDhcpPoll :
847
- ChipLogDetail (DeviceLayer, " WifiEvent::kStationDhcpPoll" );
848
- HandleDHCPPolling ();
849
- break ;
776
+ case WifiEvent::kConnectionComplete :
777
+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kConnectionComplete" );
778
+ NotifySuccessfulConnection ();
850
779
851
780
default :
852
781
break ;
@@ -917,6 +846,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
917
846
}
918
847
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
919
848
849
+
920
850
#if CHIP_CONFIG_ENABLE_ICD_SERVER
921
851
sl_status_t ConfigurePowerSave (rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state,
922
852
uint32_t listenInterval)
0 commit comments