@@ -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;
@@ -134,7 +129,8 @@ const sl_wifi_device_configuration_t config = {
134
129
#ifdef SLI_SI91X_MCU_INTERFACE
135
130
(SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE),
136
131
#else
137
- (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION),
132
+ (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION | SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE |
133
+ SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1),
138
134
#endif
139
135
.tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT |
140
136
SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS
@@ -207,27 +203,6 @@ constexpr uint8_t kWfxQueueSize = 10;
207
203
// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
208
204
constexpr uint16_t kWifiScanTimeoutTicks = 10000 ;
209
205
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
206
sl_status_t sl_wifi_siwx917_init (void )
232
207
{
233
208
sl_status_t status = SL_STATUS_OK;
@@ -356,7 +331,10 @@ sl_status_t SetWifiConfigurations()
356
331
VerifyOrReturnError (status == SL_STATUS_OK, status,
357
332
ChipLogError (DeviceLayer, " sl_wifi_set_listen_interval failed: 0x%lx" , status));
358
333
359
- 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 };
360
338
status = sl_wifi_set_advanced_client_configuration (SL_WIFI_CLIENT_INTERFACE, &client_config);
361
339
VerifyOrReturnError (status == SL_STATUS_OK, status,
362
340
ChipLogError (DeviceLayer, " sl_wifi_set_advanced_client_configuration failed: 0x%lx" , status));
@@ -513,11 +491,6 @@ sl_status_t sl_matter_wifi_platform_init(void)
513
491
sWifiEventQueue = osMessageQueueNew (kWfxQueueSize , sizeof (WifiEvent), nullptr );
514
492
VerifyOrReturnError (sWifiEventQueue != nullptr , SL_STATUS_ALLOCATION_FAILED);
515
493
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
494
return status;
522
495
}
523
496
@@ -661,53 +634,29 @@ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_
661
634
662
635
// / NotifyConnectivity
663
636
// / @brief Notify the application about the connectivity status if it has not been notified yet.
664
- // / Helper function for HandleDHCPPolling.
665
637
void NotifyConnectivity (void )
666
638
{
667
639
VerifyOrReturn (!hasNotifiedWifiConnectivity);
668
640
wfx_connected_notify (CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac );
669
641
hasNotifiedWifiConnectivity = true ;
670
642
}
671
643
672
- void HandleDHCPPolling (void )
644
+ // / NotifySuccessfulConnection
645
+ // / @brief Processing function responsible for notifying the upper layers of a succesful connection attempt.
646
+ void NotifySuccessfulConnection (void )
673
647
{
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
648
struct netif * sta_netif = &wifi_client_context.netif ;
678
649
VerifyOrReturn (sta_netif != nullptr , ChipLogError (DeviceLayer, " HandleDHCPPolling: failed to get STA netif" ));
679
-
680
650
#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
- }
651
+ wfx_dhcp_got_ipv4 ((uint32_t ) sta_netif->ip_addr .u_addr .ip4 .addr );
695
652
#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
- }
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 ();
710
658
}
659
+
711
660
void sl_matter_wifi_post_event (WifiEvent event)
712
661
{
713
662
sl_status_t status = osMessageQueuePut (sWifiEventQueue , &event, 0 , 0 );
@@ -719,19 +668,14 @@ void sl_matter_wifi_post_event(WifiEvent event)
719
668
// Chipdie, etc.
720
669
}
721
670
}
722
- // / ResetDHCPNotificationFlags
671
+ // / ResetConnectivityNotificationFlags
723
672
// / @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 )
673
+ // / and emits a WifiEvent::kConnectionComplete event to trigger DHCP polling checks. Helper function for ProcessEvent.
674
+ void ResetConnectivityNotificationFlags (void )
726
675
{
727
-
728
- #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
729
- hasNotifiedIPV4 = false ;
730
- #endif // CHIP_DEVICE_CONFIG_ENABLE_IPV4
731
- hasNotifiedIPV6 = false ;
732
676
hasNotifiedWifiConnectivity = false ;
733
677
734
- WifiEvent event = WifiEvent::kStationDoDhcp ;
678
+ WifiEvent event = WifiEvent::kConnectionComplete ;
735
679
sl_matter_wifi_post_event (event);
736
680
}
737
681
@@ -743,7 +687,7 @@ void ProcessEvent(WifiEvent event)
743
687
case WifiEvent::kStationConnect :
744
688
ChipLogDetail (DeviceLayer, " WifiEvent::kStationConnect" );
745
689
wfx_rsi.dev_state .Set (WifiState::kStationConnected );
746
- ResetDHCPNotificationFlags ();
690
+ ResetConnectivityNotificationFlags ();
747
691
break ;
748
692
749
693
case WifiEvent::kStationDisconnect : {
@@ -756,7 +700,7 @@ void ProcessEvent(WifiEvent event)
756
700
.Clear (WifiState::kStationDhcpDone );
757
701
758
702
/* TODO: Implement disconnect notify */
759
- ResetDHCPNotificationFlags ();
703
+ ResetConnectivityNotificationFlags ();
760
704
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4)
761
705
wfx_ip_changed_notify (0 ); // for IPV4
762
706
wfx_ip_changed_notify (IP_STATUS_FAIL);
@@ -833,20 +777,9 @@ void ProcessEvent(WifiEvent event)
833
777
JoinWifiNetwork ();
834
778
break ;
835
779
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 ;
780
+ case WifiEvent::kConnectionComplete :
781
+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kConnectionComplete" );
782
+ NotifySuccessfulConnection ();
850
783
851
784
default :
852
785
break ;
0 commit comments