Skip to content

Commit 9280863

Browse files
committed
patches: WHD add wifi join timeout
1 parent e47254c commit 9280863

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
From efd54c8990ba5b437eb4eb8b786b7e48941b03f1 Mon Sep 17 00:00:00 2001
2+
From: pennam <[email protected]>
3+
Date: Mon, 21 Oct 2024 11:27:36 +0200
4+
Subject: [PATCH] WHD: add join timeout parameter to WiFiSTAInterface and
5+
drivers
6+
7+
---
8+
.../emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp | 7 ++++---
9+
.../emac/COMPONENT_WHD/interface/WhdSTAInterface.h | 6 ++++++
10+
.../COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h | 2 +-
11+
.../COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c | 9 ++++++---
12+
connectivity/netsocket/include/netsocket/WiFiInterface.h | 7 +++++++
13+
5 files changed, 24 insertions(+), 7 deletions(-)
14+
15+
diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp
16+
index c933203d36..f7631a0583 100644
17+
--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp
18+
+++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp
19+
@@ -211,7 +211,8 @@ WhdSTAInterface::WhdSTAInterface(WHD_EMAC &emac, OnboardNetworkStack &stack, Olm
20+
_security(NSAPI_SECURITY_NONE),
21+
_whd_emac(emac),
22+
_olm(&olm),
23+
- _iface_shared(shared)
24+
+ _iface_shared(shared),
25+
+ _timeout(7000)
26+
{
27+
}
28+
29+
@@ -334,7 +335,7 @@ nsapi_error_t WhdSTAInterface::connect()
30+
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
31+
&ssid,
32+
security,
33+
- (const uint8_t *)_pass, strlen(_pass));
34+
+ (const uint8_t *)_pass, strlen(_pass), _timeout);
35+
}
36+
else
37+
{
38+
@@ -345,7 +346,7 @@ nsapi_error_t WhdSTAInterface::connect()
39+
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
40+
&ssid,
41+
security,
42+
- (const uint8_t *)_pass, key_length);
43+
+ (const uint8_t *)_pass, key_length, _timeout);
44+
}
45+
if (res == WHD_SUCCESS) {
46+
break;
47+
diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h
48+
index 4dd1098947..bfe933bac7 100644
49+
--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h
50+
+++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h
51+
@@ -119,6 +119,11 @@ public:
52+
return 0;
53+
}
54+
55+
+ nsapi_error_t set_timeout(uint32_t timeout)
56+
+ {
57+
+ _timeout = timeout;
58+
+ }
59+
+
60+
/** Set blocking status of interface.
61+
* Nonblocking mode unsupported.
62+
*
63+
@@ -257,6 +262,7 @@ private:
64+
nsapi_security_t _security;
65+
WHD_EMAC &_whd_emac;
66+
OlmInterface *_olm;
67+
+ uint32_t _timeout;
68+
whd_interface_shared_info_t &_iface_shared;
69+
};
70+
71+
diff --git a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h
72+
index f3b73214cb..291bd23de8 100755
73+
--- a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h
74+
+++ b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h
75+
@@ -281,7 +281,7 @@ extern uint32_t whd_wifi_stop_scan(whd_interface_t ifp);
76+
* Error code if an error occurred
77+
*/
78+
extern uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type,
79+
- const uint8_t *security_key, uint8_t key_length);
80+
+ const uint8_t *security_key, uint8_t key_length, uint32_t timeout);
81+
82+
/** Joins a specific Wi-Fi network
83+
*
84+
diff --git a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c
85+
index 5294104ab4..8a8f411ef9 100755
86+
--- a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c
87+
+++ b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c
88+
@@ -294,6 +294,8 @@ static const uint16_t mcs_data_rate_lookup_table[32][2][2] =
89+
},
90+
};
91+
92+
+static whd_wifi_join_timeout = DEFAULT_JOIN_ATTEMPT_TIMEOUT;
93+
+
94+
95+
/******************************************************
96+
* Static Function prototypes
97+
@@ -1334,7 +1336,7 @@ static uint32_t whd_wifi_join_wait_for_complete(whd_interface_t ifp, cy_semaphor
98+
99+
while (!done)
100+
{
101+
- result = cy_rtos_get_semaphore(semaphore, DEFAULT_JOIN_ATTEMPT_TIMEOUT / 10, WHD_FALSE);
102+
+ result = cy_rtos_get_semaphore(semaphore, whd_wifi_join_timeout / 10, WHD_FALSE);
103+
whd_assert("Get semaphore failed", (result == CY_RSLT_SUCCESS) || (result == CY_RTOS_TIMEOUT) );
104+
REFERENCE_DEBUG_ONLY_VARIABLE(result);
105+
106+
@@ -1345,7 +1347,7 @@ static uint32_t whd_wifi_join_wait_for_complete(whd_interface_t ifp, cy_semaphor
107+
}
108+
109+
cy_rtos_get_time(&current_time);
110+
- done = (whd_bool_t)( (current_time - start_time) >= DEFAULT_JOIN_ATTEMPT_TIMEOUT );
111+
+ done = (whd_bool_t)( (current_time - start_time) >= whd_wifi_join_timeout );
112+
}
113+
114+
if (result != WHD_SUCCESS)
115+
@@ -1574,7 +1576,7 @@ uint32_t whd_wifi_join_specific(whd_interface_t ifp, const whd_scan_result_t *ap
116+
}
117+
118+
uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type,
119+
- const uint8_t *security_key, uint8_t key_length)
120+
+ const uint8_t *security_key, uint8_t key_length, uint32_t timeout)
121+
{
122+
cy_semaphore_t join_sema;
123+
whd_result_t result;
124+
@@ -1616,6 +1618,7 @@ uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security
125+
ssid_params->SSID_len = htod32(ssid->length);
126+
memcpy(ssid_params->SSID, ssid->value, ssid_params->SSID_len);
127+
result = whd_cdc_send_ioctl(ifp, CDC_SET, WLC_SET_SSID, buffer, 0);
128+
+ whd_wifi_join_timeout = timeout;
129+
130+
if (result == WHD_SUCCESS)
131+
{
132+
diff --git a/connectivity/netsocket/include/netsocket/WiFiInterface.h b/connectivity/netsocket/include/netsocket/WiFiInterface.h
133+
index 4fd7fc6fb8..c13cab4312 100644
134+
--- a/connectivity/netsocket/include/netsocket/WiFiInterface.h
135+
+++ b/connectivity/netsocket/include/netsocket/WiFiInterface.h
136+
@@ -59,6 +59,13 @@ public:
137+
*/
138+
virtual nsapi_error_t set_channel(uint8_t channel) = 0;
139+
140+
+ /** Set the Wi-Fi network join timeout.
141+
+ *
142+
+ * @param timeout joint timeout in milliseconds (Default: 7000).
143+
+ * @return NSAPI_ERROR_OK on success, or error code on failure.
144+
+ */
145+
+ virtual nsapi_error_t set_timeout(uint32_t timeout) = 0;
146+
+
147+
/** Get the current radio signal strength for active connection.
148+
*
149+
* @return Connection strength in dBm (negative value),
150+
--
151+
2.45.2
152+

0 commit comments

Comments
 (0)