Supoort to add iBeacon Adv data in BLE Plugin
authorAbhay agarwal <ay.agarwal@samsung.com>
Wed, 28 Aug 2019 08:18:53 +0000 (13:48 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Fri, 30 Aug 2019 04:29:42 +0000 (13:29 +0900)
Change-Id: Iffacdd262e02c6d7cbeec3b93404c383207c6f24
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
ua-daemon/include/ua-plugin-manager.h
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/ua-manager-core.c
ua-plugins/include/ua-plugin.h

index cc2fcc3..564e8fd 100644 (file)
@@ -61,6 +61,8 @@ int _uam_pm_start_active_device_scan(unsigned int* bitmask, int detection_period
 
 int _uam_pm_stop_active_device_scan(unsigned int bitmask);
 
+int _uam_pm_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
+
 #ifdef __cplusplus
 }
 #endif
index ea2aa64..1146fc0 100755 (executable)
@@ -730,3 +730,28 @@ int _uam_pm_stop_active_device_scan(unsigned int bitmask)
        FUNC_EXIT;
        return ret;
 }
+
+int _uam_pm_add_ibeacon_adv(unsigned int adv_len, const char *iadv)
+{
+       FUNC_ENTRY;
+       int id;
+       int status;
+       int ret = UAM_ERROR_INTERNAL;
+
+       id = UAS_PLUGIN_ID_BLE;
+       uam_sensor_plugin_info_t *plugin = plugins[id];
+
+       if (!plugin || !plugin->api || !plugin->api->add_ibeacon_adv)
+               goto done;
+
+       status = plugin->api->add_ibeacon_adv(adv_len, iadv);
+       if (UAS_STATUS_SUCCESS != status && UAS_STATUS_ALREADY_DONE != status) {
+               UAM_ERR("plugin->add_ibeacon_adv failed for %d", id);
+               goto done;
+       }
+       ret = UAM_ERROR_NONE;
+
+done:
+       FUNC_EXIT;
+       return ret;
+}
index 9e95c6d..d441e90 100644 (file)
@@ -3209,14 +3209,23 @@ int _uam_core_get_services(int *count, uam_service_info_s **service_list)
 int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv)
 {
        FUNC_ENTRY;
+       int ret;
 
        UAM_INFO("adv_len = %u, iadv = 0x%0x:0x%0x:0x%0x", adv_len,
                iadv[0], iadv[1], iadv[2]);
+
        if (UAM_ERROR_NONE != _uam_db_insert_adv_info(adv_len, iadv)) {
                UAM_ERR("_uam_db_insert_adv_info failed");
                return UAM_ERROR_DB_FAILED;
        }
 
+       ret = _uam_pm_add_ibeacon_adv(adv_len, iadv);
+       if (UAM_ERROR_NONE != ret) {
+               UAM_ERR("Failed with error: %s (0x%4.4X)",
+                               _uam_manager_error_to_str(ret), ret);
+               return ret;
+       }
+
        FUNC_EXIT;
        return UAM_ERROR_NONE;
 }
index 5a6e02a..3e4d60c 100644 (file)
@@ -284,6 +284,15 @@ typedef struct {
         * [Async API] To cancel the ongoing active devices search.
         */
        int (*cancel_active_device_scan)(void);
+
+       /*
+        * [Sync API] To set iBeacon adv data in plug-in.
+        *
+        * [Param] adv_len - The value of length of iBeacon adv data to add.
+        *
+        * [Param] iadv - iBeacon adv data to be add.
+        */
+       int (*add_ibeacon_adv)(unsigned int adv_len, const char *iadv);
 } uas_api_t;
 
 typedef enum {