Fixed tizen coding rules 61/208861/1 accepted/tizen/unified/20190702.234204 accepted/tizen/unified/20190705.110648 submit/tizen/20190702.103155 submit/tizen/20190705.042311
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 1 Jul 2019 02:20:06 +0000 (11:20 +0900)
committersaerome kim <saerome.kim@samsung.com>
Mon, 1 Jul 2019 02:28:40 +0000 (11:28 +0900)
Fixed missing sensor plugin interface

Change-Id: Ie095c5d1e11bde88e5c90c58f0e23e6d01e64258
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
include/wifi-networkmanager.h
include/wifi-plugin.h
include/wifi-scan.h
src/wifi-plugin.c
src/wifi-scan.c
src/wifi-util.c

index eae88bf..ee5129f 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 
 bool __nm_init();
 
-bool __nm_get_interface_name(char** iface_name);
+bool __nm_get_interface_name(char **iface_name);
 
 connection_type_e __nm_get_connection_type();
 
@@ -36,19 +36,19 @@ void __nm_get_connection_profile_handler(connection_profile_h *profile);
 
 void __nm_destroy_profile_iterator();
 
-bool __nm_get_gateway_address(chargateway);
+bool __nm_get_gateway_address(char *gateway);
 
-void __nm_get_linux_arp_table(char* ip_addr, char* mac_addr);
+void __nm_get_linux_arp_table(char *ip_addr, char *mac_addr);
 
-void __nm_get_ips_mac(char* ip_addr, char* mac_addr);
+void __nm_get_ips_mac(char *ip_addr, char *mac_addr);
 
 void __nm_update_network_type(bool isConnect);
 
-bool __nm_get_mac_address(char** dest_mac_addr);
+bool __nm_get_mac_address(char **dest_mac_addr);
 
 char* __nm_get_ip_address(void);
 
-void __nm_get_connected_bssid(char** connect_bssid);
+void __nm_get_connected_bssid(char **connect_bssid);
 
 bool __nm_is_network_connected();
 
index 5629911..1117aed 100644 (file)
@@ -41,7 +41,6 @@ typedef struct {
        char mobile_id[UAS_DEVICE_ID_MAX_LEN]; /**< MObile ID which is saved in DB */
        char mac_addr[MAC_ADDRESS_STRING_SIZE]; /**< MAC address which is saved in DB */
        char ip_addr[IP_ADDRESS_STRING_SIZE]; /**< IP address which is saved in DB */
-       int absence_count; /**< How many detect ABSENCE of the target dev. */
        int mobile_flag; /**< The order of the target dev. */
        gboolean new_device; /**< Is newly added device ?*/
        unsigned int supported_techs; /**< Operating system type of the target dev. */
index 6c748f5..cecbe9d 100644 (file)
@@ -60,8 +60,8 @@ struct arp_message {
        /* ARP packet */
        uint16_t hw_type;/**< hardware type(ARPHRD_ETHER) */
        uint16_t p_type;/**< protocol type(ETH_P_IP) */
-       uint8_t p_len; /**< protocol address length */
        uint8_t hw_len;/**< hardware address length */
+       uint8_t p_len; /**< protocol address length */
        uint16_t operation;/* ARP opcode */
        uint8_t s_hwaddr[MAC_ADD_LENGTH]; /**< sender hardware address */
        uint8_t s_IPaddr[IP_ADD_LENGTH]; /**< sender IP address */
@@ -88,13 +88,13 @@ struct arping_data {
 
 int __initialize_arp_data(void);
 
-int __start_wifi_detection(const char* ip, const char* mac);
+int __start_wifi_detection(const char *ip, const char *mac);
 
-int __start_arp(const char* ip, const char* mac);
+int __start_arp(const char *ip, const char *mac);
 
 int __init_ip_mac_count(void);
 
-int __start_wifi_add_device(const char* ip, const char* mac);
+int __start_wifi_add_device(const char *ip, const char *mac);
 
 bool __is_device_exists(char *device_id);
 
index 6e6ea4b..95208c8 100644 (file)
 #define AUTHOR "Samsung"
 #define VERSION        "0.1"
 
-#define DETECTION_CYCLE_DEFAULT 900 /* 15 minutes -> 15 * 60 = 900 seconds */
-#define DETECTION_PERIOD_DEFAULT 60 /* 1 minute -> 1 * 60 = 60 seconds */
+#define DETECTION_WINDOW_DEFAULT 60 /* 1 minute -> 1 * 60 = 60 seconds */
 #define ABSENCE_THRESHOLD_DEFAULT 1
 
-static int wifi_detection_cycle = DETECTION_CYCLE_DEFAULT;
-static int wifi_detection_period = DETECTION_PERIOD_DEFAULT;
-static int wifi_detection_retries = ABSENCE_THRESHOLD_DEFAULT;
-static guint detection_cycle_timer = 0;
+static int wifi_detection_window = DETECTION_WINDOW_DEFAULT;
 static bool initial_bursts = true;
 
 static gboolean lpm_enabled = FALSE; /**< Low power mode */
@@ -251,8 +247,6 @@ void __check_device_found(char* sbuf, char* ip_sbuf)
                        g_strlcpy(wifi_info->mac_addr, sbuf, MAC_ADDRESS_STRING_SIZE);
                        g_strlcpy(wifi_info->ip_addr, ip_sbuf, IP_ADDRESS_STRING_SIZE);
 
-                       wifi_info->absence_count = 0;
-
                        if (!(UAS_PRESENCE & wifi_detection_type))
                                break;
 
@@ -307,12 +301,7 @@ void __check_mobile_list_finish(bool is_check)
                                continue;
                        }
 
-                       wifi_info->absence_count += 1;
-
-                       UA_WIFI_INFO("absence_count = %d", wifi_info->absence_count);
-
                        if ((UAS_ABSENCE & wifi_detection_type) &&
-                                       (wifi_detection_retries <= wifi_info->absence_count) &&
                                        (uas_cbs && uas_cbs->device_detected_cb)) {
                                dev_info = _wifi_plugin_util_get_dev_info_from_wifi_info(wifi_info);
                                if (!dev_info) {
@@ -332,6 +321,8 @@ void __check_mobile_list_finish(bool is_check)
                if (uas_cbs && uas_cbs->detection_state_cb)
                        uas_cbs->detection_state_cb(0);
 
+               /* Reset detection flags */
+               wifi_detection_type = 0;
        } else {
                if (is_check == true) {
                        initial_bursts = true;
@@ -423,13 +414,6 @@ static int start_detection(unsigned int detection_type)
                return UAS_STATUS_SUCCESS;
        }
 
-       /* Schedule detection cycle */
-       if (0 < detection_cycle_timer)
-               g_source_remove(detection_cycle_timer);
-
-       detection_cycle_timer = g_timeout_add_seconds(
-                       wifi_detection_cycle, __start_wifi_scan, NULL);
-
        /* Start detection */
        __start_wifi_scan(NULL);
 
@@ -452,12 +436,6 @@ static int stop_detection(unsigned int detection_type)
        if (0 != wifi_detection_type)
                goto done;
 
-       /* Remove detection cycle timer */
-       if (0 < detection_cycle_timer) {
-               g_source_remove(detection_cycle_timer);
-               detection_cycle_timer = 0;
-       }
-
 done:
        FUNC_EXIT;
        return UAS_STATUS_SUCCESS;
@@ -476,18 +454,13 @@ static int set_low_power_mode(int mode)
        return UAS_STATUS_SUCCESS;
 }
 
-static int set_detection_params(int detection_cycle,
-               int detection_period, int detection_retries)
+static int set_detection_window(unsigned int detection_window)
 {
        FUNC_ENTER;
 
        retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
-       retv_if(detection_period > detection_cycle, UAS_STATUS_FAIL);
-       retv_if(0 >= detection_retries, UAS_STATUS_FAIL);
 
-       wifi_detection_cycle = detection_cycle;
-       wifi_detection_period = detection_period;
-       wifi_detection_retries = detection_retries;
+       wifi_detection_window = detection_window;
 
        FUNC_EXIT;
        return UAS_STATUS_SUCCESS;
@@ -515,8 +488,10 @@ static uas_api_t wifi_api = {
        .start_detection = start_detection,
        .stop_detection = stop_detection,
        .set_low_power_mode = set_low_power_mode,
-       .set_detection_params = set_detection_params,
-       .set_detection_threshold = set_detection_threshold
+       .set_detection_window = set_detection_window,
+       .set_detection_threshold = set_detection_threshold,
+       .scan_active_devices = NULL,
+       .cancel_active_device_scan = NULL
 };
 
 static int module_init(uas_api_t **api)
index 94bf18c..db8f571 100644 (file)
 
 struct arping_data *arp_data;
 
-static int __arp_packet_make(const charmac)
+static int __arp_packet_make(const char *mac)
 {
        FUNC_ENTER;
        bool ret = false;
        struct ether_addr* source_mac = NULL;
        struct ether_addr* dest_mac = NULL;
-       charsource_mac_address = NULL;
+       char *source_mac_address = NULL;
 
        ret = __nm_get_mac_address(&source_mac_address);
 
@@ -109,7 +109,7 @@ static gboolean clean_socket()
        /* Closing socket descriptor. */
        if (-1 < arp_data->arp_id) {
                if (G_IO_STATUS_NORMAL != g_io_channel_shutdown(
-                       arp_data->arp_sock_io, FALSE, &error)) {
+                               arp_data->arp_sock_io, FALSE, &error)) {
                        UA_WIFI_ERR("Failure received while shutdown io channel[%d]:[%s]",
                                error->code, error->message);
                        g_error_free(error);
@@ -161,7 +161,7 @@ gboolean __arp_packet_receive(GIOChannel *source, GIOCondition condition,
        switch (condition) {
        case G_IO_IN:
                if (g_io_channel_read_chars(
-                       source, buffer, ARP_PACKET_SIZE, &bytes_read, NULL) == G_IO_STATUS_NORMAL) {
+                               source, buffer, ARP_PACKET_SIZE, &bytes_read, NULL) == G_IO_STATUS_NORMAL) {
                        uint32_t target_ip = 0;
 
                        memset(&arp_recv, 0, sizeof(arp_recv));
@@ -271,7 +271,7 @@ gboolean __arp_packet_callback()
        return false;
 }
 
-static int __init_arp(const charmac)
+static int __init_arp(const char *mac)
 {
        struct ifreq net_ifr;
        char error_buf[MAX_SIZE_ERROR_BUFFER];
@@ -351,7 +351,7 @@ static int __init_arp(const char* mac)
        }
 
        if (G_IO_STATUS_NORMAL != g_io_channel_set_encoding(
-               arp_data->arp_sock_io, NULL, NULL)) {
+                       arp_data->arp_sock_io, NULL, NULL)) {
                UA_WIFI_ERR("Failed to set encoding NULL on io channel");
                close(arp_data->arp_id);
                arp_data->arp_id = -1;
@@ -359,7 +359,7 @@ static int __init_arp(const char* mac)
        }
 
        if (G_IO_STATUS_NORMAL != g_io_channel_set_flags(
-               arp_data->arp_sock_io, G_IO_FLAG_NONBLOCK, NULL)) {
+                       arp_data->arp_sock_io, G_IO_FLAG_NONBLOCK, NULL)) {
                UA_WIFI_ERR("Failed to set flags on io channel");
                close(arp_data->arp_id);
                arp_data->arp_id = -1;
@@ -367,7 +367,7 @@ static int __init_arp(const char* mac)
        }
 
        arp_data->arp_data_id = g_io_add_watch(
-               arp_data->arp_sock_io, G_IO_IN, __arp_packet_receive, NULL);
+                       arp_data->arp_sock_io, G_IO_IN, __arp_packet_receive, NULL);
        g_io_channel_unref(arp_data->arp_sock_io);
 
        UA_WIFI_INFO("Init arp socket success");
@@ -422,9 +422,6 @@ gboolean __send_arp_unimul_packet_timeout(gpointer user_data)
                arp_data->arp.s_IPaddr[0], arp_data->arp.s_IPaddr[1],
                arp_data->arp.s_IPaddr[2], arp_data->arp_send_ip_addr);
 
-       if (arp_target_ip[0])
-               UA_WIFI_INFO("Arp source ip: %s", arp_target_ip);
-
        target_ip = inet_addr(ip_buff);
        memcpy(arp_target_ip, ip_buff, strlen(ip_buff));
        memcpy(arp_data->arp.t_IPaddr, &target_ip, IP_ADD_LENGTH); // target IP address
@@ -466,7 +463,7 @@ static void __send_arp_uni_mode(const char* ip)
        UA_WIFI_INFO("Send %d UNICAST ARP Packet", arp_data->arp_mac_count);
 }
 
-static int __arp_make_send(const char* ip, const char* mac)
+static int __arp_make_send(const char *ip, const char *mac)
 {
        FUNC_ENTER;
        int ret;
@@ -495,7 +492,7 @@ static int __arp_make_send(const char* ip, const char* mac)
        return UAS_STATUS_SUCCESS;
 }
 
-int __start_arp(const char* ip, const char* mac)
+int __start_arp(const char *ip, const char *mac)
 {
        int ret;
 
@@ -527,7 +524,7 @@ int __init_ip_mac_count(void)
        return UAS_STATUS_SUCCESS;
 }
 
-int __start_wifi_detection(const char* ip, const char* mac)
+int __start_wifi_detection(const char *ip, const char *mac)
 {
        int ret;
 
@@ -543,7 +540,7 @@ int __start_wifi_detection(const char* ip, const char* mac)
        return ret;
 }
 
-int __start_wifi_add_device(const char* ip, const char* mac)
+int __start_wifi_add_device(const char *ip, const char *mac)
 {
        int ret;
 
index 8d9c0f5..e3fe070 100644 (file)
@@ -37,7 +37,6 @@ uas_wifi_info_t *_wifi_plugin_util_get_wifi_info_from_dev_info(
        wifi_info = g_new0(uas_wifi_info_t, 1);
        wifi_info->user_id = dev_info->user_id;
        wifi_info->os = dev_info->os;
-       wifi_info->absence_count = 0;
        wifi_info->supported_techs = dev_info->supported_techs;
 
        g_strlcpy(wifi_info->mobile_id, dev_info->device_id, UAS_DEVICE_ID_MAX_LEN);