diff options
author | saerome.kim <saerome.kim@samsung.com> | 2019-07-01 11:20:06 +0900 |
---|---|---|
committer | saerome kim <saerome.kim@samsung.com> | 2019-07-01 11:28:40 +0900 |
commit | 77b067eb9e8ca88f64fe2ea9da6ddc6019856677 (patch) | |
tree | b0954936ea1b79ec6cb23a8ecca3a6a87d934911 /src | |
parent | 29c4ce2d65bbf6f33c58028ad0b52d60c8d77865 (diff) | |
download | ua-plugin-wifi-dummy-77b067eb9e8ca88f64fe2ea9da6ddc6019856677.tar.gz ua-plugin-wifi-dummy-77b067eb9e8ca88f64fe2ea9da6ddc6019856677.tar.bz2 ua-plugin-wifi-dummy-77b067eb9e8ca88f64fe2ea9da6ddc6019856677.zip |
Fixed tizen coding rulessubmit/tizen/20190705.042311submit/tizen/20190702.103155accepted/tizen/unified/20190705.110648accepted/tizen/unified/20190702.234204
Fixed missing sensor plugin interface
Change-Id: Ie095c5d1e11bde88e5c90c58f0e23e6d01e64258
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/wifi-plugin.c | 45 | ||||
-rw-r--r-- | src/wifi-scan.c | 27 | ||||
-rw-r--r-- | src/wifi-util.c | 1 |
3 files changed, 22 insertions, 51 deletions
diff --git a/src/wifi-plugin.c b/src/wifi-plugin.c index 6e6ea4b..95208c8 100644 --- a/src/wifi-plugin.c +++ b/src/wifi-plugin.c @@ -30,14 +30,10 @@ #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) diff --git a/src/wifi-scan.c b/src/wifi-scan.c index 94bf18c..db8f571 100644 --- a/src/wifi-scan.c +++ b/src/wifi-scan.c @@ -28,13 +28,13 @@ struct arping_data *arp_data; -static int __arp_packet_make(const char* mac) +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; - char* source_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 char* mac) +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; diff --git a/src/wifi-util.c b/src/wifi-util.c index 8d9c0f5..e3fe070 100644 --- a/src/wifi-util.c +++ b/src/wifi-util.c @@ -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); |