Add wifi location plugin support 83/260383/1
authorAbhay Agarwal <ay.agarwal@samsung.com>
Wed, 6 Jan 2021 09:48:46 +0000 (15:18 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 24 Jun 2021 04:09:34 +0000 (09:39 +0530)
This patch updates the enums, convert functions to
support wifi-location plugin.

Change-Id: I7f8d398708d5d6c4559d7f4d4c0fedd7ca6af6ee
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
include/ua-api.h
ua-daemon/src/pm/ua-plugin-handler.c
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/ua-manager-core.c
ua-plugins/include/ua-plugin.h

index 8ac4301..25323e0 100755 (executable)
@@ -39,7 +39,8 @@ typedef enum {
        UAM_SENSOR_BITMASK_WIFI = 0x00000004, /**< Bitmask for Wi-Fi */
        UAM_SENSOR_BITMASK_MOTION = 0x00000008, /**< Bitmask for motion */
        UAM_SENSOR_BITMASK_LIGHT = 0x00000010, /**< Bitmask for light */
-       UAM_SENSOR_BITMASK_AUDIO = 0x00000020, /**< Bitmask for autio */
+       UAM_SENSOR_BITMASK_AUDIO = 0x00000020, /**< Bitmask for audio */
+       UAM_SENSOR_BITMASK_WIFI_LOCATION = 0x00000040, /**< Bitmask for wifi location */
        UAM_SENSOR_ALL = 0xFFFFFFFF, /**< Bitmask for all sensors */
 } uam_sensor_bitmask_e;
 
@@ -489,6 +490,7 @@ typedef enum {
        UAM_TECH_TYPE_BLE = 0x02, /**< BLE */
        UAM_TECH_TYPE_WIFI = 0x04, /**< Wi-Fi */
        UAM_TECH_TYPE_P2P = 0x08, /**< Wi-Fi p2p */
+       UAM_TECH_TYPE_WIFI_LOCATION = 0x10, /**< Wi-Fi location */
        UAM_TECH_TYPE_MAX /**< Max. connectivity type */
 } uam_tech_type_e;
 
index a5151ad..47acfa1 100644 (file)
@@ -135,6 +135,7 @@ static void device_detected_callback(int id,
 
        dev_info = _pm_util_uas_dev_info_to_uam_dev_info(device);
        ret_if(NULL == dev_info);
+       dev_info->type = _pm_util_uas_plugin_id_to_tech_type(id);
 
        if (device->payload) {
                payload = g_new0(uam_ble_payload_s, 1);
@@ -210,7 +211,7 @@ static void device_active_scan_callback(int id,
                dev_info = _pm_util_uas_dev_info_to_uam_dev_info(device);
                ret_if(NULL == dev_info);
 
-               dev_info->type = UAM_TECH_TYPE_WIFI;
+               dev_info->type = _pm_util_uas_plugin_id_to_tech_type(id);
        }
 
        event_info = _pm_util_uas_scan_event_to_uam_scan_event(event);
index 1eb9240..8af601b 100644 (file)
@@ -483,26 +483,29 @@ int _uam_pm_set_registered_devices(GSList *devices, unsigned int bitmask)
 {
        FUNC_ENTRY;
        int id;
-       uas_device_info_t *dev_list = NULL;
-       int num_devices = 0;
 
        for (id = UAS_PLUGIN_ID_BLE; id < UAS_PLUGIN_ID_MAX; id++) {
+               uas_device_info_t *dev_list = NULL;
+               int num_devices = 0;
                uam_sensor_plugin_info_t *plugin = plugins[id];
                unsigned int sensor = _pm_util_uas_plugin_id_to_sensor_bitmask(id);
 
                if (!(sensor & bitmask))
                        continue;
 
-               if (!plugin || !plugin->api)
+               if (!plugin || !plugin->api || !plugin->api->set_registered_devices)
                        continue;
 
                if (UAS_SUPPORT_USER != plugin->capability)
                        continue;
 
                dev_list = __get_uas_device_list(id, devices, &num_devices);
-               if (!dev_list)
+               if (!dev_list) {
                        UAM_INFO("No devices for Plugin %d", id);
+                       continue;
+               }
 
+               UAM_INFO("set registered devices");
                if (UAS_STATUS_SUCCESS != plugin->api->set_registered_devices(
                                        num_devices, dev_list))
                        UAM_ERR("plugin->set_registered_devices() failed for %d", id);
index 0db6427..3a107e8 100644 (file)
@@ -48,6 +48,8 @@ unsigned int _pm_util_uas_plugin_id_to_sensor_bitmask(uas_plugin_id_e id)
                return UAM_SENSOR_BITMASK_LIGHT;
        case UAS_PLUGIN_ID_MOTION:
                return UAM_SENSOR_BITMASK_MOTION;
+       case UAS_PLUGIN_ID_WIFI_LOCATION:
+               return UAM_SENSOR_BITMASK_WIFI_LOCATION;
        default:
                UAM_WARN("Unknown Plugin id 0x%8.8X", id);
                return 0;
@@ -61,6 +63,8 @@ unsigned int _pm_util_uam_tech_type_to_plugin_id(uam_tech_type_e type)
                return UAS_PLUGIN_ID_BLE;
        case UAM_TECH_TYPE_WIFI:
                return UAS_PLUGIN_ID_WIFI;
+       case UAM_TECH_TYPE_WIFI_LOCATION:
+               return UAS_PLUGIN_ID_WIFI_LOCATION;
        default:
                UAM_WARN("Unknown type 0x%8.8X", type);
                return UAS_PLUGIN_ID_MAX;
@@ -74,6 +78,8 @@ unsigned int _pm_util_uas_plugin_id_to_tech_type(uas_plugin_id_e id)
                return UAM_TECH_TYPE_BLE;
        case UAS_PLUGIN_ID_WIFI:
                return UAM_TECH_TYPE_WIFI;
+       case UAS_PLUGIN_ID_WIFI_LOCATION:
+               return UAM_TECH_TYPE_WIFI_LOCATION;
        default:
                UAM_WARN("Unknown Plugin id 0x%8.8X", id);
                return UAM_TECH_TYPE_NONE;
@@ -131,6 +137,25 @@ uas_address_type_e _pm_util_uam_addr_type_to_uas_addr_type(uam_addr_type_e type)
        }
 }
 
+uas_address_type_e _pm_util_uam_tech_type_to_uas_addr_type(uam_tech_type_e type)
+{
+       switch (type) {
+       case UAM_TECH_TYPE_BT:
+               return UAS_ADDR_TYPE_BT;
+       case UAM_TECH_TYPE_BLE:
+               return UAS_ADDR_TYPE_BLE;
+       case UAM_TECH_TYPE_P2P:
+               return UAS_ADDR_TYPE_P2P;
+       case UAM_TECH_TYPE_WIFI:
+               return UAS_ADDR_TYPE_WIFI;
+       case UAM_TECH_TYPE_WIFI_LOCATION:
+               return UAS_ADDR_TYPE_WIFI;
+       default:
+               UAM_WARN("Unknown type 0x%8.8X", type);
+               return UAS_PLUGIN_ID_MAX;
+       }
+}
+
 void _pm_util_uam_db_payload_to_uas_payload(
                uas_payload_info_t *dst_payload, uam_db_payload_info_t *src_payload)
 {
@@ -303,22 +328,7 @@ uas_device_info_t *_pm_util_uam_dev_info_to_uas_dev_info(const uam_device_info_s
        device->discriminant = dev->discriminant;
 
        if (0 < strlen(dev->mac)) {
-               switch (dev->type) {
-               case UAM_TECH_TYPE_BLE:
-                       type = UAS_ADDR_TYPE_BLE;
-                       break;
-               case UAM_TECH_TYPE_BT:
-                       type = UAS_ADDR_TYPE_BT;
-                       break;
-               case UAM_TECH_TYPE_P2P:
-                       type = UAS_ADDR_TYPE_P2P;
-                       break;
-               case UAM_TECH_TYPE_WIFI:
-                       type = UAS_ADDR_TYPE_WIFI;
-                       break;
-               default:
-                       UAM_ERR("Unknown tech type: %d", dev->type);
-               }
+               type =  _pm_util_uam_tech_type_to_uas_addr_type(dev->type);
 
                if (UAS_ADDR_TYPE_INVALID != type) {
                        mac = g_strdup(dev->mac);
index 75d1685..39f179b 100755 (executable)
@@ -733,6 +733,8 @@ static unsigned int __uam_core_tech_type_to_addr_type(uam_tech_type_e tech_type)
                return UAM_ADDR_TYPE_P2P;
        case UAM_TECH_TYPE_WIFI:
                return UAM_ADDR_TYPE_WIFI;
+       case UAM_TECH_TYPE_WIFI_LOCATION:
+               return UAM_ADDR_TYPE_WIFI;
        default:
                UAM_ERR("Unknown tech type: %d", tech_type);
                return 0;
@@ -746,6 +748,8 @@ static unsigned int __uam_core_sensor_to_tech_type(unsigned int sensor)
                return UAM_TECH_TYPE_BLE;
        case UAM_SENSOR_BITMASK_WIFI:
                return UAM_TECH_TYPE_WIFI;
+       case UAM_SENSOR_BITMASK_WIFI_LOCATION:
+               return UAM_TECH_TYPE_WIFI_LOCATION;
        default:
                UAM_ERR("Unknown sensor: %d", sensor);
                return 0;
@@ -759,6 +763,8 @@ static unsigned int __uam_core_tech_type_to_sensor(unsigned int tech_type)
                return UAM_SENSOR_BITMASK_BLE;
        case UAM_TECH_TYPE_WIFI:
                return UAM_SENSOR_BITMASK_WIFI;
+       case UAM_TECH_TYPE_WIFI_LOCATION:
+               return UAM_SENSOR_BITMASK_WIFI_LOCATION;
        default:
                UAM_ERR("Unknown tech type: %d", tech_type);
                return 0;
@@ -1405,7 +1411,7 @@ static void __uam_core_add_dev_to_list(
        /* Add tech info to tech list */
        device->tech_list = g_slist_append(device->tech_list, tech);
        device->supported_techs |= tech->tech_type;
-       UAM_INFO("device->supported_techs: %8.8X", device->supported_techs);
+       UAM_INFO("device->supported_techs: 0x%8.8X", device->supported_techs);
 
        if (0 < strlen(dev_info->mac)) {
                uam_db_address_info_t *addr;
index b36fa16..ffe04a7 100644 (file)
@@ -333,6 +333,7 @@ typedef enum {
        UAS_PLUGIN_ID_WIFI,
        UAS_PLUGIN_ID_LIGHT,
        UAS_PLUGIN_ID_MOTION,
+       UAS_PLUGIN_ID_WIFI_LOCATION,
        UAS_PLUGIN_ID_MAX
 } uas_plugin_id_e;