Add API for stop detection 91/260591/2
authorAbhay Agarwal <ay.agarwal@samsung.com>
Tue, 12 Jan 2021 04:25:33 +0000 (09:55 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 1 Jul 2021 07:44:52 +0000 (13:14 +0530)
Change-Id: Ie8da934c06f6b3dff776f81875814e9ba2ce6af9
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
include/wifi-location-plugin.h
src/wifi-location-plugin-scan.c
src/wifi-location-plugin.c

index ffdab61..011408b 100755 (executable)
@@ -33,6 +33,8 @@ extern "C" {
 
 int _wifi_location_plugin_start_scan(int scan_mode);
 
+int _wifi_location_plugin_stop_scan(void);
+
 #ifdef __cplusplus
 }
 #endif
index 651e194..f61872b 100755 (executable)
@@ -34,3 +34,11 @@ int _wifi_location_plugin_start_scan(int scan_mode) {
        FUNC_EXIT;
        return ret;
 }
+
+int _wifi_location_plugin_stop_scan(void) {
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+
+       FUNC_EXIT;
+       return ret;
+}
index 8ac2c77..5e9193a 100755 (executable)
@@ -61,11 +61,9 @@ static int __stop_scan()
 
        g_slist_foreach(dev_list, __reset_devices, NULL);
 
-       /* TODO: stop scan */
-       if (UAS_STATUS_SUCCESS != ret) {
-               UA_WIFI_LOCATION_ERR("Fail to stop wifi_location scan [%d]", ret);
-               return ret;
-       }
+       /* stop scan */
+       ret = _wifi_location_plugin_stop_scan();
+       retv_if_with_log(UAS_STATUS_SUCCESS != ret, ret, "return %d", ret);
 
        /* Send detection stopped */
        if (uas_cbs && uas_cbs->detection_state_cb) {
@@ -220,6 +218,37 @@ done:
        return ret;
 }
 
+static int stop_detection(unsigned int detection_type)
+{
+       FUNC_ENTER;
+       int ret = UAS_STATUS_SUCCESS;
+
+       retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
+       retv_if(0 == (wifi_location_detection_type & detection_type),
+                                               UAS_STATUS_ALREADY_DONE);
+
+       /* Stop detection */
+       ret = __stop_scan();
+       retv_if_with_log(UAS_STATUS_SUCCESS != ret, ret, "return %d", ret);
+
+       wifi_location_detection_type &= ~detection_type;
+       UA_WIFI_LOCATION_INFO_C("wifi_location_detection_type = 0x%8.8X",
+                                               wifi_location_detection_type);
+       if (0 != wifi_location_detection_type)
+               goto done;
+
+       /* Remove stop scan timer */
+       if (0 < stop_scan_timer) {
+               g_source_remove(stop_scan_timer);
+               stop_scan_timer = 0;
+               UA_WIFI_LOCATION_INFO("Stop scan timer removed");
+       }
+
+done:
+       FUNC_EXIT;
+       return ret;
+}
+
 static uas_api_t wifi_location_api = {
        .init = init,
        .deinit = deinit,
@@ -229,7 +258,7 @@ static uas_api_t wifi_location_api = {
        .add_device = NULL,
        .remove_device = NULL,
        .start_detection = start_detection,
-       .stop_detection = NULL,
+       .stop_detection = stop_detection,
        .set_low_power_mode = NULL,
        .set_detection_window = NULL,
        .set_detection_threshold = NULL,