Skip to content

Commit eccac9b

Browse files
simensrostadjtguggedal
authored andcommitted
lib: location: Use k_sem_give() when cancelling Wi-Fi location
If location is cancelled during Wi-Fi search, the semaphore blocking the location positioning workqueue is not released due to k_sem_reset() being used instead of k_sem_give(). This prevents subsequent location requests to start Wi-Fi scans. This commit changes k_sem_reset() to k_sem_give() and adds a test for this scenario. Signed-off-by: Simen S. Røstad <[email protected]>
1 parent 492a2e9 commit eccac9b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/location/scan_wifi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void scan_wifi_execute(int32_t timeout, struct k_sem *wifi_scan_ready)
112112
#if defined(CONFIG_LOCATION_METHOD_WIFI_NET_IF_UPDOWN)
113113
ret = scan_wifi_startup_interface(wifi_iface);
114114
if (ret) {
115+
k_sem_give(scan_wifi_ready);
116+
scan_wifi_ready = NULL;
115117
return;
116118
}
117119
#endif /* defined(CONFIG_LOCATION_METHOD_WIFI_NET_IF_UPDOWN) */
@@ -203,7 +205,7 @@ void scan_wifi_net_mgmt_event_handler(
203205
int scan_wifi_cancel(void)
204206
{
205207
if (scan_wifi_ready != NULL) {
206-
k_sem_reset(scan_wifi_ready);
208+
k_sem_give(scan_wifi_ready);
207209
scan_wifi_ready = NULL;
208210
}
209211
return 0;

0 commit comments

Comments
 (0)