extern const uas_callbacks_t light_cbs;
extern const uas_callbacks_t motion_cbs;
-static int ble_detection_type = 0;
-static int wifi_detection_type = 0;
-
typedef struct {
void *handle;
uas_module_t *module;
if (!plugin || !plugin->api)
continue;
- /*
- * For User/device detection capable plugins, need to start both, PRESENCE
- * as well as ABSENCE detection, to keep UA database updated.
- */
- if (UAS_PLUGIN_ID_BLE == id || UAS_PLUGIN_ID_WIFI == id)
- status = plugin->api->start_detection(UAS_PRESENCE | UAS_ABSENCE);
- else
- status = plugin->api->start_detection(type);
+ status = plugin->api->start_detection(type);
if (UAS_STATUS_SUCCESS != status && UAS_STATUS_ALREADY_DONE != status) {
UAM_ERR("plugin->start_detection(%d) failed for %d", type, id);
continue;
}
- if (UAS_PLUGIN_ID_BLE == id)
- ble_detection_type |= type;
- if (UAS_PLUGIN_ID_WIFI == id)
- wifi_detection_type |= type;
-
/* Result success if detection started for atleast 1 of the sensor */
ret = UAM_ERROR_NONE;
}
if (!plugin || !plugin->api)
continue;
- if (UAS_PLUGIN_ID_BLE == id) {
- ble_detection_type &= ~type;
- ret = UAM_ERROR_NONE;
- if (0 != ble_detection_type)
- continue;
- }
-
- if (UAS_PLUGIN_ID_WIFI == id) {
- wifi_detection_type &= ~type;
- ret = UAM_ERROR_NONE;
- if (0 != wifi_detection_type)
- continue;
- }
-
- if (UAS_PLUGIN_ID_BLE == id || UAS_PLUGIN_ID_WIFI == id)
- status = plugin->api->stop_detection(UAS_PRESENCE | UAS_ABSENCE);
- else
- status = plugin->api->stop_detection(type);
+ status = plugin->api->stop_detection(type);
if (UAS_STATUS_SUCCESS != status && UAS_STATUS_ALREADY_DONE != status) {
UAM_ERR("plugin->stop_detection(%d) failed for %d", type, id);
retv_if(0 != g_strcmp0(service->name, svc_name), UAM_ERROR_NOT_IN_OPERATION);
/* Find sensors which are already monitoring */
- active_sensors = _uam_core_get_active_sensors(detection_type);
+ active_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
+ _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X",
sensors, active_sensors);
}
/* Find sensors which are already monitoring */
- remaining_sensors = _uam_core_get_active_sensors(detection_type);
+ remaining_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
+ _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
UAM_DBG("Remaining sensors: 0x%8.8X", remaining_sensors);
if (active_sensors == remaining_sensors) {
- UAM_INFO("NO need to stop monitoring");
+ UAM_INFO("No need to stop monitoring");
return UAM_ERROR_NONE;
}
/* Stop monitoring only for sensors which aren't required anymore */
sensors = (active_sensors & ~remaining_sensors);
- ret = _uam_pm_stop_detection(detection_type, sensors);
+ ret = _uam_pm_stop_detection(UAM_DETECT_PRESENCE | UAM_DETECT_ABSENCE, sensors);
if (UAM_ERROR_NONE != ret)
UAM_ERR("Failed with error: %s (0x%4.4X)",
_uam_manager_error_to_str(ret), ret);