* @since_tizen 4.0
*/
typedef enum {
- MESH_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ MESH_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
MESH_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MESH_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
- MESH_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ MESH_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
+ MESH_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
MESH_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
- MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */
- MESH_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESH|0x01, /**< Operation failed */
- MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH|0x02, /**< Operation is aborted */
- MESH_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */
- MESH_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */
- MESH_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */
+ MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */
+ MESH_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESH|0x01, /**< Operation failed */
+ MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH|0x02, /**< Operation is aborted */
+ MESH_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */
+ MESH_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */
+ MESH_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */
} mesh_error_e;
/**
* @since_tizen 4.0
*/
typedef enum {
- MESH_STATE_DEACTIVATED = 0, /**< Mesh network is Deactivated */
- MESH_STATE_ACTIVATED = 1, /**< Mesh network is activated */
+ MESH_STATE_DEACTIVATED = 0, /**< Mesh network is Deactivated */
+ MESH_STATE_ACTIVATED = 1, /**< Mesh network is activated */
} mesh_state_e;
/**
* @{
*/
+
+/**
+ * @brief The mesh network profile handle.
+ * @since_tizen 4.0
+*/
+typedef void* mesh_network_h;
+
+/**
+ * @brief The mesh station information handle.
+ * @since_tizen 4.0
+*/
+typedef void* mesh_station_info_h;
+
+/**
+ * @brief The mesh path information handle.
+ * @since_tizen 4.0
+*/
+typedef void* mesh_path_info_h;
+
/**
* @brief Initializes Mesh network.
* @since_tizen 4.0
* if mesh service is no longer needed.
*
* @param[in] handle The mesh handle
- * @param[in] interface The interface name of mesh network
* @param[in] event_handler The event handler
*
* @return 0 on success, otherwise a negative error value.
* @see mesh_disable()
*
*/
-int mesh_enable(mesh_h handle, const char* interface, mesh_event_cb event_handler);
+int mesh_enable(mesh_h handle, mesh_event_cb event_handler);
/**
* @brief disable the mesh service.
*/
int mesh_cancel_scan(mesh_h handle);
+/**
+ * @brief
+ * @details This function can receive scan results from mesh network.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[out] network mesh bss information handle
+ * @param[out] user_data user data pointer
+ *
+ * @pre The callback must be registered with mesh_enable()
+ *
+ * @see mesh_foreach_found_mesh_netwrok()
+ */
+typedef void (*mesh_found_mesh_netwrok_cb)(mesh_network_h network, void* user_data);
+
+/**
+ * @brief
+ * @details
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] handle The mesh handle
+ * @param[in] cb callback function pointer to inform bss information
+ * @param[in] user_data user data pointer
+ *
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
+ *
+ * @see mesh_scan()
+ * @see mesh_found_mesh_netwrok_cb()
+ *
+ */
+int mesh_foreach_found_mesh_netwrok(mesh_h handle, mesh_found_mesh_netwrok_cb cb, void *user_data);
+
/**
* @brief Get information of all connected stations.
* @details Get information about all stations present in the currently connected mesh network.
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
+ * @param[out] station The mesh station information handle
*
*
* @return 0 on success, otherwise a negative error value.
* @see mesh_deinitialize()
*
*/
-int mesh_get_station_info(mesh_h handle);
+int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
/**
* @brief Get information of all mesh paths.
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
+ * @param[out] path The mesh path information handle
*
*
* @return 0 on success, otherwise a negative error value.
* @see mesh_deinitialize()
*
*/
-int mesh_get_mpath_info(mesh_h handle);
+int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
/**
* @brief Join into specific mesh network.
int _mesh_dbus_start(mesh_h m);
int _mesh_dbus_stop(mesh_h m);
-int _mesh_enable(mesh_h handle, const char* interface, mesh_event_cb event_handler);
+int _mesh_enable(mesh_h handle, mesh_event_cb event_handler);
int _mesh_disable(mesh_h handle);
int _mesh_scan(mesh_h handle);
int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel);
int _mesh_cancel_scan(mesh_h handle);
-int _mesh_get_station_info(mesh_h handle);
-int _mesh_get_mpath_info(mesh_h handle);
+int _mesh_get_station_info(mesh_h handle, void *station);
+int _mesh_get_path_info(mesh_h handle, void *mpath_data);
int _mesh_join(mesh_h handle, const char* ssid);
int _mesh_is_joined(mesh_h handle, int is_joined);
int _mesh_disjoin(mesh_h handle);
#endif
} mesh_handle_s;
+struct mesh_found_network_s {
+ char *meshid; /**< meshid */
+ char *bssid; /**< bssid */
+ int channel; /**< channel */
+ int rssi; /**< rssi */
+ int data_rate; /**< data rate */
+};
+
+struct mesh_station_info_s {
+ char *station; /* station bssid ex) 7c:dd:90:62:37:cf (on mesh0) */
+ guint inactive_time; /**< inactive time ex) 1685 ms */
+ guint rx_bytes; /**< rx bytes ex) 34174 */
+ guint rx_packets; /**< rx packet ex) 1181 */
+ guint tx_bytes; /**< tx bytes ex) 6877 */
+ guint tx_packets; /**< tx packets ex) 76 */
+ guint tx_retries; /**< tx retries ex) 0 */
+ guint tx_failed; /**< tx failed ex) 0 */
+ guint beacon_loss; /**< beacon loss count ex) 0 */
+ int signal; /**< -64 dBm */
+ int signal_avg; /**< -63 dBm */
+ guint tx_bitrate; /**< tx bitrate ex) 54.0 MBit/s => 540 */
+ guint rx_bitrate; /**< rx bitrate ex) 5.5 MBit/s => 55 */
+ guint mesh_llid; /**< mesh_llid ex) 51731 */
+ guint mesh_plid; /**< mesh plid ex) 35432 */
+ char *mesh_plink; /**< mesh plink ex) ESTAB */
+ char *mesh_local_PS_mode; /**< mesh local power save mode ex) ACTIVE */
+ char *mesh_peer_PS_mode; /**< mesh peer power save mode ex) ACTIVE */
+ char *mesh_non_peer_PS_mode; /**< mesh non-peer power save mode ex) ACTIVE */
+ bool authorized; /**< autorized ex) yes */
+ bool authenticated; /**< authenticated ex) yes */
+ bool associated; /**< associated ex) yes */
+ char *preamble; /**< preamble ex) long */
+ bool WMM_WME; /**< WMM/WME supported ex) yes */
+ bool MFP; /**< MFP ex) no */
+ bool TDLS_peer; /**< TDLS peer ex) no */
+ guint DTIM_period; /**< DTIM period ex) 0 */
+ guint beacon_interval; /**< beacon interbal ex) 1000 */
+ guint short_slot_time; /**< short slot time supported ex) yes */
+ guint connected_time; /**< connected time : ex) 256 seconds */
+};
+
+struct mesh_mpath_dump_s {
+ char *dest_addr; /**< destination address */
+ char *next_hop; /**< next hop address */
+ char *iface; /**< network interface for mesh */
+ int sn; /**< sequence number */
+ int metric; /**< metric */
+ int qlen; /**< driver queue length */
+ int exptime; /**< expire time */
+ int dtim; /**< DTIM interval */
+ int dret; /**< dret */
+ int flags; /**< flags */
+};
+
const char* _mesh_internal_error_to_string(mesh_internal_err_e err);
#endif /* __CAPI_MESH_PRIVATE_H__ */
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_enable(mesh_h handle, const char* interface,
- mesh_event_cb event_handler)
+EXPORT_API int mesh_enable(mesh_h handle, mesh_event_cb event_handler)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
- RETV_IF(NULL == interface, MESH_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_enable(handle, interface, event_handler);
+ rv = _mesh_enable(handle, event_handler);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_get_station_info(mesh_h handle)
+EXPORT_API int mesh_get_station_info(mesh_h handle, mesh_station_info_h station)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_get_station_info(handle);
+ rv = _mesh_get_station_info(handle, station);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_get_mpath_info(mesh_h handle)
+EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_get_station_info(handle);
+ rv = _mesh_get_path_info(handle, path);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return rv;
}
-int _mesh_enable(mesh_h handle, const char* interface, mesh_event_cb event_handler)
+struct mesh_network_list_s {
+ int count;
+ GList *list;
+};
+struct mesh_network_list_s g_networks;
+
+static void _mesh_free_network(gpointer data)
+{
+ struct mesh_found_network_s *network = data;
+ g_free(network->meshid);
+ g_free(network->bssid);
+ g_free(network);
+ network = NULL;
+}
+
+static void _mesh_append_network(gpointer data)
+{
+ g_networks.list = g_list_append(g_networks.list, data);
+ g_networks.count++;
+}
+
+static void _mesh_remove_networks()
+{
+ g_list_free_full(g_networks.list, _mesh_free_network);
+ g_networks.count = 0;
+}
+
+struct mesh_mpath_list_s {
+ int count;
+ GList *list;
+};
+struct mesh_mpath_list_s g_mpath;
+
+static void _mesh_free_mpath(gpointer data)
+{
+ struct mesh_mpath_dump_s *mpath = data;
+ g_free(mpath->dest_addr);
+ g_free(mpath->next_hop);
+ g_free(mpath->iface);
+ g_free(mpath);
+ mpath = NULL;
+}
+
+static void _mesh_add_mpath(gpointer data)
+{
+ g_mpath.list = g_list_append(g_mpath.list, data);
+ g_mpath.count++;
+}
+
+static void _mesh_remove_mpath()
+{
+ g_list_free_full(g_mpath.list, _mesh_free_mpath);
+ g_mpath.count = 0;
+}
+
+int _mesh_enable(mesh_h handle, mesh_event_cb event_handler)
{
GVariant *variant = NULL;
unsigned int result;
RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "enable",
- g_variant_new("(s)", interface),
+ NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
GError *error = NULL;
struct mesh_handle *h = handle;
+ _mesh_remove_networks();
+ _mesh_remove_mpath();
+
RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
return MESH_ITNL_ERR_NONE;
}
-int _mesh_get_station_info(mesh_h handle)
+int _mesh_foreach_found_mesh_netwrok(mesh_h handle,
+ mesh_found_mesh_netwrok_cb cb, void *user_data)
+{
+ GVariant *variant = NULL;
+ unsigned int result;
+ GError *error = NULL;
+ struct mesh_handle *h = handle;
+
+ GVariant *params = NULL;
+ GVariant *inner_params = NULL;
+ GVariantIter iter, inner_iter;
+
+ gchar *key;
+ GVariant *val;
+ gsize len = 0;
+
+ _mesh_remove_networks();
+
+ RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+ RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_found_mesh_networks",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+ if (variant) {
+ /* handle station list here */
+ g_variant_get(variant, "(a(a{sv})u)", ¶ms, &result);
+
+ g_variant_iter_init(&iter, params);
+ while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+
+ struct mesh_found_network_s *network_info =
+ g_malloc0(sizeof(struct mesh_found_network_s));
+
+ g_variant_iter_init(&inner_iter, inner_params);
+ while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "meshid") == 0) {
+ network_info->meshid = g_variant_dup_string(val, &len);
+ LOGE("meshid=%s", network_info->meshid);
+ }
+ else if (strcasecmp(key, "bssid") == 0) {
+ network_info->bssid = g_variant_dup_string(val, &len);
+ LOGE("bssid = %s", network_info->bssid);
+ }
+ else if (strcasecmp(key, "channel") == 0) {
+ network_info->channel = g_variant_get_int32(val);
+ LOGE("channel = %d", network_info->channel);
+ }
+ else if (strcasecmp(key, "rssi") == 0) {
+ network_info->rssi = g_variant_get_int32(val);
+ LOGE("rssi = %d", network_info->rssi);
+ }
+ else if (strcasecmp(key, "data_rate") == 0) {
+ network_info->data_rate = g_variant_get_int32(val);
+ LOGE("data_rate = %d", network_info->data_rate);
+ /* Last element */
+ _mesh_append_network(network_info);
+ if (cb) cb(network_info, user_data);
+ }
+ }
+ g_variant_unref(inner_params);
+ }
+ g_variant_unref(params);
+
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESH_ITNL_ERR_IO_ERROR;
+ }
+
+ return MESH_ITNL_ERR_NONE;
+}
+
+struct mesh_station_info_s g_station;
+
+int _mesh_get_station_info(mesh_h handle, void *station)
{
GVariant *variant = NULL;
-// unsigned int result;
+ unsigned int result;
GError *error = NULL;
struct mesh_handle *h = handle;
+ GVariant *params = NULL;
+ GVariant *inner_params = NULL;
+ GVariantIter iter, inner_iter;
+
+ gchar *key;
+ GVariant *val;
+ gsize len = 0;
+
+ if (g_station.station) {
+ g_free(g_station.station);
+ }
+ memset(&g_station, 0, sizeof(g_station));
+
RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
-1,
NULL, &error);
if (variant) {
- //g_variant_get(variant, "(a(a{sv})", &result);
+ g_variant_get(variant, "(a(a{sv})u)", ¶ms, &result);
+
/* TODO: handle station list here */
+ g_variant_iter_init(&iter, params);
+ while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+
+ g_variant_iter_init(&inner_iter, inner_params);
+ while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "station") == 0) {
+ g_station.station = g_variant_dup_string(val, &len);
+ LOGE("station= %s", g_station.station);
+ }
+ else if (strcasecmp(key, "inactive_time") == 0) {
+ g_station.inactive_time = g_variant_get_uint32(val);
+ LOGE("inactive_time= %s", g_station.inactive_time);
+ }
+ else if (strcasecmp(key, "rx_bytes") == 0) {
+ g_station.rx_bytes = g_variant_get_uint32(val);
+ LOGE("rx_bytes= %s", g_station.rx_bytes);
+ }
+ }
+ g_variant_unref(inner_params);
+ }
+ g_variant_unref(params);
+
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
}
return MESH_ITNL_ERR_NONE;
+
}
-int _mesh_get_mpath_info(mesh_h handle)
+int _mesh_get_path_info(mesh_h handle, void* mpath_data)
{
GVariant *variant = NULL;
-// unsigned int result;
+ unsigned int result;
GError *error = NULL;
struct mesh_handle *h = handle;
+ GVariant *params = NULL;
+ GVariant *inner_params = NULL;
+ GVariantIter iter, inner_iter;
+
+ gchar *key;
+ GVariant *val;
+ gsize len = 0;
+
RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
-1,
NULL, &error);
if (variant) {
- //g_variant_get(variant, "(a(a{sv})", &result);
- /* TODO: handle mpath list here */
+ g_variant_get(variant, "(a(a{sv})u)", ¶ms, &result);
+
+ /* handle station list here */
+ _mesh_remove_mpath();
+
+ g_variant_iter_init(&iter, params);
+ while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+ struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
+ g_variant_iter_init(&inner_iter, inner_params);
+ while (g_variant_iter_loop(&inner_iter, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "dest_addr") == 0) {
+ mpath->dest_addr = g_variant_dup_string(val, &len);
+ LOGE("dest_addr= %s", mpath->dest_addr);
+ }
+ else if (strcasecmp(key, "next_hop") == 0) {
+ mpath->next_hop = g_variant_dup_string(val, &len);
+ LOGE("next_hop= %s", mpath->next_hop);
+ }
+ else if (strcasecmp(key, "iface") == 0) {
+ mpath->iface = g_variant_dup_string(val, &len);
+ LOGE("iface= %s", mpath->iface);
+ }
+
+ _mesh_add_mpath((gpointer)mpath);
+ }
+ g_variant_unref(inner_params);
+ }
+
+ g_variant_unref(params);
+
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
int ret;
msg("enable");
- ret = mesh_enable(mesh, data_mesh_interface, event_cb);
+ ret = mesh_enable(mesh, event_cb);
if (ret != 0) {
msg("Failed to enable mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);