From 69172a3309fd1ff756927a6be115312b2eba0b34 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Wed, 29 Nov 2017 15:30:59 +0530 Subject: [PATCH] wifi-mesh: Add station type in STATION_JOIN/STATION_LEFT event Change-Id: I0b92c2ecdc8b9ada619d1a863f000bd9dacb0151 Signed-off-by: Saurav Babu --- include/wifi-mesh.h | 10 ++++++++++ src/wifi-mesh-dbus.c | 8 ++++++-- test/main.c | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h index e0abd97..c717744 100644 --- a/include/wifi-mesh.h +++ b/include/wifi-mesh.h @@ -141,6 +141,15 @@ typedef enum { WIFI_MESH_IP_CONFIG_TYPE_STATIC /**< Static IP Config Type */ } wifi_mesh_ip_config_type_e; +/** + * @brief Enumeration for the station type of the Wi-Fi Mesh network. + * @since_tizen 5.0 + */ +typedef enum { + MESH_STATION_TYPE_MESH_POINT = 0, /**< Mesh Point Station */ + MESH_STATION_TYPE_SOFTAP, /**< SoftAP Station */ +} wifi_mesh_station_type_e; + /** * @brief The events for wifi_mesh_event_cb * @@ -172,6 +181,7 @@ typedef struct { */ typedef struct { char bssid[MAX_BSSID_LEN]; /**< The BSSID of the station that generated the event */ + wifi_mesh_station_type_e station_type; /**< Type of Station */ } wifi_mesh_other_station_event_s; /** diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index 02821ef..bbdb3d2 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -387,24 +387,28 @@ static void _mesh_signal_handler(GDBusConnection *connection, free(ev.data.connection_state); } else if (0 == g_strcmp0(signal_name, "sta_joined")) { char *bssid = NULL; + int station_type = -1; wifi_mesh_event_data_s ev; ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); if (NULL == ev.data.sta_info) LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE - g_variant_get(parameters, "(s)", &bssid); + g_variant_get(parameters, "(si)", &bssid, &station_type); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); + ev.data.sta_info->station_type = station_type; h->event_handler(WIFI_MESH_EVENT_STATION_JOIN, &ev, h->event_handler_user_data); free(ev.data.sta_info); } else if (0 == g_strcmp0(signal_name, "sta_left")) { char *bssid = NULL; + int station_type = -1; wifi_mesh_event_data_s ev; ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); if (NULL == ev.data.sta_info) LOGE("Failed to memory allocation !"); // LCOV_EXCL_LINE - g_variant_get(parameters, "(s)", &bssid); + g_variant_get(parameters, "(si)", &bssid, &station_type); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); + ev.data.sta_info->station_type = station_type; h->event_handler(WIFI_MESH_EVENT_STATION_LEFT, &ev, h->event_handler_user_data); free(ev.data.sta_info); diff --git a/test/main.c b/test/main.c index 3af4b59..d108ba8 100644 --- a/test/main.c +++ b/test/main.c @@ -86,6 +86,16 @@ const char* wifi_mesh_connection_event_to_string(wifi_mesh_connection_state_e e) } } +static const char *wifi_mesh_sta_type_to_string(wifi_mesh_station_type_e e) +{ + switch (e) { + CASE_TO_STR(MESH_STATION_TYPE_MESH_POINT) + CASE_TO_STR(MESH_STATION_TYPE_SOFTAP) + default : + return "Unknown station type"; + } +} + void event_cb(wifi_mesh_event_e event_type, wifi_mesh_event_data_s* event, void *user_data) { @@ -109,10 +119,14 @@ void event_cb(wifi_mesh_event_e event_type, wifi_mesh_event_data_s* event, (MESH_SECURITY_SAE == event->data.connection_state->security) ? "SAE" : "NONE"); } break; case WIFI_MESH_EVENT_STATION_JOIN: { - msgp(" New Station Joined = %s", event->data.sta_info->bssid); + msgp(" New Station of type %s Joined = %s", + wifi_mesh_sta_type_to_string(event->data.sta_info->station_type), + event->data.sta_info->bssid); } break; case WIFI_MESH_EVENT_STATION_LEFT: { - msgp(" A Station Left = %s", event->data.sta_info->bssid); + msgp(" A Station of type %s Left = %s", + wifi_mesh_sta_type_to_string(event->data.sta_info->station_type), + event->data.sta_info->bssid); } break; default: msgr(" Unexpected event !"); -- 2.34.1