wifi-mesh: Add station type in STATION_JOIN/STATION_LEFT event 67/162167/1
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 29 Nov 2017 10:00:59 +0000 (15:30 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Wed, 29 Nov 2017 10:00:59 +0000 (15:30 +0530)
Change-Id: I0b92c2ecdc8b9ada619d1a863f000bd9dacb0151
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wifi-mesh.h
src/wifi-mesh-dbus.c
test/main.c

index e0abd9738934259c46b6d59523538b06eb7b9afa..c717744baea0552bb1384d4b60e8a72dd66605f8 100644 (file)
@@ -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;
 
 /**
index 02821efad2076706e6387b2c7b7eb78552d33517..bbdb3d2a2bf51db8de9439ba2eeb73adf4418247 100644 (file)
@@ -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);
index 3af4b5966b59f477a5fc7fe3954a36999c978d76..d108ba805c22871b13989c5da669933c6575c7ff 100644 (file)
@@ -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 !");