diff options
author | jomui <jongmun.woo@samsung.com> | 2015-12-10 11:23:10 +0900 |
---|---|---|
committer | Woo <jongmun.woo@samsung.com> | 2015-12-28 18:12:57 -0800 |
commit | 8aaa7e86b0419db6de37963989f6ab54d581ae28 (patch) | |
tree | 7baec4c33323c1d4663369fe4e70456c1f686f86 | |
parent | fc617bd421f0cadd4c0affdfbcded0d466cc0b3a (diff) | |
download | geofence-server-8aaa7e86b0419db6de37963989f6ab54d581ae28.tar.gz geofence-server-8aaa7e86b0419db6de37963989f6ab54d581ae28.tar.bz2 geofence-server-8aaa7e86b0419db6de37963989f6ab54d581ae28.zip |
Proximity alert implementation using BLEsubmit/tizen_ivi/20160217.000002submit/tizen_ivi/20160217.000000submit/tizen_common/20160222.141210submit/tizen/20160202.105237accepted/tizen/wearable/20160203.051121accepted/tizen/tv/20160203.051101accepted/tizen/mobile/20160203.051039accepted/tizen/ivi/20160218.023403accepted/tizen/common/20160222.162133
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: I0e171b58a4c810d1bbccd26c46a211ef53cc7b5e
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | geofence-server/include/geofence_server_data_types.h | 6 | ||||
-rw-r--r-- | geofence-server/src/geofence_server.c | 333 | ||||
-rw-r--r-- | geofence-server/src/geofence_server.h | 14 | ||||
-rw-r--r-- | geofence-server/src/geofence_server_bluetooth.c | 53 | ||||
-rwxr-xr-x | geofence-server/src/geofence_server_db.c | 84 | ||||
-rw-r--r-- | geofence-server/src/geofence_server_db.h | 2 | ||||
-rw-r--r-- | geofence-server/src/geofence_server_private.h | 3 | ||||
-rw-r--r-- | geofence-server/src/geofence_server_wifi.c | 55 | ||||
-rw-r--r-- | geofence-server/src/server.c | 19 | ||||
-rw-r--r-- | packaging/geofence-server.spec | 1 |
11 files changed, 417 insertions, 155 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 961bf22..a416dfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET(BIN_DIR "${PREFIX}/bin") #Dependencies SET(common_dp "glib-2.0 geofence-dbus dlog gio-2.0 capi-appfw-app-manager") -SET(server_dp "${common_dp} network vconf vconf-internal-keys capi-system-info gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-location-manager capi-network-bluetooth capi-network-wifi libcore-context-manager libtzplatform-config") +SET(server_dp "${common_dp} network vconf vconf-internal-keys capi-system-info gthread-2.0 gio-unix-2.0 sqlite3 db-util alarm-service deviced capi-location-manager capi-network-bluetooth capi-network-wifi libcore-context-manager capi-system-device libtzplatform-config") SET(module_dp "${common_dp} gmodule-2.0 capi-geofence-manager") # Set required packages diff --git a/geofence-server/include/geofence_server_data_types.h b/geofence-server/include/geofence_server_data_types.h index 71339ff..4c30e7a 100644 --- a/geofence-server/include/geofence_server_data_types.h +++ b/geofence-server/include/geofence_server_data_types.h @@ -159,6 +159,12 @@ typedef enum { ACCESS_TYPE_UNKNOWN, } access_type_e; +typedef enum { + BLE_INFO_NONE = 0, + BLE_INFO_READ, + BLE_INFO_WRITE, +} ble_mode_e; + #ifdef __cplusplus } #endif diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 7e2da1c..a46ed12 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -57,6 +57,7 @@ #define DEFAULT_PLACE_OFFICE 2 #define DEFAULT_PLACE_CAR 3 +static int __emit_fence_proximity(GeofenceServer *geofence_server, int fence_id, geofence_proximity_state_e state); static int __gps_alarm_cb(alarm_id_t alarm_id, void *user_data); static int __wps_alarm_cb(alarm_id_t alarm_id, void *user_data); static int __gps_timeout_cb(alarm_id_t alarm_id, void *user_data); @@ -119,57 +120,157 @@ static const char *__convert_wifi_error_to_string(wifi_error_e err_type) } } -#if 0 /* Not used */ -static const char *__bt_get_error_message(bt_error_e err) +void emit_proximity_using_ble(GeofenceServer *geofence_server, int fence_id, geofence_proximity_state_e state) { - switch (err) { - case BT_ERROR_NONE: - return "BT_ERROR_NONE"; - case BT_ERROR_CANCELLED: - return "BT_ERROR_CANCELLED"; - case BT_ERROR_INVALID_PARAMETER: - return "BT_ERROR_INVALID_PARAMETER"; - case BT_ERROR_OUT_OF_MEMORY: - return "BT_ERROR_OUT_OF_MEMORY"; - case BT_ERROR_RESOURCE_BUSY: - return "BT_ERROR_RESOURCE_BUSY"; - case BT_ERROR_TIMED_OUT: - return "BT_ERROR_TIMED_OUT"; - case BT_ERROR_NOW_IN_PROGRESS: - return "BT_ERROR_NOW_IN_PROGRESS"; - case BT_ERROR_NOT_INITIALIZED: - return "BT_ERROR_NOT_INITIALIZED"; - case BT_ERROR_NOT_ENABLED: - return "BT_ERROR_NOT_ENABLED"; - case BT_ERROR_ALREADY_DONE: - return "BT_ERROR_ALREADY_DONE"; - case BT_ERROR_OPERATION_FAILED: - return "BT_ERROR_OPERATION_FAILED"; - case BT_ERROR_NOT_IN_PROGRESS: - return "BT_ERROR_NOT_IN_PROGRESS"; - case BT_ERROR_REMOTE_DEVICE_NOT_BONDED: - return "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"; - case BT_ERROR_AUTH_REJECTED: - return "BT_ERROR_AUTH_REJECTED"; - case BT_ERROR_AUTH_FAILED: - return "BT_ERROR_AUTH_FAILED"; - case BT_ERROR_REMOTE_DEVICE_NOT_FOUND: - return "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"; - case BT_ERROR_SERVICE_SEARCH_FAILED: - return "BT_ERROR_SERVICE_SEARCH_FAILED"; - case BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED: - return "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"; -#ifndef TIZEN_TV - case BT_ERROR_PERMISSION_DENIED: - return "BT_ERROR_PERMISSION_DENIED"; - case BT_ERROR_SERVICE_NOT_FOUND: - return "BT_ERROR_SERVICE_NOT_FOUND"; -#endif - default: - return "NOT Defined"; + FUNC_ENTRANCE_SERVER; + g_return_val_if_fail(geofence_server, -1); + GeofenceItemData *item_data = __get_item_by_fence_id(fence_id, geofence_server); + if (item_data) { + if (item_data->common_info.proximity_status != state) { + LOGI_GEOFENCE("Emitting proximity status(fence: %d): %d", fence_id, state); + geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, state, GEOFENCE_PROXIMITY_PROVIDER_BLE); + item_data->common_info.proximity_status = state; + } + } else { + LOGD_GEOFENCE("Invalid item_data"); + } +} + +static bool __check_for_match(char *str1, char *str2) +{ + if (g_strrstr(str1, str2) == NULL) + return false; + return true; +} + +static void bt_le_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + int ret = BT_ERROR_NONE; + GeofenceServer *geofence_server = (GeofenceServer *) user_data; + LOGI_GEOFENCE("Current addresses: %s", geofence_server->ble_info); + LOGI_GEOFENCE("Received address: %s", info->remote_address); + if (info == NULL) { + LOGI_GEOFENCE("Stopping scan as there is no BLE addresses found"); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + return; + } + /* Retrieve the information about the AP */ + if (!g_ascii_strcasecmp(geofence_server->ble_info, "")) { + g_stpcpy(geofence_server->ble_info, info->remote_address); + } else if (!__check_for_match(geofence_server->ble_info, info->remote_address)) { /* If duplicate does not exist */ + char *p = g_strjoin(";", geofence_server->ble_info, info->remote_address, NULL); + g_stpcpy(geofence_server->ble_info, p); + g_free(p); + } else { + LOGI_GEOFENCE("Stopping scan. Address: %s already exist in the string %s", info->remote_address, geofence_server->ble_info); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + /* Add the string to the database. */ + LOGI_GEOFENCE("Writing address: %s to DB for fence: %d", geofence_server->ble_info, geofence_server->nearestTrackingFence); + geofence_manager_set_ble_info_to_geofence(geofence_server->nearestTrackingFence, geofence_server->ble_info); + } +} + +void bt_le_scan_result_display_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + FUNC_ENTRANCE_SERVER; + int ret = BT_ERROR_NONE; + GeofenceServer *geofence_server = (GeofenceServer *) user_data; + int wps_state = 0; + int gps_state = 0; + int fence_id = -1; + char *ble_info = NULL; + ble_mode_e ble_proximity_mode = BLE_INFO_NONE; + GList *tracking_list = g_list_first(geofence_server->tracking_list); + if (info == NULL) { + LOGI_GEOFENCE("Stopping scan as there is no BLE addresses found"); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + return; + } + if (!g_ascii_strcasecmp(geofence_server->ble_info, "")) { + g_stpcpy(geofence_server->ble_info, info->remote_address); + } else if (!__check_for_match(geofence_server->ble_info, info->remote_address)) { /* If duplicate does not exist */ + char *p = g_strjoin(";", geofence_server->ble_info, info->remote_address, NULL); + g_stpcpy(geofence_server->ble_info, p); + g_free(p); + } else { + LOGI_GEOFENCE("Stopping scan. Address: %s already exist in the string %s", info->remote_address, geofence_server->ble_info); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + return; + } + if (tracking_list) { + while (tracking_list) { + ble_proximity_mode = BLE_INFO_NONE; + fence_id = GPOINTER_TO_INT(tracking_list->data); + GeofenceItemData *item_data = __get_item_by_fence_id(fence_id, geofence_server); + if (item_data->common_info.type == GEOFENCE_TYPE_GEOPOINT) { + vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_state); + vconf_get_int(VCONFKEY_LOCATION_ENABLED, &gps_state); + if (wps_state == 0 && gps_state == 0) + ble_proximity_mode = BLE_INFO_READ; + } else if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) { + if (__isWifiOn() == false) + ble_proximity_mode = BLE_INFO_READ; + } else if (item_data->common_info.type == GEOFENCE_TYPE_BT) { + bssid_info_s *bt_info = NULL; + bt_info = (bssid_info_s *) item_data->priv; + bt_device_info_s *bt_device_info = NULL; + if (bt_info != NULL) { + ret = bt_adapter_get_bonded_device_info(bt_info->bssid, &bt_device_info); + if (ret == BT_ERROR_NONE) { + if (bt_device_info->is_connected == false) + ble_proximity_mode = BLE_INFO_READ; + } else if (ret == BT_ERROR_REMOTE_DEVICE_NOT_BONDED) { + ble_proximity_mode = BLE_INFO_READ; /*Its not bonded*/ + } + } + } + if (ble_proximity_mode == BLE_INFO_READ) { + geofence_manager_get_ble_info_from_geofence(fence_id, &ble_info); + LOGI_GEOFENCE("Ble info read from DB: %s", ble_info); + if (__check_for_match(ble_info, info->remote_address)) { + LOGI_GEOFENCE("Matched for ble address: %s for the fence: %d", info->remote_address, fence_id); + emit_proximity_using_ble(geofence_server, fence_id, GEOFENCE_PROXIMITY_IMMEDIATE); + } + } + tracking_list = g_list_next(tracking_list); + } + } +} + +void device_display_changed_cb(device_callback_e type, void *value, void *user_data) +{ + FUNC_ENTRANCE_SERVER; + GeofenceServer *geofence_server = (GeofenceServer *) user_data; + int ret = BT_ERROR_NONE; + GList *tracking_list = g_list_first(geofence_server->tracking_list); + if (tracking_list) { + if (type == DEVICE_CALLBACK_DISPLAY_STATE) { + display_state_e state = (display_state_e)value; + if (state == DISPLAY_STATE_NORMAL) { + LOGI_GEOFENCE("State: NORMAL"); + if (tracking_list) { + LOGD_GEOFENCE("Scanning for BLE and read DB"); + g_stpcpy(geofence_server->ble_info, ""); + ret = bt_adapter_le_start_scan(bt_le_scan_result_display_cb, geofence_server); + if (ret != BT_ERROR_NONE) { + LOGE_GEOFENCE("Fail to start ble scan. %d", ret); + } + } + } else if (state == DISPLAY_STATE_SCREEN_DIM) + LOGI_GEOFENCE("State: DIM"); + else + LOGI_GEOFENCE("State: OFF"); + } } } -#endif static int __emit_fence_event(GeofenceServer *geofence_server, int place_id, int fence_id, access_type_e access_type, const gchar *app_id, geofence_server_error_e error, geofence_manage_e state) { @@ -214,6 +315,7 @@ static int __emit_fence_inout(GeofenceServer *geofence_server, int fence_id, geo /*LOGD_GEOFENCE("FENCE_OUT to be set, current state: %d", item_data->common_info.status);*/ if (item_data->common_info.status != GEOFENCE_FENCE_STATE_OUT) { geofence_dbus_server_send_geofence_inout_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, GEOFENCE_EMIT_STATE_OUT); + __emit_fence_proximity(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); if (item_data->client_status == GEOFENCE_CLIENT_STATUS_START) { item_data->client_status = GEOFENCE_CLIENT_STATUS_RUNNING; } @@ -236,9 +338,15 @@ static int __emit_fence_proximity(GeofenceServer *geofence_server, int fence_id, { FUNC_ENTRANCE_SERVER; g_return_val_if_fail(geofence_server, -1); + geofence_proximity_provider_e provider = GEOFENCE_PROXIMITY_PROVIDER_LOCATION; GeofenceItemData *item_data = __get_item_by_fence_id(fence_id, geofence_server); if (item_data) { - geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, state, GEOFENCE_PROXIMITY_PROVIDER_LOCATION); + if (item_data->common_info.type == GEOFENCE_TYPE_WIFI) { + provider = GEOFENCE_PROXIMITY_PROVIDER_WIFI; + } else if (item_data->common_info.type == GEOFENCE_TYPE_BT) { + provider = GEOFENCE_PROXIMITY_PROVIDER_BLUETOOTH; + } + geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, item_data->common_info.appid, fence_id, item_data->common_info.access_type, state, provider); item_data->common_info.proximity_status = state; } else { LOGD_GEOFENCE("Invalid item_data"); @@ -250,6 +358,7 @@ static int __emit_fence_proximity(GeofenceServer *geofence_server, int fence_id, static void __check_proximity_for_fence(double distance, int fence_id, int radius, geofence_proximity_state_e current_state, void *user_data) { FUNC_ENTRANCE_SERVER; + int ret = BT_ERROR_NONE; geofence_proximity_state_e state = GEOFENCE_PROXIMITY_UNCERTAIN; GeofenceServer *geofence_server = (GeofenceServer *) user_data; if (distance <= 50.0) { @@ -259,9 +368,24 @@ static void __check_proximity_for_fence(double distance, int fence_id, int radiu } else if (distance > 100.0 && distance <= radius) { state = GEOFENCE_PROXIMITY_FAR; } - if (current_state != state) + if (current_state != state) { LOGD_GEOFENCE("PROXIMITY ALERTING for fence: %d, alert: %d, distance: %f", fence_id, state, distance); __emit_fence_proximity(geofence_server, fence_id, state); + if (geofence_server->nearestTrackingFence == fence_id) { + if (state == GEOFENCE_PROXIMITY_IMMEDIATE) { + LOGD_GEOFENCE("Scanning for BLE and storing in DB"); + g_stpcpy(geofence_server->ble_info, ""); + ret = bt_adapter_le_start_scan(bt_le_scan_result_cb, geofence_server); + if (ret != BT_ERROR_NONE) { + LOGE_GEOFENCE("Fail to start ble scan. %d", ret); + } + } else if (current_state == GEOFENCE_PROXIMITY_IMMEDIATE) { /* Stopping the scan if state changes */ + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan/ Stopped already, error: %d", ret); + } + } + } } static void __check_inout_by_gps(double latitude, double longitude, int fence_id, void *user_data) @@ -579,6 +703,7 @@ static void __geofence_standalone_gps_position_changed_cb(double latitude, doubl /* Distance based alarm */ distance = _get_min_distance(latitude, longitude, &min_fence_id, geofence_server); + geofence_server->nearestTrackingFence = min_fence_id; if (distance < 200) { LOGD_GEOFENCE("interval: 1 secs"); @@ -693,6 +818,7 @@ static void __geofence_gps_position_changed_cb(double latitude, double longitude /*Get minimum distance and fence_id of the nearest tracking fence*/ if (geofence_server->gps_fix_info) { min_distance = _get_min_distance(geofence_server->gps_fix_info->latitude, geofence_server->gps_fix_info->longitude, &min_fence_id, geofence_server); + geofence_server->nearestTrackingFence = min_fence_id; /*This has to be updated frequently*/ item_data = __get_item_by_fence_id(min_fence_id, geofence_server); if (item_data && geofence_server->loc_gps_started_by_wps == TRUE) { LOGI_GEOFENCE("******Setting the GPS interval******"); @@ -743,6 +869,7 @@ static void __geofence_wps_position_changed_cb(double latitude, double longitude /*Get minimum distance and fence_id of the nearest tracking fence*/ min_distance = _get_min_distance(latitude, longitude, &min_fence_id, geofence_server); LOGI_GEOFENCE("Nearest fence id: %d, distance: %f", min_fence_id, min_distance); + geofence_server->nearestTrackingFence = min_fence_id;/* This has to be updated frequently*/ item_data = __get_item_by_fence_id(min_fence_id, geofence_server); @@ -840,45 +967,6 @@ static void __set_interval_for_gps(double min_distance, int min_fence_id, void * } } -#if 0 -static void __check_tracking_list(const char *bssid, void *user_data, geofence_type_e type) -{ - FUNC_ENTRANCE_SERVER; - GeofenceServer *geofence_server = (GeofenceServer *) user_data; - g_return_if_fail(geofence_server); - int tracking_fence_id = 0; - GeofenceItemData *item_data = NULL; - GList *tracking_fences = g_list_first(geofence_server->tracking_list); - - while (tracking_fences) { - tracking_fence_id = GPOINTER_TO_INT(tracking_fences->data); - tracking_fences = g_list_next(tracking_fences); - item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server); - if (item_data != NULL) { - if (item_data->common_info.type == type) { - if (type == GEOFENCE_TYPE_WIFI) { - bssid_info_s *wifi_info = (bssid_info_s *)item_data->priv; - - if ((!g_ascii_strcasecmp(wifi_info->bssid, bssid) || !g_ascii_strcasecmp(g_strdelimit(wifi_info->bssid, "-", ':'), bssid)) && item_data->is_wifi_status_in == false) { - LOGI_GEOFENCE("Matched wifi fence: fence_id = %d, bssid = %s", item_data->common_info.fence_id, wifi_info->bssid); - item_data->is_wifi_status_in = true; - } - } else if (type == GEOFENCE_TYPE_BT) { - bssid_info_s *bt_info = (bssid_info_s *)item_data->priv; - - if ((!g_ascii_strcasecmp(bt_info->bssid, bssid) || !g_ascii_strcasecmp(g_strdelimit(bt_info->bssid, "-", ':'), bssid)) && item_data->is_bt_status_in == false) { - LOGI_GEOFENCE("Matched bt fence: fence_id = %d, bssid received = %s, bssid = %s", item_data->common_info.fence_id, bt_info->bssid, bssid); - item_data->is_bt_status_in = true; - } - } - } - } else { - LOGI_GEOFENCE("No data present for the fence: %d", tracking_fence_id); - } - } -} -#endif - void bt_adapter_device_discovery_state_cb(int result, bt_adapter_device_discovery_state_e discovery_state, bt_adapter_device_discovery_info_s *discovery_info, void *user_data) { #if 0 @@ -922,74 +1010,17 @@ void bt_adapter_device_discovery_state_cb(int result, bt_adapter_device_discover #endif } -/*static double __getProximityDistance(double rssi_rec) -{ - FUNC_ENTRANCE_SERVER; - double d = 0; - double d0 = 1.0; - double rssi = rssi_rec; - double rssi0 = -40.9117; - double inter = 0; - - inter = (rssi0 - rssi)/(10 * ETA); - d = d0 * math.pow(10, inter); - return d; -}*/ - static void geofence_network_evt_cb(net_event_info_t *event_cb, void *user_data) { FUNC_ENTRANCE_SERVER; GeofenceServer *geofence_server = (GeofenceServer *) user_data; g_return_if_fail(geofence_server); - /*GList *tracking_fences = g_list_first(geofence_server->tracking_list); - GeofenceItemData *item_data = NULL; - int tracking_fence_id = 0;*/ net_wifi_state_t network_state = WIFI_UNKNOWN; int ret = -1; int wps_state = 0; int gps_state = 0; switch (event_cb->Event) { -#if 0 - case NET_EVENT_WIFI_SCAN_IND: - - LOGD_GEOFENCE("Got WIFI scan Ind : %d\n", event_cb->Error); - - net_profile_info_t *profiles = NULL; - int num_of_profile = 0; - - if (geofence_server->running_wifi_cnt > 0) { /*Check only if some wifi fence is running*/ - if (NET_ERR_NONE != net_get_profile_list(NET_DEVICE_WIFI, &profiles, &num_of_profile)) { - LOGD_GEOFENCE("Failed to get the scanned list"); - } else { - LOGD_GEOFENCE("Scan results retrieved successfully. No.of profiles: %d", num_of_profile); - if (num_of_profile > 0 && profiles != NULL) { - int cnt; - for (cnt = 0; cnt < num_of_profile; cnt++) { - net_wifi_profile_info_t *ap_info = &profiles[cnt].ProfileInfo.Wlan; - LOGD_GEOFENCE("BSSID %s", ap_info->bssid); - __check_tracking_list(ap_info->bssid, geofence_server, GEOFENCE_TYPE_WIFI); - } - LOGD_GEOFENCE("Comparing fences with scan results is done.Now emit the status to the application"); - while (tracking_fences) { - tracking_fence_id = GPOINTER_TO_INT(tracking_fences->data); - tracking_fences = g_list_next(tracking_fences); - item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server); - if (item_data && item_data->common_info.type == GEOFENCE_TYPE_WIFI) { - if (item_data->is_wifi_status_in == true) { - __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_IN); - } else { - __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT); - } - item_data->is_wifi_status_in = false; - } - } - } - } - } - - break; -#endif case NET_EVENT_WIFI_POWER_IND: LOGI_GEOFENCE("WIFI ON/OFF indication"); vconf_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED, &wps_state); @@ -1186,6 +1217,7 @@ static void gps_setting_changed_cb(location_method_e method, bool enable, item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server); if (item_data && item_data->common_info.type == GEOFENCE_TYPE_GEOPOINT) { __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT); + item_data->common_info.proximity_status = GEOFENCE_PROXIMITY_UNCERTAIN; } } } @@ -1201,6 +1233,7 @@ static void gps_setting_changed_cb(location_method_e method, bool enable, item_data = __get_item_by_fence_id(tracking_fence_id, geofence_server); if (item_data && item_data->common_info.type == GEOFENCE_TYPE_GEOPOINT) { __emit_fence_inout(geofence_server, item_data->common_info.fence_id, GEOFENCE_FENCE_STATE_OUT); + item_data->common_info.proximity_status = GEOFENCE_PROXIMITY_UNCERTAIN; } } return; @@ -1421,6 +1454,11 @@ static void __stop_geofence_service(gint fence_id, const gchar *app_id, gpointer if (tracking_status == 0) { /*Remove the fence from the tracklist*/ LOGD_GEOFENCE("Setting the fence status as uncertain here..."); + if (fence_id == geofence_server->nearestTrackingFence) { + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan/ Stopped already, error: %d", ret); + } item_data->common_info.status = GEOFENCE_FENCE_STATE_UNCERTAIN; item_data->common_info.proximity_status = GEOFENCE_PROXIMITY_UNCERTAIN; geofence_server->tracking_list = g_list_remove(geofence_server->tracking_list, GINT_TO_POINTER(fence_id)); @@ -2607,9 +2645,11 @@ static void __init_geofencemanager(GeofenceServer *geofence_server) geofence_server->loc_gps_started_by_wps = false; geofence_server->loc_gps_started = false; geofence_server->loc_wps_started = false; + geofence_server->nearestTrackingFence = 0; geofence_server->connectedTrackingWifiFenceId = -1; geofence_server->gps_fix_info = NULL; geofence_server->wps_fix_info = NULL; + g_stpcpy(geofence_server->ble_info, ""); geofence_server->gps_trigger_interval = 1; /* 1 sec by default*/ geofence_server->timer_id = -1; geofence_server->gps_alarm_id = -1; @@ -2782,6 +2822,7 @@ int main(int argc, char **argv) geofence_callbacks cb; cb.bt_conn_state_changed_cb = bt_conn_state_changed; cb.bt_apater_disable_cb = bt_adp_disable; + cb.device_display_changed_cb = device_display_changed_cb; cb.wifi_conn_state_changed_cb = wifi_conn_state_changed; cb.wifi_device_state_changed_cb = wifi_device_state_changed; cb.network_evt_cb = geofence_network_evt_cb; diff --git a/geofence-server/src/geofence_server.h b/geofence-server/src/geofence_server.h index d85bec2..0d5d635 100644 --- a/geofence-server/src/geofence_server.h +++ b/geofence-server/src/geofence_server.h @@ -26,6 +26,8 @@ #include <bluetooth.h> #include <wifi.h> #include <locations.h> +#include <device/display.h> +#include <device/callback.h> #include <network-wifi-intf.h> #include "geofence_server_data_types.h" @@ -50,6 +52,17 @@ typedef void (*geofence_bt_conn_state_changed_cb)(gboolean connected, bt_device_ */ typedef void (*geofence_bt_adapter_disable_cb)(gboolean connected, void *user_data); + +/** + * @brief Device changed callback + * @remarks This callback will be called whenever there is a change in the device display + * @Param[in] type Type of the callback. Here used for diplay + * @Param[out] value state of the display + * @Param[in] user_data The user data to be returned + * @see None. + */ +typedef void (*geofence_device_display_changed_cb)(device_callback_e type, void *value, void *user_data); + /** * @brief Wifi connection status change callback * @remarks This callback will be called when the wifi connection status changes. @@ -116,6 +129,7 @@ typedef void(*geofence_wifi_rssi_level_changed_cb)(wifi_rssi_level_e rssi_level, struct geofence_callbacks_s { geofence_bt_conn_state_changed_cb bt_conn_state_changed_cb; geofence_bt_adapter_disable_cb bt_apater_disable_cb; + geofence_device_display_changed_cb device_display_changed_cb; geofence_wifi_conn_state_changed_cb wifi_conn_state_changed_cb; geofence_wifi_device_state_changed_cb wifi_device_state_changed_cb; geofence_network_event_cb network_evt_cb; diff --git a/geofence-server/src/geofence_server_bluetooth.c b/geofence-server/src/geofence_server_bluetooth.c index 7da4b66..ab79233 100644 --- a/geofence-server/src/geofence_server_bluetooth.c +++ b/geofence-server/src/geofence_server_bluetooth.c @@ -24,6 +24,7 @@ #include "geofence_server_internal.h" #include "geofence_server_db.h" +static int connectedFence = -1; static gboolean __geofence_check_fence_status(int fence_status, GeofenceItemData *item_data) { FUNC_ENTRANCE_SERVER @@ -37,6 +38,44 @@ static gboolean __geofence_check_fence_status(int fence_status, GeofenceItemData return ret; } +static bool __check_for_match(char *str1, char *str2) +{ + if (g_strrstr(str1, str2) == NULL) + return false; + return true; +} + +static void bt_le_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + int ret = BT_ERROR_NONE; + GeofenceServer *geofence_server = (GeofenceServer *) user_data; + LOGI_GEOFENCE("Current addresses: %s", geofence_server->ble_info); + LOGI_GEOFENCE("Received address: %s", info->remote_address); + + if (info == NULL) { + LOGI_GEOFENCE("Stopping scan as there is no BLE address found"); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + return; + } + if (!g_ascii_strcasecmp(geofence_server->ble_info, "")) { + g_stpcpy(geofence_server->ble_info, info->remote_address); + } else if (!__check_for_match(geofence_server->ble_info, info->remote_address)) { /* If duplicate does not exist */ + char *p = g_strjoin(";", geofence_server->ble_info, info->remote_address, NULL); + g_stpcpy(geofence_server->ble_info, p); + g_free(p); + } else { + LOGI_GEOFENCE("Stopping scan. Address: %s already exist in the string %s", info->remote_address, geofence_server->ble_info); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + /* Add the string to the database. */ + if (connectedFence != -1) + geofence_manager_set_ble_info_to_geofence(connectedFence, geofence_server->ble_info); + } +} + static void emit_bt_geofence_proximity_changed(GeofenceServer *geofence_server, int fence_id, int fence_proximity_status) { FUNC_ENTRANCE_SERVER @@ -58,6 +97,14 @@ static void emit_bt_geofence_proximity_changed(GeofenceServer *geofence_server, if (fence_proximity_status != item_data->common_info.proximity_status) { geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, app_id, fence_id, item_data->common_info.access_type, fence_proximity_status, GEOFENCE_PROXIMITY_PROVIDER_BLUETOOTH); + if (fence_proximity_status == GEOFENCE_PROXIMITY_NEAR) { + LOGD_GEOFENCE("BT Fence. Scanning for BLE and storing in DB"); + g_stpcpy(geofence_server->ble_info, ""); + ret = bt_adapter_le_start_scan(bt_le_scan_result_cb, geofence_server); + if (ret != BT_ERROR_NONE) { + LOGE_GEOFENCE("Fail to start ble scan. %d", ret); + } + } item_data->common_info.proximity_status = fence_proximity_status; } @@ -135,14 +182,16 @@ static void __geofence_check_bt_fence_type(gboolean connected, const char *bssid if (connected) { /* connected => FENCE_IN*/ if (__geofence_check_fence_status(GEOFENCE_FENCE_STATE_IN, item_data) == TRUE) { LOGD_GEOFENCE("Emitted to fence_id [%d] GEOFENCE_FENCE_STATE_IN", fence_id); + connectedFence = fence_id; emit_bt_geofence_inout_changed(geofence_server, item_data, GEOFENCE_FENCE_STATE_IN); emit_bt_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_NEAR); } } else { /* disconnected => FENCE_OUT*/ if (__geofence_check_fence_status(GEOFENCE_FENCE_STATE_OUT, item_data) == TRUE) { LOGD_GEOFENCE("Emitted to fence_id [%d] GEOFENCE_FENCE_STATE_OUT", fence_id); + connectedFence = -1; emit_bt_geofence_inout_changed(geofence_server, item_data, GEOFENCE_FENCE_STATE_OUT); - emit_bt_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_FAR); + emit_bt_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); } } } @@ -150,7 +199,6 @@ static void __geofence_check_bt_fence_type(gboolean connected, const char *bssid bt_info_from_db = NULL; bt_info_from_list = NULL; } - LOGD_GEOFENCE("exit"); } @@ -205,6 +253,7 @@ void bt_adp_disable(gboolean connected, void *user_data) if (__geofence_check_fence_status(GEOFENCE_FENCE_STATE_OUT, item_data) == TRUE) { LOGD_GEOFENCE("Emitted to fence_id [%d] GEOFENCE_FENCE_STATE_OUT", fence_id); emit_bt_geofence_inout_changed(geofence_server, item_data, GEOFENCE_FENCE_STATE_OUT); + emit_bt_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); } } } diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index a7c9916..5d11e96 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -209,7 +209,7 @@ static inline int __geofence_manager_db_create_geofence_table(void) char *err = NULL; char *ddl; - ddl = sqlite3_mprintf("CREATE TABLE GeoFence ( fence_id INTEGER PRIMARY KEY AUTOINCREMENT, place_id INTEGER, enable INTEGER, app_id TEXT NOT NULL, geofence_type INTEGER, access_type INTEGER, running_status INTEGER, FOREIGN KEY(place_id) REFERENCES Places(place_id) ON DELETE CASCADE)"); + ddl = sqlite3_mprintf("CREATE TABLE GeoFence ( fence_id INTEGER PRIMARY KEY AUTOINCREMENT, place_id INTEGER, enable INTEGER, app_id TEXT NOT NULL, geofence_type INTEGER, access_type INTEGER, running_status INTEGER, ble_info TEXT, FOREIGN KEY(place_id) REFERENCES Places(place_id) ON DELETE CASCADE)"); if (sqlite3_exec(db_info_s.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { LOGI_GEOFENCE("Failed to execute the DDL (%s)", err); @@ -716,7 +716,7 @@ int geofence_manager_db_init(void) if (__check_db_file()) { LOGW_GEOFENCE("db(%s) file doesn't exist.", GEOFENCE_DB_FILE); - open_flag = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE| SQLITE_OPEN_FULLMUTEX; + open_flag = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX; } else { if (lstat(GEOFENCE_DB_FILE, &stat) < 0) { LOGE_GEOFENCE("Can't get db(%s) information.", GEOFENCE_DB_FILE); @@ -1911,6 +1911,86 @@ int geofence_manager_set_appid_to_geofence(int fence_id, char *appid) } /** + * This function get ble info from DB. + * + * @param[in] fence_id + * @param[in] ble_info + * @return FENCE_ERR_NONE on success, negative values for errors + */ +int geofence_manager_get_ble_info_from_geofence(int fence_id, char **ble_info) +{ + FUNC_ENTRANCE_SERVER; + sqlite3_stmt *state = NULL; + int ret = SQLITE_OK; + const char *tail = NULL; + char *info = NULL; + + char *query = sqlite3_mprintf("SELECT ble_info FROM GeoFence where fence_id = %d;", fence_id); + LOGD_GEOFENCE("current fence id is [%d]", fence_id); + ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail); + if (ret != SQLITE_OK) { + LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle)); + sqlite3_free(query); + return FENCE_ERR_PREPARE; + } + + ret = sqlite3_step(state); + if (ret != SQLITE_ROW) { + LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle)); + sqlite3_finalize(state); + sqlite3_free(query); + return FENCE_ERR_SQLITE_FAIL; + } + + info = (char *) sqlite3_column_text(state, 0); + if (!info || !strlen(info)) { + LOGI_GEOFENCE("ERROR: ble info is NULL!!!"); + } else { + *ble_info = g_strdup(info); + } + + sqlite3_finalize(state); + sqlite3_free(query); + return FENCE_ERR_NONE; +} + +/** + * This function set ble info on DB. + * + * @param[in] fence_id + * @param[in] ble_info + * @return FENCE_ERR_NONE on success, negative values for errors + */ +int geofence_manager_set_ble_info_to_geofence(int fence_id, char *ble_info) +{ + FUNC_ENTRANCE_SERVER; + sqlite3_stmt *state; + int ret = SQLITE_OK; + const char *tail; + + char *query = sqlite3_mprintf("UPDATE GeoFence SET ble_info = %Q where fence_id = %d;", ble_info, fence_id); + + ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail); + if (ret != SQLITE_OK) { + LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle)); + sqlite3_free(query); + return FENCE_ERR_PREPARE; + } + + ret = sqlite3_step(state); + if (ret != SQLITE_DONE) { + LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle)); + sqlite3_finalize(state); + sqlite3_free(query); + return FENCE_ERR_SQLITE_FAIL; + } + + sqlite3_finalize(state); + sqlite3_free(query); + return FENCE_ERR_NONE; +} + +/** * This function get geofence type from DB. * * @param[in] fence_id diff --git a/geofence-server/src/geofence_server_db.h b/geofence-server/src/geofence_server_db.h index 1d17ed4..227d5be 100644 --- a/geofence-server/src/geofence_server_db.h +++ b/geofence-server/src/geofence_server_db.h @@ -47,6 +47,8 @@ int geofence_manager_get_appid_from_places(int place_id, char **appid); int geofence_manager_set_appid_to_places(int place_id, char *appid); int geofence_manager_get_appid_from_geofence(int fence_id, char **appid); int geofence_manager_set_appid_to_geofence(int fence_id, char *appid); +int geofence_manager_get_ble_info_from_geofence(int fence_id, char **ble_info); +int geofence_manager_set_ble_info_to_geofence(int fence_id, char *ble_info); int geofence_manager_get_geofence_type(int fence_id, geofence_type_e *fence_type); int geofence_manager_get_place_id(int fence_id, int *place_id); int geofence_manager_set_geofence_type(int fence_id, geofence_type_e fence_type); diff --git a/geofence-server/src/geofence_server_private.h b/geofence-server/src/geofence_server_private.h index ace6796..729054b 100644 --- a/geofence-server/src/geofence_server_private.h +++ b/geofence-server/src/geofence_server_private.h @@ -40,6 +40,7 @@ extern "C" { #define APP_ID_LEN 64 #define ADDRESS_LEN 64 #define PLACE_NAME_LEN 64 +#define BLE_INFO_LEN 256 /** * The geofence common information structure @@ -163,6 +164,8 @@ typedef struct { int loc_gps_started_by_wps; int loc_gps_started; int loc_wps_started; + char ble_info[BLE_INFO_LEN]; + int nearestTrackingFence; int connectedTrackingWifiFenceId; alarm_id_t timer_id; /* ID for timer source*/ alarm_id_t gps_alarm_id; /* ID for WPS restart timer source*/ diff --git a/geofence-server/src/geofence_server_wifi.c b/geofence-server/src/geofence_server_wifi.c index 31e983d..6587333 100644 --- a/geofence-server/src/geofence_server_wifi.c +++ b/geofence-server/src/geofence_server_wifi.c @@ -58,6 +58,43 @@ static void emit_wifi_geofence_inout_changed(GeofenceServer *geofence_server, in free(app_id); } +static bool __check_for_match(char *str1, char *str2) +{ + if (g_strrstr(str1, str2) == NULL) + return false; + return true; +} + +static void bt_le_scan_result_cb(int result, bt_adapter_le_device_scan_result_info_s *info, void *user_data) +{ + int ret = BT_ERROR_NONE; + GeofenceServer *geofence_server = (GeofenceServer *) user_data; + LOGI_GEOFENCE("Current addresses: %s", geofence_server->ble_info); + LOGI_GEOFENCE("Received address: %s", info->remote_address); + + if (info == NULL) { + LOGI_GEOFENCE("Stopping scan as there is no BLE address found"); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + return; + } + if (!g_ascii_strcasecmp(geofence_server->ble_info, "")) { + g_stpcpy(geofence_server->ble_info, info->remote_address); + } else if (!__check_for_match(geofence_server->ble_info, info->remote_address)) { /* If duplicate does not exist */ + char *p = g_strjoin(";", geofence_server->ble_info, info->remote_address, NULL); + g_stpcpy(geofence_server->ble_info, p); + g_free(p); + } else { + LOGI_GEOFENCE("Stopping scan. Address: %s already exist in the string %s", info->remote_address, geofence_server->ble_info); + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan, error: %d", ret); + /* Add the string to the database. */ + geofence_manager_set_ble_info_to_geofence(geofence_server->connectedTrackingWifiFenceId, geofence_server->ble_info); + } +} + static void emit_wifi_geofence_proximity_changed(GeofenceServer *geofence_server, int fence_id, int fence_proximity_status) { FUNC_ENTRANCE_SERVER @@ -79,9 +116,22 @@ static void emit_wifi_geofence_proximity_changed(GeofenceServer *geofence_server if (fence_proximity_status != item_data->common_info.proximity_status) { geofence_dbus_server_send_geofence_proximity_changed(geofence_server->geofence_dbus_server, app_id, fence_id, item_data->common_info.access_type, fence_proximity_status, GEOFENCE_PROXIMITY_PROVIDER_WIFI); + if (geofence_server->connectedTrackingWifiFenceId == fence_id) { + if (fence_proximity_status == GEOFENCE_PROXIMITY_IMMEDIATE) { + LOGD_GEOFENCE("WIFI Fence. Scanning for BLE and storing in DB"); + g_stpcpy(geofence_server->ble_info, ""); + ret = bt_adapter_le_start_scan(bt_le_scan_result_cb, geofence_server); + if (ret != BT_ERROR_NONE) { + LOGE_GEOFENCE("Fail to start ble scan. %d", ret); + } + } else if (item_data->common_info.proximity_status == GEOFENCE_PROXIMITY_IMMEDIATE) { /* Stopping the scan if state changes from imm to somethingelse */ + ret = bt_adapter_le_stop_scan(); + if (ret != BT_ERROR_NONE) + LOGE_GEOFENCE("Unable to stop the BLE scan/ Stopped already, error: %d", ret); + } + } item_data->common_info.proximity_status = fence_proximity_status; } - if (app_id) free(app_id); } @@ -113,7 +163,6 @@ void wifi_rssi_level_changed(wifi_rssi_level_e rssi_level, void *user_data) state = GEOFENCE_PROXIMITY_NEAR; else state = GEOFENCE_PROXIMITY_FAR; - emit_wifi_geofence_proximity_changed(geofence_server, geofence_server->connectedTrackingWifiFenceId, state); } } @@ -147,6 +196,7 @@ void wifi_device_state_changed(wifi_device_state_e state, void *user_data) if (state == WIFI_DEVICE_STATE_DEACTIVATED) { LOGD_GEOFENCE("Emitted to fence_id [%d] GEOFENCE_FENCE_STATE_OUT", fence_id); emit_wifi_geofence_inout_changed(geofence_server, fence_id, GEOFENCE_FENCE_STATE_OUT); + emit_wifi_geofence_proximity_changed(geofence_server, fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); } } @@ -182,6 +232,7 @@ void __geofence_check_wifi_matched_bssid(wifi_connection_state_e state, char *bs geofence_server->connectedTrackingWifiFenceId = tracking_fence_id; } else if (state == WIFI_CONNECTION_STATE_DISCONNECTED) { emit_wifi_geofence_inout_changed(geofence_server, tracking_fence_id, GEOFENCE_FENCE_STATE_OUT); + emit_wifi_geofence_proximity_changed(geofence_server, tracking_fence_id, GEOFENCE_PROXIMITY_UNCERTAIN); geofence_server->connectedTrackingWifiFenceId = -1; } break; /*Because there cannot be two APs connected at the same time*/ diff --git a/geofence-server/src/server.c b/geofence-server/src/server.c index d86e853..8202b57 100644 --- a/geofence-server/src/server.c +++ b/geofence-server/src/server.c @@ -156,7 +156,7 @@ static void __geofence_bt_adapter_device_discovery_state_changed_cb(int result, g_return_if_fail(geofence_server); if (g_fence_update_cb.bt_discovery_cb) { - LOGD_GEOFENCE("bt_conn_state_changed_cb"); + LOGD_GEOFENCE("bt_adapter_device_discovery_state_changed_cb"); g_fence_update_cb.bt_discovery_cb(result, discovery_state, discovery_info, user_data); } LOGD_GEOFENCE("exit"); @@ -212,6 +212,17 @@ static void __geofence_gps_setting_changed_cb(location_method_e method, bool ena } } +static void __geofence_device_display_changed_cb(device_callback_e type, void *value, void *user_data) +{ + LOGD_GEOFENCE("__geofence_device_display_changed_cb"); + GeofenceServer *geofence_server = (GeofenceServer *)user_data; + g_return_if_fail(geofence_server); + if (g_fence_update_cb.device_display_changed_cb) { + LOGD_GEOFENCE("Device display changed"); + g_fence_update_cb.device_display_changed_cb(type, value, user_data); + } +} + int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) { FUNC_ENTRANCE_SERVER; @@ -315,7 +326,11 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) LOGD_GEOFENCE("location_manager_set_setting_changed_cb() failed(%d)", ret); return -1; } - + ret = device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, __geofence_device_display_changed_cb, geofence_server); + if (DEVICE_ERROR_NONE == ret) { + LOGD_GEOFENCE("device_add_callback() failed(%d)", ret); + return -1; + } return 0; } diff --git a/packaging/geofence-server.spec b/packaging/geofence-server.spec index 603966f..45feb66 100644 --- a/packaging/geofence-server.spec +++ b/packaging/geofence-server.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(capi-location-manager) BuildRequires: pkgconfig(capi-network-wifi) BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(libcore-context-manager) +BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(capi-geofence-manager) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: capi-geofence-manager-plugin-devel |