* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_enable()
+ * @see mesh_specific_scan()
+ * @see mesh_cancel_scan()
*
*/
int mesh_scan(mesh_h handle);
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_scan()
+ * @see mesh_cancel_scan()
*
*/
int mesh_specific_scan(mesh_h handle, const char* ssid, int channel);
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_scan()
+ * @see mesh_specific_scan()
* @see mesh_scan()
*
*/
int mesh_cancel_scan(mesh_h handle);
/**
- * @brief
+ * @brief Called after mesh_foreach_found_mesh_netwrok()
* @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()
+ * @pre The callback must be registered with mesh_foreach_found_mesh_netwrok()
*
* @see mesh_foreach_found_mesh_netwrok()
*/
typedef void (*mesh_found_mesh_netwrok_cb)(mesh_network_h network, void* user_data);
/**
- * @brief
- * @details
+ * @brief Gets scanned mesh network bss informatoin
+ * @details This function returns network information scanned through mesh_found_mesh_netwrok_cb.
*
* @since_tizen 4.0
*
* @see mesh_found_mesh_netwrok_cb()
*
*/
-int mesh_foreach_found_mesh_netwrok(mesh_h handle, mesh_found_mesh_netwrok_cb cb, void *user_data);
+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.
+ * @brief Get the mesh connection state.
+ * @details Check if current device is joined mesh network.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[out] station The mesh station information handle
+ * @param[out] is_joined The state of mesh network connection.
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_enable_mesh()
+ * @see mesh_found_mesh_netwrok_cb()
*
*/
-int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
+int mesh_is_joined(mesh_h handle, int* is_joined);
/**
- * @brief Get information of all mesh paths.
- * @details Get information about all mesh paths present in the currently connected mesh network.
+ * @brief Gets current joined mesh network information.
+ * @details Return current joined mesh network information..
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[out] path The mesh path information handle
+ * @param[in] is_joined The state of mesh network connection.
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_enable_mesh()
*
*/
-int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
+int mesh_get_joined_network(mesh_h handle, mesh_network_h network);
/**
- * @brief Join into specific mesh network.
- * @details Join into specific mesh network with given SSID.
+ * @brief Adds new mesh network configuration
+ * @details This function adds new network configuration.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[in] ssid Specific SSID to scan
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_is_joined()
- * @see mesh_disjoin()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_remove_mesh_network()
*
*/
-int mesh_join(mesh_h handle, const char* ssid);
+int mesh_add_mesh_network(mesh_h handle, mesh_network_h network);
/**
- * @brief Get the mesh connection state.
- * @details Check if current device is joined mesh network.
+ * @brief Called after mesh_foreach_saved_mesh_network()
+ * @details This function can receive saved mesh network configuration.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[out] network saved network configuration handle
+ * @param[out] user_data user data pointer
+ *
+ * @pre The callback must be registered with mesh_foreach_saved_mesh_netwrok()
+ *
+ * @see mesh_foreach_saved_mesh_netwrok()
+ */
+typedef void (*mesh_saved_mesh_netwrok_cb)(mesh_network_h network, void* user_data);
+
+/**
+ * @brief Gets saved mesh network informatoin
+ * @details This function returns saved network information through mesh_saved_mesh_netwrok_cb.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[in] is_joined The state of mesh network connection.
+ * @param[in] cb callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_join()
+ * @see mesh_saved_mesh_netwrok_cb()
*
*/
-int mesh_is_joined(mesh_h handle, int is_joined);
+int mesh_foreach_saved_mesh_network(mesh_h handle,
+ mesh_saved_mesh_netwrok_cb cb, void *user_data);
/**
- * @brief Disconnect from joined mesh network.
- * @details Disconnect mesh network connection from current mesh network.
+ * @brief Seletcs existing mesh network configuration
+ * @details This function seletcs existing network configuration to connect.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_join()
- * @see mesh_is_joined()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_add_mesh_network()
*
*/
-int mesh_disjoin(mesh_h handle);
+int mesh_select_mesh_network(mesh_h handle, mesh_network_h network);
/**
- * @brief Set AP setting with given parameters.
- * @details Set SoftAP parameters to use configured AP settings.
+ * @brief Removes existing mesh network configuration
+ * @details This function removes new network configuration.
*
* @since_tizen 4.0
*
* @param[in] handle The mesh handle
- * @param[in] ssid SSID for SoftAP
- * @param[in] key The key for SoftAP
- * @param[in] mode SoftAP mode
- * @param[in] channel The channel number
- * @param[in] visibility The visibility of SoftAP
- * @param[in] max_stations Max acceptable station number.
- * @param[in] security Security type of SoftAP
+ * @param[in] network callback function pointer to know saved network information
+ * @param[in] user_data user data pointer
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
+ * @see mesh_foreach_saved_mesh_network()
+ * @see mesh_saved_mesh_netwrok_cb()
+ * @see mesh_select_mesh_network()
+ * @see mesh_add_mesh_network()
*
*/
-int mesh_load_softap_settings(mesh_h handle, const char* ssid,
- const char* key, const char* mode,
- int channel, int visibility,
- int max_stations, int security);
+int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network);
/**
- * @brief Start bridging for mesh network.
- * @details For mesh gate, network bridging is required to communicate with external network.
+ * @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[in] interface The interface name of bridge.
- * @param[in] mode Mode
+ * @param[out] station The mesh station information handle
*
*
* @return 0 on success, otherwise a negative error value.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_stop_bridge()
+ * @see mesh_get_path_info()
*
*/
-int mesh_start_bridge(mesh_h handle, const char* interface, int mode);
+int mesh_get_station_info(mesh_h handle, mesh_station_info_h station);
/**
- * @brief Stop bridging for mesh network.
- * @details For mesh gate, network bridging is required to communicate with external network.
+ * @brief Get information of all mesh paths.
+ * @details Get information about all mesh paths present in the currently connected mesh network.
*
* @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.
* @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MESH_ERROR_IO_ERROR Unexpected d-bus error
*
- * @see mesh_initialize()
- * @see mesh_deinitialize()
- * @see mesh_start_bridge()
+ * @see mesh_get_station_info()
*
*/
-int mesh_stop_bridge(mesh_h handle);
+int mesh_get_path_info(mesh_h handle, mesh_path_info_h path);
/**
+ * @brief Sets network device interface name.
+ * @details This function provides the ability to manually select interfaces for advanced users.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] handle The mesh handle
+ * @param[in] mesh An interface name for mesh network
+ * @param[in] gate An interface name for external network
+ * @param[in] softap An interface name for internal softap
+ *
+ *
+ * @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
+ *
+ */
+int mesh_set_interface(mesh_h handle,
+ const char *mesh, const char* gate, const char *softap);
+/**
* @}
*/
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, void *station);
-int _mesh_get_path_info(mesh_h handle, void *mpath_data);
+int _mesh_foreach_found_mesh_network(mesh_h handle,
+ mesh_found_mesh_netwrok_cb cb, void *user_data);
int _mesh_enable_mesh(mesh_h handle);
int _mesh_disable_mesh(mesh_h handle);
+int _mesh_is_joined(mesh_h handle, int* is_joined);
+int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h _network);
int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce);
int _mesh_unset_gate(mesh_h handle);
-int _mesh_set_softap(mesh_h handle, const char* ssid,
- const char* key, const char* mode,
- int channel, int visibility,
- int max_stations, int security);
+int _mesh_set_softap(mesh_h handle, const char* ssid, const char* key, const char* mode,
+ int channel, int visibility, int max_stations, int security);
int _mesh_enable_softap(mesh_h handle);
int _mesh_disable_softap(mesh_h handle);
+int _mesh_add_network(mesh_h handle, mesh_network_h _network);
+int _mesh_foreach_saved_mesh_netwrok(mesh_h handle,
+ mesh_saved_mesh_netwrok_cb cb, void *user_data);
+int _mesh_select_network(mesh_h handle, mesh_network_h _network);
+int _mesh_remove_network(mesh_h handle, mesh_network_h _network);
+int _mesh_set_interface(mesh_h handle, const char *mesh, const char *gate, const char *softap);
+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);
+int _mesh_load_softap_settings(mesh_h handle, const char* ssid,
+ const char* key, const char* mode,
+ int channel, int visibility,
+ int max_stations, int security);
int _mesh_start_bridge(mesh_h handle, const char* interface, int mode);
int _mesh_stop_bridge(mesh_h handle);
#endif
} mesh_handle_s;
-struct mesh_found_network_s {
- char *meshid; /**< meshid */
- char *bssid; /**< bssid */
+struct mesh_network_s {
+ char meshid[32]; /**< meshid */
+ char bssid[32]; /**< bssid */
int channel; /**< channel */
int rssi; /**< rssi */
int data_rate; /**< data rate */
+ int security; /**< security type */
};
struct mesh_station_info_s {
int flags; /**< flags */
};
+#define NOTUSED(var) (var = var)
+
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_cancel_scan(mesh_h handle)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_cancel_scan(handle);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel)
{
int rv = 0;
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_cancel_scan(mesh_h handle)
+EXPORT_API int mesh_foreach_round_mesh_network(mesh_h handle,
+ mesh_found_mesh_netwrok_cb cb, void *user_data)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+ RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_cancel_scan(handle);
+ rv = _mesh_foreach_found_mesh_network(handle, cb, user_data);
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, mesh_station_info_h station)
+EXPORT_API int mesh_enable_mesh(mesh_h handle)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_get_station_info(handle, station);
+ rv = _mesh_enable_mesh(handle);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_get_path_info(mesh_h handle, mesh_path_info_h path)
+EXPORT_API int mesh_disable_mesh(mesh_h handle)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_get_path_info(handle, path);
+ rv = _mesh_disable_mesh(handle);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_enable_mesh(mesh_h handle, const char* ssid)
+EXPORT_API int mesh_is_joined(mesh_h handle, int* is_joined)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
- RETV_IF(NULL == ssid, MESH_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_enable_mesh(handle);
+ rv = _mesh_is_joined(handle, is_joined);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_is_joined(mesh_h handle, int is_joined)
+EXPORT_API int mesh_get_joined_network(mesh_h handle, mesh_network_h network)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_is_joined(handle, is_joined);
+ rv = _mesh_get_joined_mesh_network(handle, network);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_set_gate(mesh_h handle, bool stp, bool gate_announce)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_set_gate(handle, stp, gate_announce);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_disjoin(mesh_h handle)
+EXPORT_API int mesh_unset_gate(mesh_h handle)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_disjoin(handle);
+ rv = _mesh_unset_gate(handle);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_load_softap_settings(mesh_h handle, const char* ssid,
+EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid,
const char* key, const char* mode,
int channel, int visibility,
int max_stations, int security)
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_start_bridge(mesh_h handle, const char* interface, int mode)
+EXPORT_API int mesh_enable_softap(mesh_h handle)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_enable_softap(handle);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_disable_softap(mesh_h handle)
{
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_start_bridge(handle, interface, mode);
+ rv = _mesh_disable_softap(handle);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
-EXPORT_API int mesh_stop_bridge(mesh_h handle)
+EXPORT_API int mesh_add_mesh_network(mesh_h handle, mesh_network_h network)
{
int rv = 0;
CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
- rv = _mesh_stop_bridge(handle);
+ rv = _mesh_add_network(handle, network);
if (rv == MESH_ITNL_ERR_IO_ERROR) {
return MESH_ERROR_IO_ERROR;
}
return MESH_ERROR_NONE;
}
+
+EXPORT_API int mesh_foreach_saved_mesh_network(mesh_h handle,
+ mesh_found_mesh_netwrok_cb cb, void *user_data)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_foreach_saved_mesh_netwrok(handle, cb, user_data);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_select_mesh_network(mesh_h handle, mesh_network_h network)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_select_network(handle, network);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_remove_mesh_network(mesh_h handle, mesh_network_h network)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_remove_network(handle, network);
+ 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, 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, station);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+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_path_info(handle, path);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_set_interface(mesh_h handle,
+ const char *mesh, const char* gate, const char *softap)
+{
+ int rv = 0;
+ CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+ RETV_IF(NULL == mesh, MESH_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER);
+
+ rv = _mesh_set_interface(handle, mesh, gate, softap);
+ if (rv == MESH_ITNL_ERR_IO_ERROR) {
+ return MESH_ERROR_IO_ERROR;
+ }
+
+ return MESH_ERROR_NONE;
+}
+
static void _mesh_free_network(gpointer data)
{
- struct mesh_found_network_s *network = data;
+ struct mesh_network_s *network = data;
g_free(network->meshid);
g_free(network->bssid);
g_free(network);
return MESH_ITNL_ERR_NONE;
}
-int _mesh_foreach_found_mesh_netwrok(mesh_h handle,
+int _mesh_foreach_found_mesh_network(mesh_h handle,
mesh_found_mesh_netwrok_cb cb, void *user_data)
{
GVariant *variant = NULL;
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));
+ struct mesh_network_s *network_info =
+ g_malloc0(sizeof(struct mesh_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);
+ const char *buf = g_variant_get_string(val, &len);
+ memcpy(network_info->meshid, buf, len);
+ //network_info->meshid = g_variant_get_string(val, &len);
LOGE("meshid=%s", network_info->meshid);
}
else if (strcasecmp(key, "bssid") == 0) {
- network_info->bssid = g_variant_dup_string(val, &len);
+ const char *buf = g_variant_get_string(val, &len);
+ memcpy(network_info->bssid, buf, len);
+ //network_info->bssid = g_variant_dup_string(val, &len);
LOGE("bssid = %s", network_info->bssid);
}
else if (strcasecmp(key, "channel") == 0) {
return MESH_ITNL_ERR_NONE;
}
-int _mesh_get_joined_mesh_network(mesh_h handle)
+/* TODO: Parameter verification required */
+int _mesh_is_joined(mesh_h handle, int* is_joined)
+{
+ GVariant *variant = NULL;
+ unsigned int result;
+ GError *error = NULL;
+ struct mesh_handle *h = handle;
+
+ 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, "is_joined",
+ g_variant_new("(b)", (is_joined==0) ? FALSE : TRUE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(u)", &result);
+ LOGD("Mesh is_joined status 0x%x", result);
+ } 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;
+}
+
+int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
GError *error = NULL;
RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
+ RETV_IF(NULL == _network, MESH_ITNL_ERR_INVALID_PARAM);
variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_joined_mesh_network",
NULL,
-1,
NULL, &error);
if (variant) {
- gchar *meshid = NULL;
- gchar *bssid = NULL;
+ struct mesh_network_s *n = _network;
+ int len;
+ char *meshid = NULL;
+ char *bssid = NULL;
int channel, max_speed;
unsigned int result;
g_variant_get(variant, "(ssiiu)", meshid, bssid, &channel, &max_speed, &result);
LOGD("get_joined_mesh_network status 0x%x", result);
+
+ len = strlen(meshid);
+ memcpy(n->meshid, meshid, len > 32 ? 32 : len);
+ len = strlen(bssid);
+ memcpy(n->bssid, bssid, len > 32 ? 32 : len);
+ n->channel = channel;
+ n->data_rate = max_speed;
+ n->rssi = -1;
+
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ITNL_ERR_NONE;
}
-struct mesh_station_info_s g_station;
-
-int _mesh_get_station_info(mesh_h handle, void *station)
+int _mesh_enable_softap(mesh_h handle)
{
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;
+ RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR);
+ RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR);
- if (g_station.station) {
- g_free(g_station.station);
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "enable_softap",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(u)", &result);
+ LOGD("enable_softap status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESH_ITNL_ERR_IO_ERROR;
}
- memset(&g_station, 0, sizeof(g_station));
+
+ return MESH_ITNL_ERR_NONE;
+}
+
+int _mesh_disable_softap(mesh_h handle)
+{
+ GVariant *variant = NULL;
+ unsigned int result;
+ GError *error = NULL;
+ struct mesh_handle *h = handle;
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_station_info",
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disable_softap",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(a(a{sv})u)", ¶ms, &result);
+ g_variant_get(variant, "(u)", &result);
+ LOGD("disable_softap status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESH_ITNL_ERR_IO_ERROR;
+ }
- /* TODO: handle station list here */
- g_variant_iter_init(&iter, params);
- while (g_variant_iter_loop(&iter, "(a{sv})", &inner_params)) {
+ return MESH_ITNL_ERR_NONE;
+}
- 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);
+int _mesh_add_network(mesh_h handle, mesh_network_h _network)
+{
+ GVariant *variant = NULL;
+ unsigned int result;
+ GError *error = NULL;
+ struct mesh_handle *h = handle;
+ struct mesh_network_s *n = _network;
+
+ 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, "add_network",
+ g_variant_new("(sii)", n->meshid, n->channel, n->security),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(u)", &result);
+ LOGD("add_network status 0x%x", result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
}
return MESH_ITNL_ERR_NONE;
-
}
-int _mesh_get_path_info(mesh_h handle, void* mpath_data)
+int _mesh_foreach_saved_mesh_netwrok(mesh_h handle,
+ mesh_saved_mesh_netwrok_cb cb, void *user_data)
{
GVariant *variant = NULL;
unsigned int result;
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_mpath_info",
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_found_mesh_networks",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(a(a{sv})u)", ¶ms, &result);
-
/* handle station list here */
- _mesh_remove_mpath();
+ 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_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
+
+ struct mesh_network_s *network_info =
+ g_malloc0(sizeof(struct mesh_network_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);
+ if (strcasecmp(key, "meshid") == 0) {
+ const char *buf = g_variant_get_string(val, &len);
+ memcpy(network_info->meshid, buf, len);
+ //network_info->meshid = g_variant_dup_string(val, &len);
+ LOGE("meshid=%s", network_info->meshid);
}
- else if (strcasecmp(key, "iface") == 0) {
- mpath->iface = g_variant_dup_string(val, &len);
- LOGE("iface= %s", mpath->iface);
+ else if (strcasecmp(key, "bssid") == 0) {
+ const char *buf = g_variant_get_string(val, &len);
+ memcpy(network_info->bssid, buf, len);
+ //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);
- _mesh_add_mpath((gpointer)mpath);
+ _mesh_append_network(network_info);
+ if (cb) cb(network_info, user_data);
+ }
}
g_variant_unref(inner_params);
}
-
g_variant_unref(params);
+ LOGD("get_saved_mesh_networks status 0x%x", result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
return MESH_ITNL_ERR_NONE;
}
-#if 1
-int _mesh_join(mesh_h handle, const char* ssid)
+
+int _mesh_select_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
unsigned int result;
GError *error = NULL;
struct mesh_handle *h = handle;
+ struct mesh_network_s *n = _network;
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, "join",
- g_variant_new("(s)", ssid),
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "select_network",
+ g_variant_new("(sii)", n->meshid, n->channel, n->security),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
g_variant_get(variant, "(u)", &result);
- LOGD("Mesh join status 0x%x", result);
+ LOGD("select_network status 0x%x", result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ITNL_ERR_NONE;
}
-/* TODO: Parameter verification required */
-int _mesh_is_joined(mesh_h handle, int is_joined)
+int _mesh_remove_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
unsigned int result;
GError *error = NULL;
struct mesh_handle *h = handle;
+ struct mesh_network_s *n = _network;
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, "is_joined",
- g_variant_new("(b)", (is_joined==0) ? FALSE : TRUE),
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "remove_network",
+ g_variant_new("(sii)", n->meshid, n->channel, n->security),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
g_variant_get(variant, "(u)", &result);
- LOGD("Mesh is_joined status 0x%x", result);
+ LOGD("remove_network status 0x%x", result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ITNL_ERR_NONE;
}
-int _mesh_disjoin(mesh_h handle)
+
+struct mesh_station_info_s g_station;
+
+int _mesh_get_station_info(mesh_h handle, void *station)
{
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;
+
+ 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);
- variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disjoin",
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info",
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
- LOGD("Mesh disjoin status 0x%x", 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_start_bridge(mesh_h handle, const char* interface, int mode)
+int _mesh_get_path_info(mesh_h handle, void* mpath_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;
+
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, "start_bridge",
- g_variant_new("(is)", mode, interface),
+ variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_mpath_info",
+ NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
- LOGD("Mesh bridge start status 0x%x", result);
+ 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);
return MESH_ITNL_ERR_NONE;
}
-int _mesh_stop_bridge(mesh_h handle)
+int _mesh_set_interface(mesh_h handle, const char *mesh, const char *gate, const char *softap)
{
- GVariant *variant = NULL;
- unsigned int result;
- GError *error = NULL;
struct mesh_handle *h = handle;
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, "stop_bridge",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL, &error);
- if (variant) {
- g_variant_get(variant, "(u)", &result);
- LOGD("Mesh bridge stop status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return MESH_ITNL_ERR_IO_ERROR;
- }
+ LOGE("Not implemented yet!!");
+ NOTUSED(mesh);
+ NOTUSED(gate);
+ NOTUSED(softap);
return MESH_ITNL_ERR_NONE;
}
-#endif
+