diff options
author | saerome.kim <saerome.kim@samsung.com> | 2017-07-04 21:17:59 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2017-07-17 11:09:10 +0900 |
commit | 3068dd95439f6daf95e2a126101206c98ee00777 (patch) | |
tree | 62fdb1b588a99fbc8eea449cbafb49b4ccdd8a10 | |
parent | dc5f3484790c33ca50298ffd31c9510584b6a666 (diff) | |
download | wifi-mesh-3068dd95439f6daf95e2a126101206c98ee00777.tar.gz wifi-mesh-3068dd95439f6daf95e2a126101206c98ee00777.tar.bz2 wifi-mesh-3068dd95439f6daf95e2a126101206c98ee00777.zip |
Change package name to capi-network-wifi-mesh
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | capi-network-wifi-mesh.pc.in (renamed from capi-network-mesh.pc.in) | 0 | ||||
-rw-r--r-- | doc/wifi-mesh-doc.h | 51 | ||||
-rw-r--r-- | include/mesh.h | 1009 | ||||
-rw-r--r-- | include/mesh_dbus.h | 75 | ||||
-rw-r--r-- | include/wifi-mesh-internal.h (renamed from include/mesh-internal.h) | 112 | ||||
-rw-r--r-- | include/wifi-mesh.h | 1007 | ||||
-rw-r--r-- | include/wifi-mesh_dbus.h | 75 | ||||
-rw-r--r-- | include/wifi-mesh_log.h (renamed from include/mesh_log.h) | 6 | ||||
-rw-r--r-- | include/wifi-mesh_private.h (renamed from include/mesh_private.h) | 20 | ||||
-rw-r--r-- | include/wifi-mesh_service_error.h (renamed from include/service_error.h) | 6 | ||||
-rw-r--r-- | packaging/capi-network-wifi-mesh.manifest (renamed from packaging/capi-network-mesh.manifest) | 0 | ||||
-rw-r--r-- | packaging/capi-network-wifi-mesh.spec (renamed from packaging/capi-network-mesh.spec) | 16 | ||||
-rw-r--r-- | src/mesh_internal.c | 130 | ||||
-rw-r--r-- | src/wifi-mesh-dbus.c (renamed from src/mesh_dbus.c) | 406 | ||||
-rw-r--r-- | src/wifi-mesh-internal.c | 130 | ||||
-rw-r--r-- | src/wifi-mesh.c (renamed from src/mesh.c) | 264 | ||||
-rw-r--r-- | test/CMakeLists.txt | 14 | ||||
-rw-r--r-- | test/common.h | 8 | ||||
-rw-r--r-- | test/main.c | 79 | ||||
-rw-r--r-- | test/wifi-mesh-device.c (renamed from test/mesh_device.c) | 64 | ||||
-rw-r--r-- | test/wifi-mesh-network.c (renamed from test/mesh_network.c) | 298 |
22 files changed, 1912 insertions, 1863 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a9eb25d..7de7068 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(fw_name "capi-network-mesh") +SET(fw_name "capi-network-wifi-mesh") PROJECT(${fw_name}) @@ -48,8 +48,7 @@ INSTALL(TARGETS ${fw_name} DESTINATION ${LIB}) INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/network FILES_MATCHING - PATTERN "mesh_*.h" EXCLUDE - PATTERN "service_*.h" EXCLUDE + PATTERN "wifi-mesh_*.h" EXCLUDE PATTERN "${INC_DIR}/*.h" ) diff --git a/capi-network-mesh.pc.in b/capi-network-wifi-mesh.pc.in index 2b4a65f..2b4a65f 100644 --- a/capi-network-mesh.pc.in +++ b/capi-network-wifi-mesh.pc.in diff --git a/doc/wifi-mesh-doc.h b/doc/wifi-mesh-doc.h new file mode 100644 index 0000000..3905feb --- /dev/null +++ b/doc/wifi-mesh-doc.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __TIZEN_NETWORK_WIFI_MESH_DOC_H__ +#define __TIZEN_NETWORK_WIFI_MESH_DOC_H__ + +/** + * @ingroup CAPI_NETWORK_FRAMEWORK + * @defgroup CAPI_NETWORK_WIFI_MESH_MODULE Wi-Fi Mesh + * @brief This provides APIs to manage Wi-Fi Mesh. + * + * @section CAPI_NETWORK_WIFI_MESH_MODULE_HEADER Header + * \#include <wifi-mesh.h> + * + * @section CAPI_NETWORK_WIFI_MESH_MODULE_OVERVIEW Overview + * This set of functions is used to manage the settings of Wi-Fi Mesh network. + * In addition, this set provides functions to connect and disconnect remote devices using Wi-Fi Mesh. + * + * @subsection CAPI_NETWORK_WIFI_MESH_MODULE_REFERENCE Wi-Fi Mesh Reference + * - https://standards.ieee.org/findstds/standard/802.11s-2011.html/ + * - http://linuxwireless.org/en/developers/Documentation/ieee80211/802.11s/ + * + * @section CAPI_NETWORK_WIFI_MESH_MODULE_FEATURE Related Features + * These APIs are related with the following features:\n + * - http://tizen.org/feature/network.mesh\n + * - http://tizen.org/feature/network.mesh.admin\n + * + * It is recommended to design applications with regard to features, for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/getting-started/native-application/understanding-tizen-programming/application-filtering"><b>Feature List</b>.</a> + * + */ + +#endif __TIZEN_NETWORK_WIFI_MESH_DOC_H__ + diff --git a/include/mesh.h b/include/mesh.h deleted file mode 100644 index fb6895f..0000000 --- a/include/mesh.h +++ /dev/null @@ -1,1009 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __TIZEN_MESH_H__ -#define __TIZEN_MESH_H__ - -#include <tizen.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file mesh.h - */ - -/** -* @addtogroup CAPI_NETWORK_MESH_MODULE -* @{ -*/ - -/** - * @brief The mesh handle. - * @since_tizen 4.0 -*/ -typedef void *mesh_h; - -/*********************************************************************** - TEMP -***********************************************************************/ -#ifndef TIZEN_ERROR_MESH -#define TIZEN_ERROR_MESH -0x02F60000 -#endif - -/** - * @brief Enumeration for the Mesh error type. - * @since_tizen 4.0 - */ -typedef enum { - 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_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ - MESH_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ - MESH_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */ - MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */ - 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_OPERATION_FAILED = TIZEN_ERROR_MESH | 0x01, /**< Operation failed */ - MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH | 0x02, /**< Operation is aborted */ - MESH_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_MESH | 0x03, /**< Mesh Already Initialized */ -} mesh_error_e; - -/** -* @} -*/ - -/** -* @addtogroup CAPI_NETWORK_MESH_MONITOR_MODULE -* @{ -*/ - -/** - * @brief The maximum length of mesh id - * - * @since_tizen 4.0 - */ -#define MAX_MESHID_LEN 32 - -/** - * @brief The maximum length of BSSID - * - * @since_tizen 4.0 - */ -#define MAX_BSSID_LEN 18 - -/** - * @brief The maximum length of passphrase - * - * @since_tizen 4.0 - */ -#define MAX_PASSPHRASE_LEN (64+1) - -/** - * @brief Enumeration for the security type of the Mesh network. - * @since_tizen 4.0 - */ -typedef enum { - MESH_SECURITY_NONE = 0, /**< Open network */ - MESH_SECURITY_SAE, /**< Simultaneous Authentication of Equals */ -} mesh_security_type_e; - -/** - * @brief Enumeration for the connection state of the Mesh network. - * @since_tizen 4.0 - */ -typedef enum { - MESH_CONNECTION_STATE_DISCONNECTED = 0, /**< Mesh network is disconnected */ - MESH_CONNECTION_STATE_ASSOCIATION, /**< Service is trying to establish low-level network connection to the mesh network. */ - MESH_CONNECTION_STATE_CONFIGURATION, /**< Service is trying to retrieve/configure IP settings. */ - MESH_CONNECTION_STATE_CONNECTED /**< Mesh network is connected */ -} mesh_connection_state_e; - -/** - * @brief The events for mesh_event_cb - * - * @since_tizen 4.0 - */ -typedef enum { - MESH_EVENT_ENABLED = 0x00, /**< This event is received after enabling mesh network */ - MESH_EVENT_SCAN_DONE = 0x01, /**< This event comes after scanning operation completed */ - MESH_EVENT_CONNECTION_STATE = 0x02, /**< This event takes place when mesh network connection state is changed */ - MESH_EVENT_STATION_JOIN = 0x03, /**< This event takes place when new station joined */ - MESH_EVENT_STATION_LEFT = 0x04, /**< This event takes place when existing station left */ -} mesh_event_e; - -/** - * @brief The structure type for the MESH_EVENT_ENABLED callback data. - * @details The result of creating or joining mesh network. - * - * @since_tizen 4.0 - */ -typedef struct { - int result; /**< The result of creating or joining mesh network */ -} mesh_mesh_enabled_event_s; - -/** - * @brief The structure type for the MESH_EVENT_STATION_JOIN or MESH_EVENT_STATION_LEFT callback data. - * @details Result of join or left event of other station. - * - * @since_tizen 4.0 - */ -typedef struct { - char bssid[MAX_BSSID_LEN]; /**< The BSSID of the station that generated the event */ -} mesh_other_station_event_s; - -/** - * @brief The structure type for the MESH_EVENT_CONNECTION_STATE callback data. - * @details The state of mesh network connection. - * - * @since_tizen 4.0 - */ -typedef struct { - char mesh_id[MAX_MESHID_LEN]; /**< The Mesh ID of the network that generated the event */ - char bssid[MAX_BSSID_LEN]; /**< The BSSID of the network that generated the event */ - int channel; /**< The channel of the network that generated the event */ - mesh_security_type_e security; /**< The security type of network */ - mesh_connection_state_e state; /**< The state of mesh network connection. */ -} mesh_connection_state_event_s; - -/** - * @brief The structure type for response data of mesh_event_cb. - * @details This function can receive events from the devices in the network. - * ex) join, re-join, leave and attribute change report - * - * @since_tizen 4.0 - */ -typedef struct { - union { - mesh_mesh_enabled_event_s *mesh_enable; /**< The result of enabling mesh system service. */ - mesh_other_station_event_s *sta_info; /**< This event comes from other stations. */ - mesh_connection_state_event_s *connection_state; /**< The state of mesh network connection. */ - } data; -} mesh_event_data_s; - -/** -* @} -*/ - -/** -* @addtogroup CAPI_NETWORK_MESH_MODULE -* @{ -*/ - - -/** - * @brief The mesh network profile handle. - * @since_tizen 4.0 -*/ -typedef void* mesh_network_h; - -/** - * @brief The mesh network peer handle. - * @since_tizen 4.0 -*/ -typedef void* mesh_peer_h; - -/** - * @brief Creates network handle for network information. - * @details This function is to allocate new mesh network information - * - * @since_tizen 4.0 - * - * @param[out] network The mesh network information handle, we will allocate mesh - * network information structure internally. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_OUT_OF_MEMORY Memory error - * - * @see mesh_network_clone() - * @see mesh_network_new_with() - * @see mesh_network_destroy() - * - */ -int mesh_network_new(mesh_network_h* network); - -/** - * @brief Clones network handle for network information. - * @details This function is to clone mesh network information - * - * @since_tizen 4.0 - * - * @param[out] dst The target mesh network information handle, we will allocate mesh - * network information structure internally. - * @param[in] src The source mesh network information handle. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_OUT_OF_MEMORY Memory error - * - * @see mesh_network_new() - * @see mesh_network_new_with() - * @see mesh_network_destroy() - * - */ -int mesh_network_clone(mesh_network_h* dst, mesh_network_h src); - -/** - * @brief Creates network handle with parameters for network information. - * @details This function is to allocate new mesh network information - * - * @since_tizen 4.0 - * - * @param[out] network The mesh network information handle, we will allocate mesh - * network information structure internally. - * @param[in] meshid The Mesh Network ID - * @param[in] bssid The Basic Service Set ID - * @param[in] channel The operating channel number - * @param[in] rssi The Received Signal Strength Indicator - * @param[in] security The security type for network - * @param[in] passphrase The passphrase for network connection - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_OUT_OF_MEMORY Memory error - * - * @see mesh_network_clone() - * @see mesh_network_new_with() - * @see mesh_network_destroy() - * - */ -int mesh_network_new_with(mesh_network_h* network, const char *meshid, - const char *bssid, int channel, int rssi, mesh_security_type_e security, - const char *passphrase); - -/** - * @brief Destroys network handle for network information. - * @details This function is to destroy mesh network information - * - * @since_tizen 4.0 - * - * @param[in] network The target mesh network information handle. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_OUT_OF_MEMORY Memory error - * - * @see mesh_network_new() - * @see mesh_network_new_with() - * @see mesh_network_clone() - * @see mesh_network_destroy() - * - */ -int mesh_network_destroy(mesh_network_h network); - -/** - * @brief Gets network mesh network id. - * @details This function is to return mesh network id - * @remark The returned string should be freed when no longer needed. - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[out] meshid The mesh network id. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_set_meshid() - * - */ -int mesh_network_get_meshid(mesh_network_h network, char **meshid); - -/** - * @brief Sets network mesh network id. - * @details This function is to set mesh network id - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] meshid The mesh network id. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_meshid() - * - */ -int mesh_network_set_meshid(mesh_network_h network, const char *meshid); - -/** - * @brief Gets BSSID. - * @details This function is to get basic service set id - * @remark The returned string should be freed when no longer needed. - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] bssid The basic service set id. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_set_bssid() - * - */ -int mesh_network_get_bssid(mesh_network_h network, char **bssid); - -/** - * @brief Sets BSSID. - * @details This function is to set basic service set id - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] bssid The basic service set id. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_bssid() - * - */ -int mesh_network_set_bssid(mesh_network_h network, const char *bssid); - -/** - * @brief Gets channel. - * @details This function is to get channel - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[out] channel The operating channel number. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_set_channel() - * - */ -int mesh_network_get_channel(mesh_network_h network, int *channel); - -/** - * @brief Sets channel. - * @details This function is to get channel - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] channel The operating channel number. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_channel() - * - */ -int mesh_network_set_channel(mesh_network_h network, int channel); - -/** - * @brief Gets RSSI. - * @details This function is to get rssi - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[out] rssi The received signal strength indicator. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_set_rssi() - * - */ -int mesh_network_get_rssi(mesh_network_h network, int *rssi); - -/** - * @brief Sets RSSI. - * @details This function is to set rssi - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] rssi The received signal strength indicator. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_rssi() - * - */ -int mesh_network_set_rssi(mesh_network_h network, int rssi); - -/** - * @brief Gets the security type. - * @details This function is to get the security type. - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[out] security The security type for network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_set_security() - * - */ -int mesh_network_get_security(mesh_network_h network, mesh_security_type_e *security); - -/** - * @brief Sets the security type. - * @details This function is to set the security type. - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] security The security type for network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_security() - * - */ -int mesh_network_set_security(mesh_network_h network, mesh_security_type_e security); - -/** - * @brief Sets the passphrase for network connection. - * @details This function is to set the passphrase. - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[in] passphrase The passphrase for network connection. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see mesh_network_get_security() - * @see mesh_network_set_security() - */ -int mesh_network_set_passphrase(mesh_network_h network, const char* passphrase); - -/** - * @brief Gets the connection state. - * @details This function is to get the connection state - * - * @since_tizen 4.0 - * - * @param[in] network The mesh network information handle. - * @param[out] state The maximum data rate. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - */ -int mesh_network_get_connection_state(mesh_network_h network, mesh_connection_state_e *state); - -/** - * @brief Gets address from mesh peer. - * @details This function is to return mesh network id - * @remark The returned string should be freed when no longer needed. - * - * @since_tizen 4.0 - * - * @param[in] peer The mesh peer information handle. - * @param[out] address The address of mesh peer. - * - * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * - */ -int mesh_peer_get_address(mesh_peer_h peer, char **address); - -/** - * @brief Initializes Mesh network. - * @since_tizen 4.0 - * @privlevel public - * @privilege %http://tizen.org/privilege/network.get - * @remarks You must release @a handle using mesh_deinitialize(). - * @param[out] handle The mesh handle - * @return @c 0 on success, otherwise negative error value - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_ALREADY_INITIALIZED Already initialized - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_INVALID_OPERATION Invalid operation - * @retval #MESH_ERROR_OPERATION_FAILED Operation failed - * @retval #MESH_ERROR_PERMISSION_DENIED Permission Denied - * @retval #MESH_ERROR_OUT_OF_MEMORY Out of memory - * @retval #MESH_ERROR_NOT_SUPPORTED Not supported - */ -int mesh_initialize(mesh_h *handle); - -/** - * @brief Deinitializes Mesh network. - * @since_tizen 4.0 - * @param[in] handle The mesh handle - * @return 0 on success, otherwise negative error value - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MESH_ERROR_INVALID_OPERATION Invalid operation - * @retval #MESH_ERROR_OPERATION_FAILED Operation failed - * @retval #MESH_ERROR_NOT_SUPPORTED Not supported - */ -int mesh_deinitialize(mesh_h handle); - -/** - * @brief Specifies the type of function passed to mesh_enable() - * @details This function can receive events from mesh network. - * ex) enabled state, scan result - * - * @since_tizen 4.0 - * - * @remarks You can receive below events. - * @see #MESH_EVENT_ENABLED - * @see #MESH_EVENT_SCAN_DONE - * @see #MESH_EVENT_STATION_JOIN - * @see #MESH_EVENT_STATION_LEFT - * - * @param[out] event_type The event identification - * @param[out] event parameter data pointer - * - * @pre The callback must be registered with mesh_enable() - * - * @see mesh_set_event_cb() - */ -typedef void (*mesh_event_cb)(mesh_event_e event_type, mesh_event_data_s* event); - -/** - * @brief Sets event handler for the mesh network service. - * @details Sets event handler to get events from the mesh network service. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] event_handler The event handler - * - * @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 - * @retval #MESH_ERROR_NOT_SUPPORTED Not supported - * - * @see mesh_initialize() - * @see mesh_deinitialize() - * - */ -int mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler); - -/** - * @brief Enable the mesh service. - * @details All this function to start mesh service - * - * @since_tizen 4.0 - * - * @remarks You must free all resources of the mesh by calling mesh_deinitialize() - * if mesh service is no longer needed. - * - * @param[in] handle The mesh handle - * - * @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_initialize() - * @see mesh_deinitialize() - * @see mesh_event_cb() - * @see mesh_disable() - * - */ -int mesh_enable(mesh_h handle); - -/** - * @brief disable the mesh service. - * @details all this function to stop mesh service - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * @remarks You must free all resources of the mesh by calling mesh_deinitialize() - * if mesh service is no longer needed. - * - * - * @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_initialize() - * @see mesh_deinitialize() - * @see mesh_enable() - * - */ -int mesh_disable(mesh_h handle); - -/** - * @brief Scan the mesh network. - * @details Scan all mesh network to get network state. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * - * @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_specific_scan() - * @see mesh_cancel_scan() - * - */ -int mesh_scan(mesh_h handle); - -/** - * @brief Scan for the specific mesh network. - * @details Scan specific SSID and channel to get network state. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] ssid Specific SSID to scan - * @param[in] channel The channel number to scan - * - * - * @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_cancel_scan() - * - */ -int mesh_specific_scan(mesh_h handle, const char* ssid, int channel); - -/** - * @brief Called after mesh_foreach_found_mesh_network() - * @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_foreach_found_mesh_network() - * - * @see mesh_foreach_found_mesh_network() - */ -typedef void (*mesh_found_mesh_network_cb)(mesh_network_h network, void* user_data); - -/** - * @brief Gets found mesh network bss information - * @details This function returns network information found through mesh_found_mesh_network_cb. - * - * @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_network_cb() - * - */ -int mesh_foreach_found_mesh_network(mesh_h handle, - mesh_found_mesh_network_cb cb, void *user_data); - -/** - * @brief Called after mesh_foreach_connected_peers() - * @details This function can receive connected peers on mesh network. - * - * @since_tizen 4.0 - * - * @param[out] network The mesh peer information handle - * @param[out] user_data user data pointer - * - * @pre The callback must be registered with mesh_foreach_connected_peers() - * - * @see mesh_foreach_connected_peers() - */ -typedef void (*mesh_connected_peer_cb)(mesh_peer_h peer, void* user_data); - -/** - * @brief Gets found mesh network peer information - * @details This function returns network information found through mesh_connected_peer_cb. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] cb callback function pointer to inform peer 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_find_peers() - * @see mesh_connected_peer_cb() - * - */ -int mesh_foreach_connected_peers(mesh_h handle, - mesh_connected_peer_cb cb, void *user_data); - -/** - * @brief Enables the mesh network. - * @details This function is to join or create mesh network using saved mesh network configuration - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * @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_disable_mesh() - * - */ -int mesh_enable_mesh(mesh_h handle); - -/** - * @brief Disables the mesh network. - * @details This function is to disjoin or destroy current mesh network - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * @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_enable_mesh() - * - */ -int mesh_disable_mesh(mesh_h handle); - -/** - * @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] is_joined The state of mesh network connection. - * - * - * @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_enable_mesh() - * @see mesh_found_mesh_network_cb() - * - */ -int mesh_is_joined(mesh_h handle, bool* is_joined); - -/** - * @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] network Mesh bss information handle - * - * - * @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_enable_mesh() - * - */ -int mesh_get_joined_network(mesh_h handle, mesh_network_h* network); - -/** - * @brief Sets softap options - * @details This function sets softap options. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] ssid The SSID - * @param[in] key The pre-shared key - * @param[in] channel The operating channel number - * @param[in] visibility The broadcast option (1:Broadcast SSID, 2:Hidden) - * @param[in] max_stations The maximum allowable number of stations (default:10) - * @param[in] security Security option (1:WPA1, 2:WPA2) - * - * - * @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_enable_softap() - * @see mesh_disable_softap() - * - */ -int mesh_set_softap(mesh_h handle, const char* ssid, const char* key, - int channel, bool visibility, int max_stations, int security); - -/** - * @brief Enables softap - * @details This function enables softap. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * - * @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_set_softap() - * @see mesh_disable_softap() - * - */ -int mesh_enable_softap(mesh_h handle); - -/** - * @brief Disable softap - * @details This function disables softap. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * - * - * @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_set_softap() - * @see mesh_enable_softap() - * - */ -int mesh_disable_softap(mesh_h handle); - -/** - * @brief Creates new mesh network configuration - * @details This function creates new mesh network. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] network Mesh bss information handle - * - * - * @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_connect_mesh_network() - * @see mesh_disconnect_mesh_network() - * @see mesh_forget_mesh_network() - * - */ -int mesh_create_mesh_network(mesh_h handle, mesh_network_h network); - -/** - * @brief Connects existing mesh network - * @details This function makes a connection to existing mesh network. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] network Mesh bss information handle - * - * - * @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_create_mesh_network() - * @see mesh_disconnect_mesh_network() - * @see mesh_forget_mesh_network() - * - */ -int mesh_connect_mesh_network(mesh_h handle, mesh_network_h network); - -/** - * @brief Disconnects existing mesh network - * @details This function disconnects with existing mesh network. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] network Mesh bss information handle - * - * - * @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_create_mesh_network() - * @see mesh_forget_mesh_network() - * - */ -int mesh_disconnect_mesh_network(mesh_h handle, mesh_network_h network); - -/** - * @brief Forgets existing mesh network - * @details This function removes the information of connected network. - * - * @since_tizen 4.0 - * - * @param[in] handle The mesh handle - * @param[in] network Mesh bss information handle - * - * - * @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_create_mesh_network() - * @see mesh_connect_mesh_network() - * @see mesh_disconnect_mesh_network() - * - */ -int mesh_forget_mesh_network(mesh_h handle, mesh_network_h network); - - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_MESH_H__ */ diff --git a/include/mesh_dbus.h b/include/mesh_dbus.h deleted file mode 100644 index 0618678..0000000 --- a/include/mesh_dbus.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __MESH_DBUS_H__ -#define __MESH_DBUS_H__ - -#include "mesh.h" -#include "mesh-internal.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define MESH_SERVER_NAME "net.mesh" -#define MESH_OBJECT_PATH "/net/mesh" -#define MESH_SERVICE_INTERFACE "net.mesh" - -#define MESH_MANAGER_NAME "net.mesh.manager" -#define MESH_MANAGER_OBJ_PATH "/net/mesh/manager" -#define MESH_MANAGER_INTERFACE "net.mesh.manager" - -#define MESH_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */ - -int _mesh_dbus_start(mesh_h m); -int _mesh_dbus_stop(mesh_h m); - -int _mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler); -int _mesh_enable(mesh_h handle); -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_scan_result(mesh_h handle); -int _mesh_foreach_found_mesh_network(mesh_h handle, - mesh_found_mesh_network_cb cb, void *user_data); -int _mesh_find_peers(mesh_h handle); -int _mesh_foreach_connected_peers(mesh_h handle, - mesh_connected_peer_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, bool* is_joined); -int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network); -int _mesh_set_gate(mesh_h handle, bool gate_announce, int hwmp_root_mode, bool stp); -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_enable_softap(mesh_h handle); -int _mesh_disable_softap(mesh_h handle); -int _mesh_create_network(mesh_h handle, mesh_network_h _network); -int _mesh_connect_network(mesh_h handle, mesh_network_h _network); -int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network); -int _mesh_forget_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_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data); -int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data); -int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, const char *softap); - -#ifdef __cplusplus -} -#endif - -#endif /** __MESH_DBUS_H__ */ diff --git a/include/mesh-internal.h b/include/wifi-mesh-internal.h index d92b201..816a838 100644 --- a/include/mesh-internal.h +++ b/include/wifi-mesh-internal.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __TIZEN_MESH_INTERNAL_H__ -#define __TIZEN_MESH_INTERNAL_H__ +#ifndef __TIZEN_WIFI_MESH_INTERNAL_H__ +#define __TIZEN_WIFI_MESH_INTERNAL_H__ #include <tizen.h> @@ -60,17 +60,17 @@ typedef void* mesh_mpath_info_h; * * @since_tizen 4.0 * - * @param[in] network The mesh network information handle. + * @param[in] network The Wi-Fi mesh network information handle. * @param[out] data_rate The maximum data rate. * * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter * - * @see mesh_network_set_data_rate() + * @see wifi_mesh_network_set_data_rate() * */ -int mesh_network_get_data_rate(mesh_network_h network, int *data_rate); +int wifi_mesh_network_get_data_rate(wifi_mesh_network_h network, int *data_rate); /** * @brief Sets the maximum data rate. @@ -78,17 +78,17 @@ int mesh_network_get_data_rate(mesh_network_h network, int *data_rate); * * @since_tizen 4.0 * - * @param[in] network The mesh network information handle. + * @param[in] network The Wi-Fi mesh network information handle. * @param[in] data_rate The maximum data rate. * * @return 0 on success, otherwise a negative error value. - * @retval #MESH_ERROR_NONE Successful - * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter * - * @see mesh_network_get_data_rate() + * @see wifi_mesh_network_get_data_rate() * */ -int mesh_network_set_data_rate(mesh_network_h network, int data_rate); +int wifi_mesh_network_set_data_rate(wifi_mesh_network_h network, int data_rate); /** * @brief Cancel scanning for the mesh network. @@ -96,20 +96,20 @@ int mesh_network_set_data_rate(mesh_network_h network, int data_rate); * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi mesh handle * * * @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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * - * @see mesh_scan() - * @see mesh_specific_scan() - * @see mesh_scan() + * @see wifi_mesh_scan() + * @see wifi_mesh_specific_scan() + * @see wifi_mesh_scan() * */ -int mesh_cancel_scan(mesh_h handle); +int wifi_mesh_cancel_scan(wifi_mesh_h handle); /** * @brief Sets gate options @@ -117,7 +117,7 @@ int mesh_cancel_scan(mesh_h handle); * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi mesh handle * @param[in] gate_announce Enable / Disable Gate Announce to peers * @param[in] hwmp_root_mode HWMP (Hybrid Wireless Mesh Protocol) Root Mode \n * #MESH_HWMP_ROOT_REACTIVE_MODE \n @@ -128,14 +128,14 @@ int mesh_cancel_scan(mesh_h handle); * * * @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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * - * @see mesh_unset_gate() + * @see wifi_mesh_unset_gate() * */ -int mesh_set_gate(mesh_h handle, int gate_announce, int hwmp_root_mode, bool stp); +int wifi_mesh_set_gate(wifi_mesh_h handle, int gate_announce, int hwmp_root_mode, bool stp); /** * @brief Unsets gate options @@ -143,21 +143,21 @@ int mesh_set_gate(mesh_h handle, int gate_announce, int hwmp_root_mode, bool stp * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi mesh handle * * * @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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * - * @see mesh_set_gate() + * @see wifi_mesh_set_gate() * */ -int mesh_unset_gate(mesh_h handle); +int wifi_mesh_unset_gate(wifi_mesh_h handle); /** - * @brief Called after mesh_get_stations_info() + * @brief Called after wifi_mesh_get_stations_info() * @details This function can receive joined station information from mesh network. * * @since_tizen 4.0 @@ -165,11 +165,11 @@ int mesh_unset_gate(mesh_h handle); * @param[out] station mesh station information handle * @param[out] user_data user data pointer * - * @pre The callback must be registered with mesh_foreach_found_mesh_network() + * @pre The callback must be registered with wifi_mesh_foreach_found_network() * - * @see mesh_foreach_found_mesh_network() + * @see wifi_mesh_foreach_found_network() */ -typedef void (*mesh_found_station_cb)(mesh_station_info_h station, void* user_data); +typedef void (*wifi_mesh_found_station_cb)(mesh_station_info_h station, void* user_data); /** * @brief Get information of all connected stations. @@ -177,23 +177,23 @@ typedef void (*mesh_found_station_cb)(mesh_station_info_h station, void* user_da * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi mesh handle * @param[in] cb The callback function to receive station information * @param[in] user_data User data * * * @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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * * @see mesh_get_path_info() * */ -int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data); +int wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data); /** - * @brief Called after mesh_get_stations_info() + * @brief Called after wifi_mesh_get_stations_info() * @details This function can receive joined station information from mesh network. * * @since_tizen 4.0 @@ -201,9 +201,9 @@ int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_d * @param[out] path mesh path information handle * @param[out] user_data user data pointer * - * @pre The callback must be registered with mesh_foreach_found_mesh_network() + * @pre The callback must be registered with wifi_mesh_foreach_found_network() * - * @see mesh_foreach_found_mesh_network() + * @see wifi_mesh_foreach_found_network() */ typedef void (*mesh_found_mpath_cb)(mesh_mpath_info_h path, void* user_data); @@ -213,20 +213,20 @@ typedef void (*mesh_found_mpath_cb)(mesh_mpath_info_h path, void* user_data); * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi mesh handle * @param[in] cb The callback function to receive mesh path information * @param[in] user_data User data * * * @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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * - * @see mesh_get_stations_info() + * @see wifi_mesh_get_stations_info() * */ -int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data); +int wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *user_data); /** * @brief Sets network device interface name. @@ -234,23 +234,23 @@ int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data); * * @since_tizen 4.0 * - * @param[in] handle The mesh handle + * @param[in] handle The Wi-Fi 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 + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error * */ -int mesh_set_interfaces(mesh_h handle, +int wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char* gate, const char *softap); #ifdef __cplusplus } #endif -#endif /* __TIZEN_MESH_INTERNAL_H__ */ +#endif /* __TIZEN_WIFI_MESH_INTERNAL_H__ */ diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h new file mode 100644 index 0000000..0951724 --- /dev/null +++ b/include/wifi-mesh.h @@ -0,0 +1,1007 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_WIFI_MESH_H__ +#define __TIZEN_WIFI_MESH_H__ + +#include <tizen.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file wifi-mesh.h + */ + +/** +* @addtogroup CAPI_NETWORK_WIFI_MESH_MODULE +* @{ +*/ + +/** + * @brief The Wi-Fi mesh handle. + * @since_tizen 4.0 +*/ +typedef void *wifi_mesh_h; + +/*********************************************************************** + TEMP +***********************************************************************/ +#ifndef TIZEN_ERROR_MESH +#define TIZEN_ERROR_MESH -0x02F60000 +#endif + +/** + * @brief Enumeration for the Wi-Fi mesh error type. + * @since_tizen 4.0 + */ +typedef enum { + WIFI_MESH_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + WIFI_MESH_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + WIFI_MESH_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ + WIFI_MESH_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ + WIFI_MESH_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + WIFI_MESH_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */ + WIFI_MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */ + WIFI_MESH_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */ + WIFI_MESH_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */ + WIFI_MESH_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not Supported */ + WIFI_MESH_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESH | 0x01, /**< Operation failed */ + WIFI_MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH | 0x02, /**< Operation is aborted */ + WIFI_MESH_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_MESH | 0x03, /**< Mesh Already Initialized */ +} wifi_mesh_error_e; + +/** +* @} +*/ + +/** +* @addtogroup CAPI_NETWORK_WIFI_MESH_MONITOR_MODULE +* @{ +*/ + +/** + * @brief The maximum length of mesh id + * + * @since_tizen 4.0 + */ +#define MAX_MESHID_LEN 32 + +/** + * @brief The maximum length of BSSID + * + * @since_tizen 4.0 + */ +#define MAX_BSSID_LEN 18 + +/** + * @brief The maximum length of passphrase + * + * @since_tizen 4.0 + */ +#define MAX_PASSPHRASE_LEN (64+1) + +/** + * @brief Enumeration for the security type of the Wi-Fi Mesh network. + * @since_tizen 4.0 + */ +typedef enum { + MESH_SECURITY_NONE = 0, /**< Open network */ + MESH_SECURITY_SAE, /**< Simultaneous Authentication of Equals */ +} wifi_mesh_security_type_e; + +/** + * @brief Enumeration for the connection state of the Wi-Fi Mesh network. + * @since_tizen 4.0 + */ +typedef enum { + WIFI_MESH_CONNECTION_STATE_DISCONNECTED = 0, /**< Wi-Fi Mesh network is disconnected */ + WIFI_MESH_CONNECTION_STATE_ASSOCIATION, /**< Service is trying to establish low-level network connection to the mesh network. */ + WIFI_MESH_CONNECTION_STATE_CONFIGURATION, /**< Service is trying to retrieve/configure IP settings. */ + WIFI_MESH_CONNECTION_STATE_CONNECTED /**< Wi-Fi Mesh network is connected */ +} wifi_mesh_connection_state_e; + +/** + * @brief The events for wifi_mesh_event_cb + * + * @since_tizen 4.0 + */ +typedef enum { + WIFI_MESH_EVENT_ENABLED = 0x00, /**< This event is received after enabling mesh network */ + WIFI_MESH_EVENT_SCAN_DONE = 0x01, /**< This event comes after scanning operation completed */ + WIFI_MESH_EVENT_CONNECTION_STATE = 0x02, /**< This event takes place when mesh network connection state is changed */ + WIFI_MESH_EVENT_STATION_JOIN = 0x03, /**< This event takes place when new station joined */ + WIFI_MESH_EVENT_STATION_LEFT = 0x04, /**< This event takes place when existing station left */ +} wifi_mesh_event_e; + +/** + * @brief The structure type for the WIFI_MESH_EVENT_ENABLED callback data. + * @details The result of creating or joining mesh network. + * + * @since_tizen 4.0 + */ +typedef struct { + int result; /**< The result of creating or joining mesh network */ +} wifi_mesh_enabled_event_s; + +/** + * @brief The structure type for the WIFI_MESH_EVENT_STATION_JOIN or WIFI_MESH_EVENT_STATION_LEFT callback data. + * @details Result of join or left event of other station. + * + * @since_tizen 4.0 + */ +typedef struct { + char bssid[MAX_BSSID_LEN]; /**< The BSSID of the station that generated the event */ +} wifi_mesh_other_station_event_s; + +/** + * @brief The structure type for the WIFI_MESH_EVENT_CONNECTION_STATE callback data. + * @details The state of mesh network connection. + * + * @since_tizen 4.0 + */ +typedef struct { + char mesh_id[MAX_MESHID_LEN]; /**< The Mesh ID of the network that generated the event */ + char bssid[MAX_BSSID_LEN]; /**< The BSSID of the network that generated the event */ + int channel; /**< The channel of the network that generated the event */ + wifi_mesh_security_type_e security; /**< The security type of network */ + wifi_mesh_connection_state_e state; /**< The state of mesh network connection. */ +} wifi_mesh_connection_state_event_s; + +/** + * @brief The structure type for response data of wifi_mesh_event_cb. + * @details This function can receive events from the devices in the network. + * ex) enable, station information, connection state and etc + * + * @since_tizen 4.0 + */ +typedef struct { + union { + wifi_mesh_enabled_event_s *wifi_mesh_enable; /**< The result of enabling mesh system service. */ + wifi_mesh_other_station_event_s *sta_info; /**< This event comes from other stations. */ + wifi_mesh_connection_state_event_s *connection_state; /**< The state of mesh network connection. */ + } data; +} wifi_mesh_event_data_s; + +/** +* @} +*/ + +/** +* @addtogroup CAPI_NETWORK_WIFI_MESH_MODULE +* @{ +*/ + +/** + * @brief The Wi-Fi mesh network profile handle. + * @since_tizen 4.0 +*/ +typedef void* wifi_mesh_network_h; + +/** + * @brief The Wi-Fi mesh network peer handle. + * @since_tizen 4.0 +*/ +typedef void* wifi_mesh_peer_h; + +/** + * @brief Creates a network handle. + * @details This function is to allocate new mesh network information + * + * @since_tizen 4.0 + * + * @param[out] network The mesh network information handle, we will allocate mesh + * network information structure internally. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_OUT_OF_MEMORY Memory error + * + * @see wifi_mesh_network_clone() + * @see wifi_mesh_network_new_with() + * @see wifi_mesh_network_destroy() + * + */ +int wifi_mesh_network_new(wifi_mesh_network_h* network); + +/** + * @brief Clones a network handle. + * @details This function is to clone mesh network information + * + * @since_tizen 4.0 + * + * @param[out] dst The target Wi-Fi mesh network information handle, we will allocate mesh + * network information structure internally. + * @param[in] src The source mesh network information handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_OUT_OF_MEMORY Memory error + * + * @see wifi_mesh_network_new() + * @see wifi_mesh_network_new_with() + * @see wifi_mesh_network_destroy() + * + */ +int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_network_h src); + +/** + * @brief Creates network handle with parameters. + * @details This function is to allocate new mesh network information + * + * @since_tizen 4.0 + * + * @param[out] network The mesh network information handle, we will allocate mesh + * network information structure internally. + * @param[in] meshid The Mesh Network ID + * @param[in] bssid The Basic Service Set ID + * @param[in] channel The operating channel number + * @param[in] rssi The Received Signal Strength Indicator + * @param[in] security The security type for network + * @param[in] passphrase The passphrase for network connection + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_OUT_OF_MEMORY Memory error + * + * @see wifi_mesh_network_clone() + * @see wifi_mesh_network_new_with() + * @see wifi_mesh_network_destroy() + * + */ +int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const char *meshid, + const char *bssid, int channel, int rssi, wifi_mesh_security_type_e security, + const char *passphrase); + +/** + * @brief Destroys network handle. + * @details This function is to destroy mesh network information + * + * @since_tizen 4.0 + * + * @param[in] network The target Wi-Fi mesh network information handle. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_OUT_OF_MEMORY Memory error + * + * @see wifi_mesh_network_new() + * @see wifi_mesh_network_new_with() + * @see wifi_mesh_network_clone() + * @see wifi_mesh_network_destroy() + * + */ +int wifi_mesh_network_destroy(wifi_mesh_network_h network); + +/** + * @brief Gets a Wi-Fi mesh network id. + * @details This function is to return mesh network id + * @remark The returned string should be freed when no longer needed. + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] meshid The mesh network id. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_meshid() + * + */ +int wifi_mesh_network_get_meshid(wifi_mesh_network_h network, char **meshid); + +/** + * @brief Sets a Wi-Fi mesh network id. + * @details This function is to set Wi-Fi mesh network id + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] meshid The mesh network id. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_meshid() + * + */ +int wifi_mesh_network_set_meshid(wifi_mesh_network_h network, const char *meshid); + +/** + * @brief Gets BSSID. + * @details This function is to get basic service set id + * @remark The returned string should be freed when no longer needed. + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] bssid The basic service set id. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_bssid() + * + */ +int wifi_mesh_network_get_bssid(wifi_mesh_network_h network, char **bssid); + +/** + * @brief Sets BSSID. + * @details This function is to set basic service set id + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] bssid The basic service set id. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_bssid() + * + */ +int wifi_mesh_network_set_bssid(wifi_mesh_network_h network, const char *bssid); + +/** + * @brief Gets channel. + * @details This function is to get channel + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] channel The operating channel number. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_channel() + * + */ +int wifi_mesh_network_get_channel(wifi_mesh_network_h network, int *channel); + +/** + * @brief Sets channel. + * @details This function is to get channel + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] channel The operating channel number. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_channel() + * + */ +int wifi_mesh_network_set_channel(wifi_mesh_network_h network, int channel); + +/** + * @brief Gets RSSI. + * @details This function is to get rssi + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] rssi The received signal strength indicator. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_rssi() + * + */ +int wifi_mesh_network_get_rssi(wifi_mesh_network_h network, int *rssi); + +/** + * @brief Sets RSSI. + * @details This function is to set rssi + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] rssi The received signal strength indicator. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_rssi() + * + */ +int wifi_mesh_network_set_rssi(wifi_mesh_network_h network, int rssi); + +/** + * @brief Gets the security type. + * @details This function is to get the security type. + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] security The security type for network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_security() + * + */ +int wifi_mesh_network_get_security(wifi_mesh_network_h network, wifi_mesh_security_type_e *security); + +/** + * @brief Sets the security type. + * @details This function is to set the security type. + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] security The security type for network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_security() + * + */ +int wifi_mesh_network_set_security(wifi_mesh_network_h network, wifi_mesh_security_type_e security); + +/** + * @brief Sets the passphrase for network connection. + * @details This function is to set the passphrase. + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] passphrase The passphrase for network connection. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_security() + * @see wifi_mesh_network_set_security() + */ +int wifi_mesh_network_set_passphrase(wifi_mesh_network_h network, const char* passphrase); + +/** + * @brief Gets the connection state. + * @details This function is to get the connection state + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] state The maximum data rate. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int wifi_mesh_network_get_connection_state(wifi_mesh_network_h network, wifi_mesh_connection_state_e *state); + +/** + * @brief Gets address from the Wi-Fi mesh peer. + * @details This function is to return mesh network id + * @remark The returned string should be freed when no longer needed. + * + * @since_tizen 4.0 + * + * @param[in] peer The mesh peer information handle. + * @param[out] address The address of mesh peer. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int wifi_mesh_peer_get_address(wifi_mesh_peer_h peer, char **address); + +/** + * @brief Initializes a Wi-Fi Mesh network. + * @since_tizen 4.0 + * @privlevel public + * @remarks You must release @a handle using wifi_mesh_deinitialize(). + * @param[out] handle The Wi-Fi mesh handle + * @return @c 0 on success, otherwise negative error value + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_ALREADY_INITIALIZED Already initialized + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MESH_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_MESH_ERROR_PERMISSION_DENIED Permission Denied + * @retval #WIFI_MESH_ERROR_OUT_OF_MEMORY Out of memory + * @retval #WIFI_MESH_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_mesh_initialize(wifi_mesh_h *handle); + +/** + * @brief Deinitializes the Wi-Fi Mesh network. + * @since_tizen 4.0 + * @param[in] handle The Wi-Fi mesh handle + * @return 0 on success, otherwise negative error value + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_INVALID_OPERATION Invalid operation + * @retval #WIFI_MESH_ERROR_OPERATION_FAILED Operation failed + * @retval #WIFI_MESH_ERROR_NOT_SUPPORTED Not supported + */ +int wifi_mesh_deinitialize(wifi_mesh_h handle); + +/** + * @brief Specifies the type of function passed to wifi_mesh_enable() + * @details This function can receive events from the Wi-Fi mesh network. + * ex) enabled state, scan result + * + * @since_tizen 4.0 + * + * @remarks You can receive below events. + * @see #WIFI_MESH_EVENT_ENABLED + * @see #WIFI_MESH_EVENT_SCAN_DONE + * @see #WIFI_MESH_EVENT_STATION_JOIN + * @see #WIFI_MESH_EVENT_STATION_LEFT + * + * @param[out] event_type The event identification + * @param[out] event parameter data pointer + * + * @pre The callback must be registered with wifi_mesh_enable() + * + * @see wifi_mesh_set_event_cb() + */ +typedef void (*wifi_mesh_event_cb)(wifi_mesh_event_e event_type, wifi_mesh_event_data_s* event); + +/** + * @brief Sets event handler for the Wi-Fi mesh network service. + * @details Sets event handler to get events from the Wi-Fi mesh network service. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] event_handler The event handler + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * @retval #WIFI_MESH_ERROR_NOT_SUPPORTED Not supported + * + * @see wifi_mesh_initialize() + * @see wifi_mesh_deinitialize() + * + */ +int wifi_mesh_set_event_cb(wifi_mesh_h handle, wifi_mesh_event_cb event_handler); + +/** + * @brief Enable the Wi-Fi mesh service. + * @details All this function to start Wi-Fi mesh service + * + * @since_tizen 4.0 + * + * @remarks You must free all resources of the mesh by calling wifi_mesh_deinitialize() + * if mesh service is no longer needed. + * + * @param[in] handle The Wi-Fi mesh handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_initialize() + * @see wifi_mesh_deinitialize() + * @see wifi_mesh_event_cb() + * @see wifi_mesh_disable() + * + */ +int wifi_mesh_enable(wifi_mesh_h handle); + +/** + * @brief disable the Wi-Fi mesh service. + * @details all this function to stop Wi-Fi mesh service + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * @remarks You must free all resources of the mesh by calling wifi_mesh_deinitialize() + * if mesh service is no longer needed. + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_initialize() + * @see wifi_mesh_deinitialize() + * @see wifi_mesh_enable() + * + */ +int wifi_mesh_disable(wifi_mesh_h handle); + +/** + * @brief Scan Wi-Fi mesh networks. + * @details Scan all Wi-Fi mesh network to get network state. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_specific_scan() + * @see wifi_mesh_cancel_scan() + * + */ +int wifi_mesh_scan(wifi_mesh_h handle); + +/** + * @brief Scan for the specific mesh network. + * @details Scan specific SSID and channel to get specific Wi-Fi mesh networks. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] ssid Specific SSID to scan + * @param[in] channel The channel number to scan + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_scan() + * @see wifi_mesh_cancel_scan() + * + */ +int wifi_mesh_specific_scan(wifi_mesh_h handle, const char* ssid, int channel); + +/** + * @brief Called after wifi_mesh_foreach_found_network() + * @details This function can receive scan results from Wi-Fi mesh networks. + * + * @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 wifi_mesh_foreach_found_network() + * + * @see wifi_mesh_foreach_found_network() + */ +typedef void (*wifi_mesh_found_network_cb)(wifi_mesh_network_h network, void* user_data); + +/** + * @brief Gets found Wi-Fi mesh network bss information + * @details This function returns network information found through wifi_mesh_found_network_cb. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi 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 #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_scan() + * @see wifi_mesh_found_network_cb() + * + */ +int wifi_mesh_foreach_found_network(wifi_mesh_h handle, + wifi_mesh_found_network_cb cb, void *user_data); + +/** + * @brief Called after wifi_mesh_foreach_connected_peers() + * @details This function can receive connected peers on the Wi-Fi mesh network. + * + * @since_tizen 4.0 + * + * @param[out] network The mesh peer information handle + * @param[out] user_data user data pointer + * + * @pre The callback must be registered with wifi_mesh_foreach_connected_peers() + * + * @see wifi_mesh_foreach_connected_peers() + */ +typedef void (*wifi_mesh_connected_peer_cb)(wifi_mesh_peer_h peer, void* user_data); + +/** + * @brief Gets found Wi-Fi mesh network peer information + * @details This function returns network information found through wifi_mesh_connected_peer_cb. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] cb callback function pointer to inform peer information + * @param[in] user_data user data pointer + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see mesh_find_peers() + * @see wifi_mesh_connected_peer_cb() + * + */ +int wifi_mesh_foreach_connected_peers(wifi_mesh_h handle, + wifi_mesh_connected_peer_cb cb, void *user_data); + +/** + * @brief Enables the Wi-Fi mesh network. + * @details This function is to join or create Wi-Fi mesh network using saved Wi-Fi mesh network configuration + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_stop_mesh() + * + */ +int wifi_mesh_start_mesh(wifi_mesh_h handle); + +/** + * @brief Disables the Wi-Fi mesh network. + * @details This function is to disjoin or destroy current Wi-Fi mesh network + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_start_mesh() + * + */ +int wifi_mesh_stop_mesh(wifi_mesh_h handle); + +/** + * @brief Get the Wi-Fi mesh connection state. + * @details Check if current device is joined Wi-Fi mesh network. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[out] is_joined The state of mesh network connection. + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_start_mesh() + * @see wifi_mesh_found_network_cb() + * + */ +int wifi_mesh_is_joined(wifi_mesh_h handle, bool* is_joined); + +/** + * @brief Gets current joined Wi-Fi mesh network information. + * @details Return current joined Wi-Fi mesh network information.. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[out] network Wi-Fi Mesh bss information handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_start_mesh() + * + */ +int wifi_mesh_get_joined_network(wifi_mesh_h handle, wifi_mesh_network_h* network); + +/** + * @brief Sets softap options + * @details This function sets softap options. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] ssid The SSID + * @param[in] key The pre-shared key + * @param[in] channel The operating channel number + * @param[in] visibility The broadcast option (1:Broadcast SSID, 2:Hidden) + * @param[in] max_stations The maximum allowable number of stations (default:10) + * @param[in] security Security option (1:WPA1, 2:WPA2) + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_enable_softap() + * @see wifi_mesh_disable_softap() + * + */ +int wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, + int channel, bool visibility, int max_stations, int security); + +/** + * @brief Enables softap + * @details This function enables softap. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_set_softap() + * @see wifi_mesh_disable_softap() + * + */ +int wifi_mesh_enable_softap(wifi_mesh_h handle); + +/** + * @brief Disable softap + * @details This function disables softap. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_set_softap() + * @see wifi_mesh_enable_softap() + * + */ +int wifi_mesh_disable_softap(wifi_mesh_h handle); + +/** + * @brief Creates new Wi-Fi mesh network configuration + * @details This function creates new mesh network. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] network Wi-Fi Mesh bss information handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_connect_network() + * @see wifi_mesh_disconnect_network() + * @see wifi_mesh_forget_network() + * + */ +int wifi_mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h network); + +/** + * @brief Connects existing Wi-Fi mesh network + * @details This function makes a connection to existing Wi-Fi mesh network. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] network Wi-Fi Mesh bss information handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_create_network() + * @see wifi_mesh_disconnect_network() + * @see wifi_mesh_forget_network() + * + */ +int wifi_mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h network); + +/** + * @brief Disconnects existing Wi-Fi mesh network + * @details This function disconnects with existing Wi-Fi mesh network. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] network Wi-Fi Mesh bss information handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_create_network() + * @see wifi_mesh_forget_network() + * + */ +int wifi_mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h network); + +/** + * @brief Forgets existing Wi-Fi mesh network + * @details This function removes the information of connected network. + * + * @since_tizen 4.0 + * + * @param[in] handle The Wi-Fi mesh handle + * @param[in] network Wi-Fi Mesh bss information handle + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #WIFI_MESH_ERROR_IO_ERROR Unexpected d-bus error + * + * @see wifi_mesh_create_network() + * @see wifi_mesh_connect_network() + * @see wifi_mesh_disconnect_network() + * + */ +int wifi_mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h network); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_WIFI_MESH_H__ */ diff --git a/include/wifi-mesh_dbus.h b/include/wifi-mesh_dbus.h new file mode 100644 index 0000000..05a0131 --- /dev/null +++ b/include/wifi-mesh_dbus.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIFI_MESH_DBUS_H__ +#define __WIFI_MESH_DBUS_H__ + +#include "wifi-mesh.h" +#include "wifi-mesh-internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MESH_SERVER_NAME "net.mesh" +#define MESH_OBJECT_PATH "/net/mesh" +#define MESH_SERVICE_INTERFACE "net.mesh" + +#define MESH_MANAGER_NAME "net.mesh.manager" +#define MESH_MANAGER_OBJ_PATH "/net/mesh/manager" +#define MESH_MANAGER_INTERFACE "net.mesh.manager" + +#define MESH_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */ + +int _mesh_dbus_start(wifi_mesh_h m); +int _mesh_dbus_stop(wifi_mesh_h m); + +int _wifi_mesh_set_event_cb(wifi_mesh_h handle, wifi_mesh_event_cb event_handler); +int _wifi_mesh_enable(wifi_mesh_h handle); +int _wifi_mesh_disable(wifi_mesh_h handle); +int _wifi_mesh_scan(wifi_mesh_h handle); +int _wifi_mesh_specific_scan(wifi_mesh_h handle, const char* ssid, int channel); +int _wifi_mesh_cancel_scan(wifi_mesh_h handle); +int _wifi_mesh_get_scan_result(wifi_mesh_h handle); +int _mesh_foreach_found_mesh_network(wifi_mesh_h handle, + wifi_mesh_found_network_cb cb, void *user_data); +int _wifi_mesh_find_peers(wifi_mesh_h handle); +int _wifi_mesh_foreach_connected_peers(wifi_mesh_h handle, + wifi_mesh_connected_peer_cb cb, void *user_data); +int _wifi_mesh_enable_mesh(wifi_mesh_h handle); +int _wifi_mesh_disable_mesh(wifi_mesh_h handle); +int _wifi_mesh_is_joined(wifi_mesh_h handle, bool* is_joined); +int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _network); +int _wifi_mesh_set_gate(wifi_mesh_h handle, bool gate_announce, int hwmp_root_mode, bool stp); +int _wifi_mesh_unset_gate(wifi_mesh_h handle); +int _wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, const char* mode, + int channel, int visibility, int max_stations, int security); +int _wifi_mesh_enable_softap(wifi_mesh_h handle); +int _wifi_mesh_disable_softap(wifi_mesh_h handle); +int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network); +int _mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h _network); +int _mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h _network); +int _mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h _network); +int _mesh_set_interface(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap); +int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data); +int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *user_data); +int _wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap); + +#ifdef __cplusplus +} +#endif + +#endif /** __WIFI_MESH_DBUS_H__ */ diff --git a/include/mesh_log.h b/include/wifi-mesh_log.h index 2093faa..2842cd6 100644 --- a/include/mesh_log.h +++ b/include/wifi-mesh_log.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef __CAPI_MESH_LOG_H__ -#define __CAPI_MESH_LOG_H__ +#ifndef __CAPI_WIFI_MESH_LOG_H__ +#define __CAPI_WIFI_MESH_LOG_H__ #include <dlog.h> #ifdef LOG_TAG #undef LOG_TAG #endif -#define LOG_TAG "CAPI_MESH" +#define LOG_TAG "WIFI_MESH" #define RET_IF(expr) \ do { \ diff --git a/include/mesh_private.h b/include/wifi-mesh_private.h index 63a22ab..67b3093 100644 --- a/include/mesh_private.h +++ b/include/wifi-mesh_private.h @@ -14,22 +14,22 @@ * limitations under the License. */ -#ifndef __CAPI_MESH_PRIVATE_H__ -#define __CAPI_MESH_PRIVATE_H__ +#ifndef __CAPI_WIFI_MESH_PRIVATE_H__ +#define __CAPI_WIFI_MESH_PRIVATE_H__ #include <net/if.h> #include <gio/gio.h> #include <glib.h> #include <system_info.h> -#include "mesh.h" +#include "wifi-mesh.h" #define MESH_FEATURE "http://tizen.org/feature/network.mesh" #define CHECK_INPUT_PARAMETER(arg) \ if (arg == NULL) { \ LOGE("INVALID_PARAMETER"); \ - return MESH_ERROR_INVALID_PARAMETER; \ + return WIFI_MESH_ERROR_INVALID_PARAMETER; \ } #if 0 @@ -38,11 +38,11 @@ if (!system_info_get_platform_bool(feature_name, &mesh_supported)) { \ if (mesh_supported == FALSE) { \ LOGE("mesh feature is disabled"); \ - return MESH_ERROR_NOT_SUPPORTED; \ + return WIFI_MESH_ERROR_NOT_SUPPORTED; \ } \ } else { \ LOGE("Error - Feature getting from System Info"); \ - return MESH_ERROR_OPERATION_FAILED; \ + return WIFI_MESH_ERROR_OPERATION_FAILED; \ } \ } #else @@ -55,7 +55,7 @@ typedef struct mesh_handle { gpointer dbus_connection; GCancellable *ca; GList *dbus_sub_ids; - mesh_event_cb event_handler; + wifi_mesh_event_cb event_handler; /* TODO: Below members are related with event callback * Need to be considered */ @@ -78,9 +78,9 @@ struct mesh_network_s { int channel; /**< Channel */ int rssi; /**< RSSI */ int data_rate; /**< Data rate */ - mesh_security_type_e security; /**< Security type */ + wifi_mesh_security_type_e security; /**< Security type */ char passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase */ - mesh_connection_state_e state; /**< Connection state */ + wifi_mesh_connection_state_e state; /**< Connection state */ }; struct mesh_station_info_s { @@ -135,4 +135,4 @@ struct mesh_mpath_dump_s { #define NOTUSED(var) (var = var) -#endif /* __CAPI_MESH_PRIVATE_H__ */ +#endif /* __CAPI_WIFI_MESH_PRIVATE_H__ */ diff --git a/include/service_error.h b/include/wifi-mesh_service_error.h index 53b4036..ba51996 100644 --- a/include/service_error.h +++ b/include/wifi-mesh_service_error.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __MESH_SERVICE_ERROR_H__ -#define __MESH_SERVICE_ERROR_H__ +#ifndef __WIFI_MESH_SERVICE_ERROR_H__ +#define __WIFI_MESH_SERVICE_ERROR_H__ #ifdef __cplusplus extern "C" { @@ -36,4 +36,4 @@ typedef enum { } #endif -#endif /** __MESH_SERVICE_ERROR_H__ */ +#endif /** __WIFI_MESH_SERVICE_ERROR_H__ */ diff --git a/packaging/capi-network-mesh.manifest b/packaging/capi-network-wifi-mesh.manifest index 97e8c31..97e8c31 100644 --- a/packaging/capi-network-mesh.manifest +++ b/packaging/capi-network-wifi-mesh.manifest diff --git a/packaging/capi-network-mesh.spec b/packaging/capi-network-wifi-mesh.spec index d80d032..a8b13c5 100644 --- a/packaging/capi-network-mesh.spec +++ b/packaging/capi-network-wifi-mesh.spec @@ -2,11 +2,11 @@ %define minor 1 %define patchlevel 1 -Name: capi-network-mesh +Name: capi-network-wifi-mesh Version: %{major}.%{minor}.%{patchlevel} Release: 1 License: Apache-2.0 -Summary: Mesh Core API +Summary: Wi-Fi Mesh Core API Group: System/Libraries Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest @@ -20,10 +20,10 @@ Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description -Mesh network Core API library +Wi-Fi Mesh network Core API library %package devel -Summary: Mesh Core API +Summary: Wi-Fi Mesh Core API Group: Development/Libraries Requires: %{name} = %{version}-%{release} @@ -54,12 +54,12 @@ rm -rf %{buildroot} %postun -p /sbin/ldconfig %files -%manifest capi-network-mesh.manifest -%attr(644,-,-) %{_libdir}/libcapi-network-mesh.so.* +%manifest capi-network-wifi-mesh.manifest +%attr(644,-,-) %{_libdir}/libcapi-network-wifi-mesh.so.* %license LICENSE -%{_bindir}/mesh_test +%{_bindir}/wifi-mesh-test %files devel %{_includedir}/network/*.h %{_libdir}/pkgconfig/*.pc -%{_libdir}/libcapi-network-mesh.so +%{_libdir}/libcapi-network-wifi-mesh.so diff --git a/src/mesh_internal.c b/src/mesh_internal.c deleted file mode 100644 index 91d4d4a..0000000 --- a/src/mesh_internal.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mesh.h" -#include "mesh_log.h" -#include "mesh_private.h" -#include "mesh_dbus.h" - -/** - * Mesh network CAPI - */ - -EXPORT_API int mesh_network_get_data_rate(mesh_network_h network, int *data_rate) -{ - struct mesh_network_s *net = (struct mesh_network_s *)network; - - CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - - if (network == NULL || data_rate == NULL) { - /* LCOV_EXCL_START */ - LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; - /* LCOV_EXCL_STOP */ - } - - *data_rate = net->data_rate; - - return MESH_ERROR_NONE; -} - -EXPORT_API int mesh_network_set_data_rate(mesh_network_h network, int data_rate) -{ - struct mesh_network_s *net = (struct mesh_network_s *)network; - - CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - - if (network == NULL) { - /* LCOV_EXCL_START */ - LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; - /* LCOV_EXCL_STOP */ - } - - net->data_rate = data_rate; - - 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); - return rv; -} - -EXPORT_API int mesh_set_gate(mesh_h handle, int gate_announce, int hwmp_root_mode, bool stp) -{ - int rv = 0; - int _stp = stp ? 1 : 0; - CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - - rv = _mesh_set_gate(handle, gate_announce, hwmp_root_mode, _stp); - return rv; -} - -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_unset_gate(handle); - return rv; -} - -EXPORT_API int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data) -{ - int rv = 0; - CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - - rv = _mesh_get_stations_info(handle, cb, user_data); - return rv; -} - -EXPORT_API int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) -{ - int rv = 0; - CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - - rv = _mesh_get_mpath_info(handle, cb, user_data); - return rv; -} - -EXPORT_API int mesh_set_interfaces(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_interfaces(handle, mesh, gate, softap); - return rv; -} - diff --git a/src/mesh_dbus.c b/src/wifi-mesh-dbus.c index be8cebc..f3fb6af 100644 --- a/src/mesh_dbus.c +++ b/src/wifi-mesh-dbus.c @@ -17,37 +17,37 @@ #include <stdio.h> #include <stdlib.h> -#include "mesh.h" -#include "mesh_log.h" -#include "mesh_dbus.h" -#include "mesh_private.h" -#include "service_error.h" +#include "wifi-mesh.h" +#include "wifi-mesh_log.h" +#include "wifi-mesh_dbus.h" +#include "wifi-mesh_private.h" +#include "wifi-mesh_service_error.h" static GDBusProxy *_gproxy_mesh_service = NULL; -static int _mesh_close_gdbus_call(mesh_h m); +static int _wifi_mesh_close_gdbus_call(wifi_mesh_h m); -static mesh_error_e __convert_service_error_type(service_error_e err_type) +static wifi_mesh_error_e __convert_service_error_type(service_error_e err_type) { switch (err_type) { case SERVICE_ERROR_NONE: - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; case SERVICE_ERROR_IO_ERROR: - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; case SERVICE_ERROR_NO_DATA: - return MESH_ERROR_NO_DATA; + return WIFI_MESH_ERROR_NO_DATA; case SERVICE_ERROR_OUT_OF_MEMORY: - return MESH_ERROR_OUT_OF_MEMORY; + return WIFI_MESH_ERROR_OUT_OF_MEMORY; case SERVICE_ERROR_OPERATION_FAILED: - return MESH_ERROR_OPERATION_FAILED; + return WIFI_MESH_ERROR_OPERATION_FAILED; case SERVICE_ERROR_INVALID_PARAMETER: - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; case SERVICE_ERROR_ALREADY_REGISTERED: - return MESH_ERROR_ALREADY_IN_PROGRESS; + return WIFI_MESH_ERROR_ALREADY_IN_PROGRESS; case SERVICE_ERROR_IN_PROGRESS: - return MESH_ERROR_NOW_IN_PROGRESS; + return WIFI_MESH_ERROR_NOW_IN_PROGRESS; default: - return MESH_ERROR_OPERATION_FAILED; + return WIFI_MESH_ERROR_OPERATION_FAILED; } } @@ -74,27 +74,27 @@ static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec, { GDBusProxy *proxy = G_DBUS_PROXY(object); gchar *name_owner = g_dbus_proxy_get_name_owner(proxy); - mesh_h handle = (mesh_h)user_data; + wifi_mesh_h handle = (wifi_mesh_h)user_data; LOGD("Name owner notify [%s]", name_owner); if (NULL == name_owner) - _mesh_close_gdbus_call(handle); + _wifi_mesh_close_gdbus_call(handle); g_free(name_owner); } -static int _mesh_create_gdbus_call(mesh_h handle) +static int _wifi_mesh_create_gdbus_call(wifi_mesh_h handle) { int id; GError *error = NULL; struct mesh_handle *h = handle; if (NULL == h) - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; if (h->dbus_connection != NULL) - return MESH_ERROR_ALREADY_IN_PROGRESS; + return WIFI_MESH_ERROR_ALREADY_IN_PROGRESS; h->dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (h->dbus_connection == NULL) { @@ -102,7 +102,7 @@ static int _mesh_create_gdbus_call(mesh_h handle) LOGE("Failed to connect to the D-BUS daemon [%s]", error->message); g_error_free(error); } - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } id = g_signal_connect(h->dbus_connection, "notify::g-name-owner", @@ -111,13 +111,13 @@ static int _mesh_create_gdbus_call(mesh_h handle) LOGE("g_signal_connect() Fail"); g_object_unref(h->dbus_connection); h->dbus_connection = NULL; - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -static int _mesh_close_gdbus_call(mesh_h handle) +static int _wifi_mesh_close_gdbus_call(wifi_mesh_h handle) { struct mesh_handle *h = handle; @@ -125,11 +125,11 @@ static int _mesh_close_gdbus_call(mesh_h handle) g_object_unref(h->dbus_connection); h->dbus_connection = NULL; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } static GList *g_networks = { 0, }; -static void _mesh_free_network(gpointer data) +static void _wifi_mesh_free_network(gpointer data) { struct mesh_network_s *network = data; g_free(network); @@ -139,32 +139,32 @@ static void _mesh_free_network(gpointer data) static void _mesh_remove_networks() { if (g_networks) - g_list_free_full(g_networks, _mesh_free_network); + g_list_free_full(g_networks, _wifi_mesh_free_network); g_networks = NULL; } -static void _mesh_append_network(gpointer data) +static void _wifi_mesh_append_network(gpointer data) { g_networks = g_list_append(g_networks, data); } static GList *g_peers = NULL; -static void _mesh_remove_peers() +static void _wifi_mesh_remove_peers() { if (g_peers) g_list_free(g_peers); g_peers = NULL; } -static void _mesh_append_peer(gpointer data) +static void _wifi_mesh_append_peer(gpointer data) { g_peers = g_list_append(g_peers, data); } -int _mesh_get_scan_result(mesh_h handle) +int _wifi_mesh_get_scan_result(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; @@ -178,8 +178,8 @@ int _mesh_get_scan_result(mesh_h handle) /* Clear previous scan results */ _mesh_remove_networks(); - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_found_mesh_networks", NULL, @@ -217,7 +217,7 @@ int _mesh_get_scan_result(mesh_h handle) LOGD(" State [%d]", network_info->state); } } - _mesh_append_network(network_info); + _wifi_mesh_append_network(network_info); g_variant_iter_free(iter_row); } @@ -226,16 +226,16 @@ int _mesh_get_scan_result(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_find_peers(mesh_h handle) +int _wifi_mesh_find_peers(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; @@ -247,10 +247,10 @@ int _mesh_find_peers(mesh_h handle) gsize len = 0; /* Clear previous peer list */ - _mesh_remove_peers(); + _wifi_mesh_remove_peers(); - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_connected_peers", NULL, @@ -271,7 +271,7 @@ int _mesh_find_peers(mesh_h handle) } } /* Last element */ - _mesh_append_peer(peer_info); + _wifi_mesh_append_peer(peer_info); g_variant_iter_free(iter_row); } g_variant_iter_free(iter); @@ -279,7 +279,7 @@ int _mesh_find_peers(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; @@ -295,77 +295,77 @@ static void _mesh_signal_handler(GDBusConnection *connection, RETM_IF(NULL == h->event_handler, "event_handler is null"); LOGD("signal received = %s", signal_name); - if (0 == g_strcmp0(signal_name, "mesh_enabled")) { - int result = MESH_ERROR_NONE; - mesh_event_data_s ev; + if (0 == g_strcmp0(signal_name, "wifi_mesh_enabled")) { + int result = WIFI_MESH_ERROR_NONE; + wifi_mesh_event_data_s ev; g_variant_get(parameters, "(i)", &result); - ev.data.mesh_enable = calloc(1, sizeof(mesh_mesh_enabled_event_s)); - RETM_IF(NULL == ev.data.mesh_enable, "Failed to memory allocation !"); - ev.data.mesh_enable->result = __convert_service_error_type(result); + ev.data.wifi_mesh_enable = calloc(1, sizeof(wifi_mesh_enabled_event_s)); + RETM_IF(NULL == ev.data.wifi_mesh_enable, "Failed to memory allocation !"); + ev.data.wifi_mesh_enable->result = __convert_service_error_type(result); - h->event_handler(MESH_EVENT_ENABLED, &ev); - free(ev.data.mesh_enable); + h->event_handler(WIFI_MESH_EVENT_ENABLED, &ev); + free(ev.data.wifi_mesh_enable); } else if (0 == g_strcmp0(signal_name, "scan_done")) { - h->event_handler(MESH_EVENT_SCAN_DONE, NULL); + h->event_handler(WIFI_MESH_EVENT_SCAN_DONE, NULL); } else if (0 == g_strcmp0(signal_name, "connection_state")) { char *mesh_id = NULL; char *bssid = NULL; int channel = 0; int state = 0; int security = 0; - mesh_event_data_s ev; + wifi_mesh_event_data_s ev; g_variant_get(parameters, "(ssiii)", &mesh_id, &bssid, &channel, &security, &state); - ev.data.connection_state = calloc(1, sizeof(mesh_connection_state_event_s)); + ev.data.connection_state = calloc(1, sizeof(wifi_mesh_connection_state_event_s)); RETM_IF(NULL == ev.data.connection_state, "Failed to memory allocation !"); g_snprintf(ev.data.connection_state->mesh_id, MAX_MESHID_LEN, "%s", mesh_id); g_snprintf(ev.data.connection_state->bssid, MAX_BSSID_LEN, "%s", bssid); ev.data.connection_state->channel = channel; - ev.data.connection_state->security = (mesh_security_type_e)security; - ev.data.connection_state->state = (mesh_connection_state_e)state; + ev.data.connection_state->security = (wifi_mesh_security_type_e)security; + ev.data.connection_state->state = (wifi_mesh_connection_state_e)state; - h->event_handler(MESH_EVENT_CONNECTION_STATE, &ev); + h->event_handler(WIFI_MESH_EVENT_CONNECTION_STATE, &ev); free(ev.data.connection_state); } else if (0 == g_strcmp0(signal_name, "sta_joined")) { char *bssid = NULL; - mesh_event_data_s ev; - ev.data.sta_info = calloc(1, sizeof(mesh_other_station_event_s)); + wifi_mesh_event_data_s ev; + ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); RETM_IF(NULL == ev.data.sta_info, "Failed to memory allocation !"); g_variant_get(parameters, "(s)", &bssid); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); - h->event_handler(MESH_EVENT_STATION_JOIN, &ev); + h->event_handler(WIFI_MESH_EVENT_STATION_JOIN, &ev); free(ev.data.sta_info); } else if (0 == g_strcmp0(signal_name, "sta_left")) { char *bssid = NULL; - mesh_event_data_s ev; - ev.data.sta_info = calloc(1, sizeof(mesh_other_station_event_s)); + wifi_mesh_event_data_s ev; + ev.data.sta_info = calloc(1, sizeof(wifi_mesh_other_station_event_s)); RETM_IF(NULL == ev.data.sta_info, "Failed to memory allocation !"); g_variant_get(parameters, "(s)", &bssid); memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN); - h->event_handler(MESH_EVENT_STATION_LEFT, &ev); + h->event_handler(WIFI_MESH_EVENT_STATION_LEFT, &ev); free(ev.data.sta_info); } } -static void _mesh_subscribe_event(mesh_h handle) +static void _mesh_subscribe_event(wifi_mesh_h handle) { unsigned int id; struct mesh_handle *h = handle; - /* mesh_enabled */ + /* wifi_mesh_enabled */ id = g_dbus_connection_signal_subscribe((GDBusConnection *)h->dbus_connection, - NULL, MESH_SERVER_NAME, "mesh_enabled", MESH_OBJECT_PATH, NULL, + NULL, MESH_SERVER_NAME, "wifi_mesh_enabled", MESH_OBJECT_PATH, NULL, G_DBUS_CALL_FLAGS_NONE, _mesh_signal_handler, h, NULL); if (0 == id) { - LOGE("g_dbus_connection_signal_subscribe(mesh_enabled) Fail(%d)", errno); + LOGE("g_dbus_connection_signal_subscribe(wifi_mesh_enabled) Fail(%d)", errno); return; } h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id)); - LOGD("subscribed for mesh_enabled signal %d", id); + LOGD("subscribed for wifi_mesh_enabled signal %d", id); /* scan_done */ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, MESH_SERVER_NAME, @@ -422,7 +422,7 @@ static void _on_unsubscribe_ids(gpointer data, gpointer user_data) (GDBusConnection *)h->dbus_connection, id); } -static void _mesh_unsubscribe_event(mesh_h handle) +static void _mesh_unsubscribe_event(wifi_mesh_h handle) { struct mesh_handle *h = handle; RET_IF(NULL == h); @@ -433,13 +433,13 @@ static void _mesh_unsubscribe_event(mesh_h handle) h->dbus_sub_ids = NULL; } -int _mesh_dbus_start(mesh_h handle) +int _mesh_dbus_start(wifi_mesh_h handle) { struct mesh_handle *h = handle; int rv; - rv = _mesh_create_gdbus_call(handle); - if (MESH_ERROR_NONE != rv) + rv = _wifi_mesh_create_gdbus_call(handle); + if (WIFI_MESH_ERROR_NONE != rv) return rv; h->ca = g_cancellable_new(); @@ -447,23 +447,23 @@ int _mesh_dbus_start(mesh_h handle) /* Create all proxies here */ _gproxy_mesh_service = _proxy_get_mesh_service(h); RETVM_IF(NULL == _gproxy_mesh_service, - MESH_ERROR_IO_ERROR, "Couldn't get _gproxy_mesh_service"); + WIFI_MESH_ERROR_IO_ERROR, "Couldn't get _gproxy_mesh_service"); g_dbus_proxy_set_default_timeout( G_DBUS_PROXY(_gproxy_mesh_service), MESH_DBUS_PROXY_TIMEOUT); /* Subscribe events */ _mesh_subscribe_event(handle); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -int _mesh_dbus_stop(mesh_h handle) +int _mesh_dbus_stop(wifi_mesh_h handle) { struct mesh_handle *h = handle; int rv; if (NULL == h) - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; _mesh_unsubscribe_event(handle); @@ -477,7 +477,7 @@ int _mesh_dbus_stop(mesh_h handle) g_object_unref(h->ca); h->ca = NULL; - rv = _mesh_close_gdbus_call(handle); + rv = _wifi_mesh_close_gdbus_call(handle); return rv; } @@ -515,22 +515,22 @@ static void _mesh_remove_mpath() g_mpath.count = 0; } -int _mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler) +int _wifi_mesh_set_event_cb(wifi_mesh_h handle, wifi_mesh_event_cb event_handler) { struct mesh_handle *h = handle; - RETV_IF(NULL == h, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == h, WIFI_MESH_ERROR_INVALID_PARAMETER); h->event_handler = event_handler; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -int _mesh_enable(mesh_h handle) +int _wifi_mesh_enable(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_connection_call_sync(h->dbus_connection, MESH_MANAGER_NAME, @@ -547,24 +547,24 @@ int _mesh_enable(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_disable(mesh_h handle) +int _wifi_mesh_disable(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - _mesh_remove_peers(); + _wifi_mesh_remove_peers(); _mesh_remove_networks(); _mesh_remove_mpath(); - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_connection_call_sync(h->dbus_connection, MESH_MANAGER_NAME, @@ -581,22 +581,22 @@ int _mesh_disable(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } h->event_handler = NULL; return result; } -int _mesh_scan(mesh_h handle) +int _wifi_mesh_scan(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "scan", NULL, @@ -610,21 +610,21 @@ int _mesh_scan(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel) +int _wifi_mesh_specific_scan(wifi_mesh_h handle, const char* ssid, int channel) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "specific_scan", g_variant_new("(si)", ssid, channel), @@ -638,21 +638,21 @@ int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_cancel_scan(mesh_h handle) +int _wifi_mesh_cancel_scan(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "cancel_scan", NULL, @@ -666,27 +666,27 @@ int _mesh_cancel_scan(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_foreach_found_mesh_network(mesh_h handle, - mesh_found_mesh_network_cb cb, void *user_data) +int _mesh_foreach_found_mesh_network(wifi_mesh_h handle, + wifi_mesh_found_network_cb cb, void *user_data) { int i; GList *iter = NULL; struct mesh_network_s *data = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == cb, WIFI_MESH_ERROR_INVALID_PARAMETER); if (0 >= g_list_length(g_networks)) { LOGD("No scan result"); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } /* Get a first item */ @@ -703,24 +703,24 @@ int _mesh_foreach_found_mesh_network(mesh_h handle, i++; } - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -int _mesh_foreach_connected_peers(mesh_h handle, - mesh_connected_peer_cb cb, void *user_data) +int _wifi_mesh_foreach_connected_peers(wifi_mesh_h handle, + wifi_mesh_connected_peer_cb cb, void *user_data) { int i; GList *iter = NULL; struct mesh_network_s *data = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == cb, WIFI_MESH_ERROR_INVALID_PARAMETER); if (0 >= g_list_length(g_peers)) { LOGD("No peer data"); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } /* Get a first item */ @@ -737,18 +737,18 @@ int _mesh_foreach_connected_peers(mesh_h handle, i++; } - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -int _mesh_enable_mesh(mesh_h handle) +int _wifi_mesh_enable_mesh(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "enable_mesh", NULL, @@ -762,21 +762,21 @@ int _mesh_enable_mesh(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_disable_mesh(mesh_h handle) +int _wifi_mesh_disable_mesh(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disable_mesh", NULL, @@ -790,23 +790,23 @@ int _mesh_disable_mesh(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } /* TODO: Parameter verification required */ -int _mesh_is_joined(mesh_h handle, bool* is_joined) +int _wifi_mesh_is_joined(wifi_mesh_h handle, bool* is_joined) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; gboolean state; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "is_joined", NULL, @@ -821,7 +821,7 @@ int _mesh_is_joined(mesh_h handle, bool* is_joined) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; @@ -829,16 +829,16 @@ int _mesh_is_joined(mesh_h handle, bool* is_joined) struct mesh_network_s g_joined_network; -int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) +int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _network) { - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GVariant *variant = NULL; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _network, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _network, WIFI_MESH_ERROR_INVALID_PARAMETER); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_joined_mesh_network", NULL, @@ -865,14 +865,14 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) g_joined_network.rssi = -1; g_joined_network.data_rate = 0; g_joined_network.security = MESH_SECURITY_NONE; - g_joined_network.state = MESH_CONNECTION_STATE_DISCONNECTED; + g_joined_network.state = WIFI_MESH_CONNECTION_STATE_DISCONNECTED; if (SERVICE_ERROR_NO_DATA == svc_result) { *_network = NULL; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } - if (MESH_ERROR_NONE != result) + if (WIFI_MESH_ERROR_NONE != result) return result; if (meshid) { @@ -892,21 +892,21 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_set_gate(mesh_h handle, bool gate_announce, int hwmp_root_mode, bool stp) +int _wifi_mesh_set_gate(wifi_mesh_h handle, bool gate_announce, int hwmp_root_mode, bool stp) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "set_gate", g_variant_new("(bqq)", gate_announce, hwmp_root_mode, stp), @@ -920,21 +920,21 @@ int _mesh_set_gate(mesh_h handle, bool gate_announce, int hwmp_root_mode, bool s } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_unset_gate(mesh_h handle) +int _wifi_mesh_unset_gate(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "unset_gate", NULL, @@ -948,24 +948,24 @@ int _mesh_unset_gate(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_set_softap(mesh_h handle, const char* ssid, +int _wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, const char* mode, int channel, int visibility, int max_stations, int security) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "set_softap", g_variant_new("(sssiiii)", ssid, key, mode, @@ -980,21 +980,21 @@ int _mesh_set_softap(mesh_h handle, const char* ssid, } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_enable_softap(mesh_h handle) +int _wifi_mesh_enable_softap(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "enable_softap", NULL, @@ -1008,21 +1008,21 @@ int _mesh_enable_softap(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_disable_softap(mesh_h handle) +int _wifi_mesh_disable_softap(wifi_mesh_h handle) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disable_softap", NULL, @@ -1036,22 +1036,22 @@ int _mesh_disable_softap(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_create_network(mesh_h handle, mesh_network_h _network) +int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "create_mesh_network", g_variant_new("(sii)", n->meshid, n->channel, n->security), @@ -1065,22 +1065,22 @@ int _mesh_create_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_connect_network(mesh_h handle, mesh_network_h _network) +int _mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h _network) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "connect_mesh_network", g_variant_new("(siis)", n->meshid, n->channel, n->security, n->passphrase), @@ -1094,22 +1094,22 @@ int _mesh_connect_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network) +int _mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h _network) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "disconnect_mesh_network", g_variant_new("(sii)", n->meshid, n->channel, n->security), @@ -1123,22 +1123,22 @@ int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_forget_network(mesh_h handle, mesh_network_h _network) +int _mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h _network) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); LOGD("mesid=%s channel=%d security=%d", n->meshid, n->channel, n->security); @@ -1154,16 +1154,16 @@ int _mesh_forget_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data) +int _wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; @@ -1174,8 +1174,8 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_ GVariant *val; gsize len = 0; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_station_info", NULL, @@ -1298,16 +1298,16 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_ } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) +int _wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *user_data) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; @@ -1318,8 +1318,8 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) GVariant *val; gsize len = 0; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_mpath_info", NULL, @@ -1385,21 +1385,21 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; } -int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, const char *softap) +int _wifi_mesh_set_interfaces(wifi_mesh_h handle, const char *mesh, const char *gate, const char *softap) { GVariant *variant = NULL; - int result = MESH_ERROR_NONE; + int result = WIFI_MESH_ERROR_NONE; GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, WIFI_MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, WIFI_MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "set_interfaces", g_variant_new("(sss)", mesh, gate, softap), @@ -1413,7 +1413,7 @@ int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, cons } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ERROR_IO_ERROR; + return WIFI_MESH_ERROR_IO_ERROR; } return result; diff --git a/src/wifi-mesh-internal.c b/src/wifi-mesh-internal.c new file mode 100644 index 0000000..80ae01d --- /dev/null +++ b/src/wifi-mesh-internal.c @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "wifi-mesh.h" +#include "wifi-mesh_log.h" +#include "wifi-mesh_private.h" +#include "wifi-mesh_dbus.h" + +/** + * Wi-Fi Mesh network CAPI + */ + +EXPORT_API int wifi_mesh_network_get_data_rate(wifi_mesh_network_h network, int *data_rate) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (network == NULL || data_rate == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + *data_rate = net->data_rate; + + return WIFI_MESH_ERROR_NONE; +} + +EXPORT_API int wifi_mesh_network_set_data_rate(wifi_mesh_network_h network, int data_rate) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (network == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + net->data_rate = data_rate; + + return WIFI_MESH_ERROR_NONE; +} + +EXPORT_API int wifi_mesh_cancel_scan(wifi_mesh_h handle) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_cancel_scan(handle); + return rv; +} + +EXPORT_API int wifi_mesh_set_gate(wifi_mesh_h handle, int gate_announce, int hwmp_root_mode, bool stp) +{ + int rv = 0; + int _stp = stp ? 1 : 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_set_gate(handle, gate_announce, hwmp_root_mode, _stp); + return rv; +} + +EXPORT_API int wifi_mesh_unset_gate(wifi_mesh_h handle) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_unset_gate(handle); + return rv; +} + +EXPORT_API int wifi_mesh_get_stations_info(wifi_mesh_h handle, wifi_mesh_found_station_cb cb, void *user_data) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_get_stations_info(handle, cb, user_data); + return rv; +} + +EXPORT_API int wifi_mesh_get_mpath_info(wifi_mesh_h handle, mesh_found_mpath_cb cb, void *user_data) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_get_mpath_info(handle, cb, user_data); + return rv; +} + +EXPORT_API int wifi_mesh_set_interfaces(wifi_mesh_h handle, + const char *mesh, const char* gate, const char *softap) +{ + int rv = 0; + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + RETV_IF(NULL == mesh, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + + rv = _wifi_mesh_set_interfaces(handle, mesh, gate, softap); + return rv; +} + diff --git a/src/mesh.c b/src/wifi-mesh.c index 436bcdb..b34d3c7 100644 --- a/src/mesh.c +++ b/src/wifi-mesh.c @@ -17,16 +17,16 @@ #include <stdio.h> #include <stdlib.h> -#include "mesh.h" -#include "mesh_log.h" -#include "mesh_private.h" -#include "mesh_dbus.h" +#include "wifi-mesh.h" +#include "wifi-mesh_log.h" +#include "wifi-mesh_private.h" +#include "wifi-mesh_dbus.h" /** - * Mesh network CAPI + * Wi-Fi Mesh network CAPI */ -EXPORT_API int mesh_network_new(mesh_network_h* network) +EXPORT_API int wifi_mesh_network_new(wifi_mesh_network_h* network) { struct mesh_network_s *net; @@ -35,7 +35,7 @@ EXPORT_API int mesh_network_new(mesh_network_h* network) if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } @@ -43,15 +43,15 @@ EXPORT_API int mesh_network_new(mesh_network_h* network) if (NULL == net) { /* LCOV_EXCL_START */ LOGE("Out of memory"); - return MESH_ERROR_OUT_OF_MEMORY; + return WIFI_MESH_ERROR_OUT_OF_MEMORY; /* LCOV_EXCL_STOP */ } - *network = (mesh_network_h)net; + *network = (wifi_mesh_network_h)net; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src) +EXPORT_API int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_network_h src) { struct mesh_network_s *net = NULL; struct mesh_network_s *_src = src; @@ -61,7 +61,7 @@ EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src) if (dst == NULL || src == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } @@ -69,7 +69,7 @@ EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src) if (NULL == net) { /* LCOV_EXCL_START */ LOGE("Out of memory"); - return MESH_ERROR_OUT_OF_MEMORY; + return WIFI_MESH_ERROR_OUT_OF_MEMORY; /* LCOV_EXCL_STOP */ } snprintf(net->meshid, MAX_MESHID_LEN, "%s", _src->meshid); @@ -81,13 +81,13 @@ EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src) if (strlen(_src->passphrase) > 0) snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", _src->passphrase); - *dst = (mesh_network_h)net; + *dst = (wifi_mesh_network_h)net; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_new_with(mesh_network_h* network, const char *meshid, - const char *bssid, int channel, int rssi, mesh_security_type_e security, +EXPORT_API int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const char *meshid, + const char *bssid, int channel, int rssi, wifi_mesh_security_type_e security, const char *passphrase) { struct mesh_network_s *net; @@ -97,7 +97,7 @@ EXPORT_API int mesh_network_new_with(mesh_network_h* network, const char *meshid if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } @@ -112,12 +112,12 @@ EXPORT_API int mesh_network_new_with(mesh_network_h* network, const char *meshid if (passphrase) snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", passphrase); - *network = (mesh_network_h)net; + *network = (wifi_mesh_network_h)net; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_destroy(mesh_network_h network) +EXPORT_API int wifi_mesh_network_destroy(wifi_mesh_network_h network) { struct mesh_network_s *net = network; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); @@ -125,16 +125,16 @@ EXPORT_API int mesh_network_destroy(mesh_network_h network) if (NULL == net) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } free(net); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_meshid(mesh_network_h network, char **meshid) +EXPORT_API int wifi_mesh_network_get_meshid(wifi_mesh_network_h network, char **meshid) { struct mesh_network_s *net = network; @@ -143,16 +143,16 @@ EXPORT_API int mesh_network_get_meshid(mesh_network_h network, char **meshid) if (network == NULL || meshid == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *meshid = strdup(net->meshid); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_meshid(mesh_network_h network, const char *meshid) +EXPORT_API int wifi_mesh_network_set_meshid(wifi_mesh_network_h network, const char *meshid) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -161,16 +161,16 @@ EXPORT_API int mesh_network_set_meshid(mesh_network_h network, const char *meshi if (network == NULL || meshid == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } snprintf(net->meshid, MAX_MESHID_LEN, "%s", meshid); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_bssid(mesh_network_h network, char **bssid) +EXPORT_API int wifi_mesh_network_get_bssid(wifi_mesh_network_h network, char **bssid) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -179,16 +179,16 @@ EXPORT_API int mesh_network_get_bssid(mesh_network_h network, char **bssid) if (network == NULL || bssid == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *bssid = strdup(net->bssid); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_bssid(mesh_network_h network, const char *bssid) +EXPORT_API int wifi_mesh_network_set_bssid(wifi_mesh_network_h network, const char *bssid) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -197,16 +197,16 @@ EXPORT_API int mesh_network_set_bssid(mesh_network_h network, const char *bssid) if (network == NULL || bssid == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } snprintf(net->bssid, MAX_BSSID_LEN, "%s", bssid); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_channel(mesh_network_h network, int *channel) +EXPORT_API int wifi_mesh_network_get_channel(wifi_mesh_network_h network, int *channel) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -215,16 +215,16 @@ EXPORT_API int mesh_network_get_channel(mesh_network_h network, int *channel) if (network == NULL || channel == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *channel = net->channel; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_channel(mesh_network_h network, int channel) +EXPORT_API int wifi_mesh_network_set_channel(wifi_mesh_network_h network, int channel) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -233,16 +233,16 @@ EXPORT_API int mesh_network_set_channel(mesh_network_h network, int channel) if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } net->channel = channel; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_rssi(mesh_network_h network, int *rssi) +EXPORT_API int wifi_mesh_network_get_rssi(wifi_mesh_network_h network, int *rssi) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -251,16 +251,16 @@ EXPORT_API int mesh_network_get_rssi(mesh_network_h network, int *rssi) if (network == NULL || rssi == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *rssi = net->rssi; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_rssi(mesh_network_h network, int rssi) +EXPORT_API int wifi_mesh_network_set_rssi(wifi_mesh_network_h network, int rssi) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -269,16 +269,16 @@ EXPORT_API int mesh_network_set_rssi(mesh_network_h network, int rssi) if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } net->rssi = rssi; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_security(mesh_network_h network, mesh_security_type_e *security) +EXPORT_API int wifi_mesh_network_get_security(wifi_mesh_network_h network, wifi_mesh_security_type_e *security) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -287,16 +287,16 @@ EXPORT_API int mesh_network_get_security(mesh_network_h network, mesh_security_t if (network == NULL || security == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *security = net->security; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_security(mesh_network_h network, mesh_security_type_e security) +EXPORT_API int wifi_mesh_network_set_security(wifi_mesh_network_h network, wifi_mesh_security_type_e security) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -305,16 +305,16 @@ EXPORT_API int mesh_network_set_security(mesh_network_h network, mesh_security_t if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } net->security = security; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_set_passphrase(mesh_network_h network, const char* passphrase) +EXPORT_API int wifi_mesh_network_set_passphrase(wifi_mesh_network_h network, const char* passphrase) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -323,7 +323,7 @@ EXPORT_API int mesh_network_set_passphrase(mesh_network_h network, const char* p if (network == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } @@ -332,11 +332,11 @@ EXPORT_API int mesh_network_set_passphrase(mesh_network_h network, const char* p else memset(net->passphrase, 0x0, MAX_PASSPHRASE_LEN); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_network_get_connection_state(mesh_network_h network, - mesh_connection_state_e *state) +EXPORT_API int wifi_mesh_network_get_connection_state(wifi_mesh_network_h network, + wifi_mesh_connection_state_e *state) { struct mesh_network_s *net = (struct mesh_network_s *)network; @@ -345,16 +345,16 @@ EXPORT_API int mesh_network_get_connection_state(mesh_network_h network, if (network == NULL || state == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *state = net->state; - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_peer_get_address(mesh_peer_h peer, char **address) +EXPORT_API int wifi_mesh_peer_get_address(wifi_mesh_peer_h peer, char **address) { struct mesh_peer_s *peer_info = (struct mesh_peer_s *)peer; @@ -363,16 +363,16 @@ EXPORT_API int mesh_peer_get_address(mesh_peer_h peer, char **address) if (peer == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } *address = strdup(peer_info->address); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_initialize(mesh_h *mesh) +EXPORT_API int wifi_mesh_initialize(wifi_mesh_h *mesh) { int rv; struct mesh_handle* handle; @@ -382,7 +382,7 @@ EXPORT_API int mesh_initialize(mesh_h *mesh) if (mesh == NULL) { /* LCOV_EXCL_START */ LOGE("Invalid parameter"); - return MESH_ERROR_INVALID_PARAMETER; + return WIFI_MESH_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_STOP */ } @@ -393,18 +393,18 @@ EXPORT_API int mesh_initialize(mesh_h *mesh) handle = g_new0(struct mesh_handle, 1); if (NULL == handle) { LOGE("Failed to create handle"); - return MESH_ERROR_OUT_OF_MEMORY; + return WIFI_MESH_ERROR_OUT_OF_MEMORY; } *mesh = handle; rv = _mesh_dbus_start(*mesh); - if (rv != MESH_ERROR_NONE) + if (rv != WIFI_MESH_ERROR_NONE) LOGD("D-Bus init: (0x%X)", rv); - return MESH_ERROR_NONE; + return WIFI_MESH_ERROR_NONE; } -EXPORT_API int mesh_deinitialize(mesh_h handle) +EXPORT_API int wifi_mesh_deinitialize(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); @@ -416,141 +416,141 @@ EXPORT_API int mesh_deinitialize(mesh_h handle) return rv; } -EXPORT_API int mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler) +EXPORT_API int wifi_mesh_set_event_cb(wifi_mesh_h handle, wifi_mesh_event_cb event_handler) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_set_event_cb(handle, event_handler); + rv = _wifi_mesh_set_event_cb(handle, event_handler); return rv; } -EXPORT_API int mesh_enable(mesh_h handle) +EXPORT_API int wifi_mesh_enable(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_enable(handle); + rv = _wifi_mesh_enable(handle); return rv; } -EXPORT_API int mesh_disable(mesh_h handle) +EXPORT_API int wifi_mesh_disable(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_disable(handle); + rv = _wifi_mesh_disable(handle); return rv; } -EXPORT_API int mesh_scan(mesh_h handle) +EXPORT_API int wifi_mesh_scan(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_scan(handle); + rv = _wifi_mesh_scan(handle); return rv; } -EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel) +EXPORT_API int wifi_mesh_specific_scan(wifi_mesh_h handle, const char* ssid, int channel) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == ssid, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ssid, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_specific_scan(handle, ssid, channel); + rv = _wifi_mesh_specific_scan(handle, ssid, channel); return rv; } -EXPORT_API int mesh_foreach_found_mesh_network(mesh_h handle, - mesh_found_mesh_network_cb cb, void *user_data) +EXPORT_API int wifi_mesh_foreach_found_network(wifi_mesh_h handle, + wifi_mesh_found_network_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); + RETV_IF(NULL == cb, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_get_scan_result(handle); - if (MESH_ERROR_NONE != rv) + rv = _wifi_mesh_get_scan_result(handle); + if (WIFI_MESH_ERROR_NONE != rv) return rv; rv = _mesh_foreach_found_mesh_network(handle, cb, user_data); return rv; } -EXPORT_API int mesh_foreach_connected_peers(mesh_h handle, - mesh_connected_peer_cb cb, void *user_data) +EXPORT_API int wifi_mesh_foreach_connected_peers(wifi_mesh_h handle, + wifi_mesh_connected_peer_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); + RETV_IF(NULL == cb, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_find_peers(handle); - if (MESH_ERROR_NONE != rv) + rv = _wifi_mesh_find_peers(handle); + if (WIFI_MESH_ERROR_NONE != rv) return rv; - rv = _mesh_foreach_connected_peers(handle, cb, user_data); + rv = _wifi_mesh_foreach_connected_peers(handle, cb, user_data); return rv; } -EXPORT_API int mesh_enable_mesh(mesh_h handle) +EXPORT_API int wifi_mesh_start_mesh(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_enable_mesh(handle); + rv = _wifi_mesh_enable_mesh(handle); return rv; } -EXPORT_API int mesh_disable_mesh(mesh_h handle) +EXPORT_API int wifi_mesh_stop_mesh(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_disable_mesh(handle); + rv = _wifi_mesh_disable_mesh(handle); return rv; } -EXPORT_API int mesh_is_joined(mesh_h handle, bool* is_joined) +EXPORT_API int wifi_mesh_is_joined(wifi_mesh_h handle, bool* is_joined) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_is_joined(handle, is_joined); + rv = _wifi_mesh_is_joined(handle, is_joined); return rv; } -EXPORT_API int mesh_get_joined_network(mesh_h handle, mesh_network_h *network) +EXPORT_API int wifi_mesh_get_joined_network(wifi_mesh_h handle, wifi_mesh_network_h *network) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); rv = _mesh_get_joined_mesh_network(handle, network); return rv; } -EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid, +EXPORT_API int wifi_mesh_set_softap(wifi_mesh_h handle, const char* ssid, const char* key, int channel, bool visibility, int max_stations, int security) { @@ -558,85 +558,85 @@ EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid, char buf[32] = {0,}; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == ssid, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == key, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ssid, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == key, WIFI_MESH_ERROR_INVALID_PARAMETER); if (channel <= 13) memcpy(buf, "g", strlen("g")); else memcpy(buf, "a", strlen("a")); - rv = _mesh_set_softap(handle, ssid, key, buf, channel, + rv = _wifi_mesh_set_softap(handle, ssid, key, buf, channel, visibility, max_stations, security); return rv; } -EXPORT_API int mesh_enable_softap(mesh_h handle) +EXPORT_API int wifi_mesh_enable_softap(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_enable_softap(handle); + rv = _wifi_mesh_enable_softap(handle); return rv; } -EXPORT_API int mesh_disable_softap(mesh_h handle) +EXPORT_API int wifi_mesh_disable_softap(wifi_mesh_h handle) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); - rv = _mesh_disable_softap(handle); + rv = _wifi_mesh_disable_softap(handle); return rv; } -EXPORT_API int mesh_create_mesh_network(mesh_h handle, mesh_network_h network) +EXPORT_API int wifi_mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h network) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == network, WIFI_MESH_ERROR_INVALID_PARAMETER); rv = _mesh_create_network(handle, network); return rv; } -EXPORT_API int mesh_connect_mesh_network(mesh_h handle, mesh_network_h network) +EXPORT_API int wifi_mesh_connect_network(wifi_mesh_h handle, wifi_mesh_network_h network) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == network, WIFI_MESH_ERROR_INVALID_PARAMETER); rv = _mesh_connect_network(handle, network); return rv; } -EXPORT_API int mesh_disconnect_mesh_network(mesh_h handle, mesh_network_h network) +EXPORT_API int wifi_mesh_disconnect_network(wifi_mesh_h handle, wifi_mesh_network_h network) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == network, WIFI_MESH_ERROR_INVALID_PARAMETER); rv = _mesh_disconnect_network(handle, network); return rv; } -EXPORT_API int mesh_forget_mesh_network(mesh_h handle, mesh_network_h network) +EXPORT_API int wifi_mesh_forget_network(wifi_mesh_h handle, wifi_mesh_network_h network) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); - RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle, WIFI_MESH_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == network, WIFI_MESH_ERROR_INVALID_PARAMETER); rv = _mesh_forget_network(handle, network); return rv; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a191bd..d804958 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(test "mesh_test") +SET(test "wifi-mesh-test") INCLUDE(FindPkgConfig) pkg_check_modules(${test} REQUIRED dlog glib-2.0 gio-2.0) @@ -17,11 +17,11 @@ SET(CMAKE_EXE_LINKER_FLAGS "-lpthread") SET(NEW_SOURCES main.c menu.c - mesh_device.c - mesh_network.c + wifi-mesh-device.c + wifi-mesh-network.c ) -# mesh test tool -ADD_EXECUTABLE(mesh_test ${NEW_SOURCES}) -TARGET_LINK_LIBRARIES(mesh_test ${${fw_name}_LDFLAGS} ${pkgs_LDFLAGS} capi-network-mesh) -INSTALL(TARGETS mesh_test DESTINATION ${BIN_INSTALL_DIR}) +# Wi-Fi mesh test tool +ADD_EXECUTABLE(${test} ${NEW_SOURCES}) +TARGET_LINK_LIBRARIES(${test} ${${fw_name}_LDFLAGS} ${pkgs_LDFLAGS} capi-network-wifi-mesh) +INSTALL(TARGETS ${test} DESTINATION ${BIN_INSTALL_DIR}) diff --git a/test/common.h b/test/common.h index e6ff888..d421e09 100644 --- a/test/common.h +++ b/test/common.h @@ -18,15 +18,15 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include <mesh.h> -#include <mesh-internal.h> +#include <wifi-mesh.h> +#include <wifi-mesh-internal.h> __BEGIN_DECLS #define CASE_TO_STR(x) case x: return #x; -const char* mesh_error_to_string(mesh_error_e err); -const char* _mesh_connection_event_to_string(mesh_connection_state_e e); +const char* wifi_mesh_error_to_string(wifi_mesh_error_e err); +const char* wifi_mesh_connection_event_to_string(wifi_mesh_connection_state_e e); __END_DECLS diff --git a/test/main.c b/test/main.c index d7be69c..1aa3c46 100644 --- a/test/main.c +++ b/test/main.c @@ -29,7 +29,7 @@ #include "menu.h" #include "common.h" -mesh_h mesh = NULL; +wifi_mesh_h mesh = NULL; extern struct menu_data menu_mesh_device[]; extern struct menu_data menu_mesh_network[]; @@ -37,79 +37,80 @@ extern struct menu_data menu_mesh_network[]; /* Scanned Mesh Network */ extern GList *g_found_network_list; -const char* mesh_error_to_string(mesh_error_e err) +const char* wifi_mesh_error_to_string(wifi_mesh_error_e err) { switch (err) { /* CHECK: List all enum values here */ - CASE_TO_STR(MESH_ERROR_NONE) - CASE_TO_STR(MESH_ERROR_INVALID_PARAMETER) - CASE_TO_STR(MESH_ERROR_OUT_OF_MEMORY) - CASE_TO_STR(MESH_ERROR_NO_DATA) - CASE_TO_STR(MESH_ERROR_INVALID_OPERATION) - CASE_TO_STR(MESH_ERROR_ALREADY_IN_PROGRESS) - CASE_TO_STR(MESH_ERROR_NOW_IN_PROGRESS) - CASE_TO_STR(MESH_ERROR_PERMISSION_DENIED) - CASE_TO_STR(MESH_ERROR_IO_ERROR) - CASE_TO_STR(MESH_ERROR_NOT_SUPPORTED) - CASE_TO_STR(MESH_ERROR_OPERATION_FAILED) - CASE_TO_STR(MESH_ERROR_OPERATION_ABORTED) + CASE_TO_STR(WIFI_MESH_ERROR_NONE) + CASE_TO_STR(WIFI_MESH_ERROR_INVALID_PARAMETER) + CASE_TO_STR(WIFI_MESH_ERROR_OUT_OF_MEMORY) + CASE_TO_STR(WIFI_MESH_ERROR_NO_DATA) + CASE_TO_STR(WIFI_MESH_ERROR_INVALID_OPERATION) + CASE_TO_STR(WIFI_MESH_ERROR_ALREADY_IN_PROGRESS) + CASE_TO_STR(WIFI_MESH_ERROR_NOW_IN_PROGRESS) + CASE_TO_STR(WIFI_MESH_ERROR_PERMISSION_DENIED) + CASE_TO_STR(WIFI_MESH_ERROR_IO_ERROR) + CASE_TO_STR(WIFI_MESH_ERROR_NOT_SUPPORTED) + CASE_TO_STR(WIFI_MESH_ERROR_OPERATION_FAILED) + CASE_TO_STR(WIFI_MESH_ERROR_OPERATION_ABORTED) + CASE_TO_STR(WIFI_MESH_ERROR_ALREADY_INITIALIZED) default : return "Unknown Error"; } } -static const char* _mesh_event_to_string(mesh_event_e e) +static const char* _wifi_mesh_event_to_string(wifi_mesh_event_e e) { switch (e) { /* CHECK: List all enum values here */ - CASE_TO_STR(MESH_EVENT_ENABLED) - CASE_TO_STR(MESH_EVENT_SCAN_DONE) - CASE_TO_STR(MESH_EVENT_CONNECTION_STATE) - CASE_TO_STR(MESH_EVENT_STATION_JOIN) - CASE_TO_STR(MESH_EVENT_STATION_LEFT) + CASE_TO_STR(WIFI_MESH_EVENT_ENABLED) + CASE_TO_STR(WIFI_MESH_EVENT_SCAN_DONE) + CASE_TO_STR(WIFI_MESH_EVENT_CONNECTION_STATE) + CASE_TO_STR(WIFI_MESH_EVENT_STATION_JOIN) + CASE_TO_STR(WIFI_MESH_EVENT_STATION_LEFT) default : return "MESH_EVENT_UNKNOWN"; } } -const char* _mesh_connection_event_to_string(mesh_connection_state_e e) +const char* wifi_mesh_connection_event_to_string(wifi_mesh_connection_state_e e) { switch (e) { /* CHECK: List all enum values here */ - CASE_TO_STR(MESH_CONNECTION_STATE_DISCONNECTED) - CASE_TO_STR(MESH_CONNECTION_STATE_ASSOCIATION) - CASE_TO_STR(MESH_CONNECTION_STATE_CONFIGURATION) - CASE_TO_STR(MESH_CONNECTION_STATE_CONNECTED) + CASE_TO_STR(WIFI_MESH_CONNECTION_STATE_DISCONNECTED) + CASE_TO_STR(WIFI_MESH_CONNECTION_STATE_ASSOCIATION) + CASE_TO_STR(WIFI_MESH_CONNECTION_STATE_CONFIGURATION) + CASE_TO_STR(WIFI_MESH_CONNECTION_STATE_CONNECTED) default : return "Unknown state"; } } -void event_cb(mesh_event_e event_type, mesh_event_data_s* event) +void event_cb(wifi_mesh_event_e event_type, wifi_mesh_event_data_s* event) { msg(""); - msgp("Event received [%s]", _mesh_event_to_string(event_type)); + msgp("Event received [%s]", _wifi_mesh_event_to_string(event_type)); switch (event_type) { - case MESH_EVENT_ENABLED: { - msgp(" Mesh Network Enabled Result = %d", event->data.mesh_enable->result); + case WIFI_MESH_EVENT_ENABLED: { + msgp(" Mesh Network Enabled Result = %d", event->data.wifi_mesh_enable->result); } break; - case MESH_EVENT_SCAN_DONE: { + case WIFI_MESH_EVENT_SCAN_DONE: { msgp(" Mesh Scan Done"); } break; - case MESH_EVENT_CONNECTION_STATE:{ + case WIFI_MESH_EVENT_CONNECTION_STATE:{ msgp(" Connection state changed [%s]", - _mesh_connection_event_to_string(event->data.connection_state->state)); + wifi_mesh_connection_event_to_string(event->data.connection_state->state)); msgp(" From Mesh ID[%-10s] BSSID[%s] Channel[%d] Security[%4s]", event->data.connection_state->mesh_id, event->data.connection_state->bssid, event->data.connection_state->channel, (MESH_SECURITY_SAE == event->data.connection_state->security) ? "SAE" : "NONE"); } break; - case MESH_EVENT_STATION_JOIN: { + case WIFI_MESH_EVENT_STATION_JOIN: { msgp(" New Station Joined = %s", event->data.sta_info->bssid); } break; - case MESH_EVENT_STATION_LEFT: { + case WIFI_MESH_EVENT_STATION_LEFT: { msgp(" A Station Left = %s", event->data.sta_info->bssid); } break; default: @@ -123,10 +124,10 @@ static int __init_func(MManager *mm, struct menu_data *menu) #if 0 int ret = -1; - ret = mesh_initialize(&mesh); + ret = wifi_mesh_initialize(&mesh); if (ret != 0) { msg("Failed to initialize mesh: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } #endif @@ -135,7 +136,7 @@ static int __init_func(MManager *mm, struct menu_data *menu) static struct menu_data menu_main[] = { { "1", "Device", menu_mesh_device, NULL, NULL }, - { "2", "Mesh network", menu_mesh_network, NULL, NULL }, + { "2", "Wi-Fi Mesh network", menu_mesh_network, NULL, NULL }, { NULL, NULL, }, }; @@ -163,7 +164,7 @@ int main(int arg, char **argv) mainloop = g_main_loop_new(NULL, FALSE); msg(""); - msg("* Mesh Test application "); + msg("* Wi-Fi Mesh Test application "); msg("* Build On: %s %s", __DATE__, __TIME__); if (__create_init_menu(init_menu) == FALSE) @@ -184,7 +185,7 @@ OUT: g_list_free(g_found_network_list); if (mesh) - mesh_deinitialize(mesh); + wifi_mesh_deinitialize(mesh); g_main_loop_unref(mainloop); msg("******* Bye bye *******"); diff --git a/test/mesh_device.c b/test/wifi-mesh-device.c index 57a85ad..c5f4d44 100644 --- a/test/mesh_device.c +++ b/test/wifi-mesh-device.c @@ -27,21 +27,21 @@ #include "menu.h" #include "common.h" -extern mesh_h mesh; -extern void event_cb(mesh_event_e event_type, mesh_event_data_s* event); +extern wifi_mesh_h mesh; +extern void event_cb(wifi_mesh_event_e event_type, wifi_mesh_event_data_s* event); static int run_mesh_create(MManager *mm, struct menu_data *menu) { int ret; msg("create"); - ret = mesh_initialize(&mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_initialize(&mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to initialize mesh: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_initialize() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_initialize() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -51,53 +51,53 @@ static int run_mesh_destroy(MManager *mm, struct menu_data *menu) int ret; msg("destroy"); - ret = mesh_deinitialize(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_deinitialize(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to de-initialize mesh: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_deinitialize() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_deinitialize() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_enable(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_enable(MManager *mm, struct menu_data *menu) { int ret; msg("enable"); - ret = mesh_set_event_cb(mesh, event_cb); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_set_event_cb(mesh, event_cb); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to set callback for mesh network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_set_event_cb() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_set_event_cb() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); - ret = mesh_enable(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_enable(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to enable mesh network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_enable() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_enable() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_disable(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_disable(MManager *mm, struct menu_data *menu) { int ret; msg("disable"); - ret = mesh_disable(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_disable(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to disable mesh network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_disable() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_disable() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -105,18 +105,18 @@ static int run_mesh_disable(MManager *mm, struct menu_data *menu) static char mesh_interface[MENU_DATA_SIZE + 1] = "mesh0"; static char gate_interface[MENU_DATA_SIZE + 1] = "eth0"; static char softap_interface[MENU_DATA_SIZE + 1] = "wlan1"; -static int run_mesh_set_interfaces(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_set_interfaces(MManager *mm, struct menu_data *menu) { int ret; msg("set_interfaces"); - ret = mesh_set_interfaces(mesh, mesh_interface, gate_interface, softap_interface); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_set_interfaces(mesh, mesh_interface, gate_interface, softap_interface); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to set interfaces: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_set_interfaces() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_set_interfaces() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -125,15 +125,15 @@ static struct menu_data menu_mesh_interface[] = { { "1", "mesh", NULL, NULL, mesh_interface }, { "2", "gate", NULL, NULL, gate_interface }, { "3", "softap", NULL, NULL, softap_interface }, - { "4", "run", NULL, run_mesh_set_interfaces, NULL }, + { "4", "run", NULL, run_wifi_mesh_set_interfaces, NULL }, { NULL, NULL, }, }; struct menu_data menu_mesh_device[] = { { "1", "initialize", NULL, run_mesh_create, NULL }, { "2", "deinitialize", NULL, run_mesh_destroy, NULL }, - { "3", "enable", NULL, run_mesh_enable, NULL }, - { "4", "disable", NULL, run_mesh_disable, NULL }, + { "3", "enable", NULL, run_wifi_mesh_enable, NULL }, + { "4", "disable", NULL, run_wifi_mesh_disable, NULL }, { "5", "set_inteface", menu_mesh_interface, NULL, NULL}, { NULL, NULL, }, }; diff --git a/test/mesh_network.c b/test/wifi-mesh-network.c index 6642624..77b05d5 100644 --- a/test/mesh_network.c +++ b/test/wifi-mesh-network.c @@ -27,7 +27,7 @@ #include "menu.h" #include "common.h" -extern mesh_h mesh; +extern wifi_mesh_h mesh; static char gate_announce[MENU_DATA_SIZE + 1] = "1"; static char hwmp_root_mode[MENU_DATA_SIZE + 1] = "4"; @@ -52,31 +52,31 @@ static char network_idx[MENU_DATA_SIZE + 1] = "1"; static int g_scan_net_idx = 0; GList *g_found_network_list = NULL; -static void found_mesh_network_cb(mesh_network_h network, void* user_data) +static void found_mesh_network_cb(wifi_mesh_network_h network, void* user_data) { int ret; - mesh_network_h net = NULL; + wifi_mesh_network_h net = NULL; char *meshid = NULL; char *bssid = NULL; int rssi; int data_rate; - mesh_security_type_e security; + wifi_mesh_security_type_e security; int channel; - ret = mesh_network_clone(&net, network); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to clone found network: [%s(0x%X)]", mesh_error_to_string(ret), ret); + ret = wifi_mesh_network_clone(&net, network); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to clone found network: [%s(0x%X)]", wifi_mesh_error_to_string(ret), ret); return; } g_found_network_list = g_list_append(g_found_network_list, net); - mesh_network_get_meshid(net, &meshid); - mesh_network_get_bssid(net, &bssid); - mesh_network_get_channel(net, &channel); - mesh_network_get_rssi(net, &rssi); - mesh_network_get_data_rate(net, &data_rate); - mesh_network_get_security(net, &security); + wifi_mesh_network_get_meshid(net, &meshid); + wifi_mesh_network_get_bssid(net, &bssid); + wifi_mesh_network_get_channel(net, &channel); + wifi_mesh_network_get_rssi(net, &rssi); + wifi_mesh_network_get_data_rate(net, &data_rate); + wifi_mesh_network_get_security(net, &security); msgb(" [%02d] Mesh ID[%-10s] BSSID[%s] Channel[%d] RSSI[%ddBm] Date Rate[%dMbps] Security[%4s]", g_scan_net_idx, meshid, bssid, channel, rssi == 0 ? 0 : rssi-120, data_rate, (MESH_SECURITY_SAE == security) ? "SAE" : "NONE"); @@ -87,11 +87,11 @@ static void found_mesh_network_cb(mesh_network_h network, void* user_data) if (bssid) free(bssid); } -static void connected_peer_cb(mesh_peer_h peer, void* user_data) +static void connected_peer_cb(wifi_mesh_peer_h peer, void* user_data) { char *address = NULL; - mesh_peer_get_address(peer, &address); + wifi_mesh_peer_get_address(peer, &address); msgb(" Peer Address [%s]", address); if (address) @@ -114,7 +114,7 @@ static int run_show_found_network(MManager *mm, struct menu_data *menu) int i = 1; /* Displays from 1 */ char *_meshid = NULL; int _channel = 1; - mesh_security_type_e _security = MESH_SECURITY_NONE; + wifi_mesh_security_type_e _security = MESH_SECURITY_NONE; GList *iter = NULL; @@ -126,10 +126,10 @@ static int run_show_found_network(MManager *mm, struct menu_data *menu) msg("Scan Results : "); iter = g_found_network_list; while (iter != NULL) { - mesh_network_h _net = iter->data; - mesh_network_get_meshid(_net, &_meshid); - mesh_network_get_channel(_net, &_channel); - mesh_network_get_security(_net, &_security); + wifi_mesh_network_h _net = iter->data; + wifi_mesh_network_get_meshid(_net, &_meshid); + wifi_mesh_network_get_channel(_net, &_channel); + wifi_mesh_network_get_security(_net, &_security); msgb(" [%02d] Mesh ID[%-10s] Channel[%d] Security[%4s]", i++, _meshid, _channel, (MESH_SECURITY_SAE == _security) ? "SAE" : "NONE"); @@ -142,17 +142,17 @@ static int run_show_found_network(MManager *mm, struct menu_data *menu) } #endif -static int run_mesh_scan(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_scan(MManager *mm, struct menu_data *menu) { int ret; msg("Scan"); - ret = mesh_scan(mesh); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to scan: [%s(0x%X)]", mesh_error_to_string(ret), ret); + ret = wifi_mesh_scan(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to scan: [%s(0x%X)]", wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_scan() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -165,23 +165,23 @@ static int run_get_found_mesh_network(MManager *mm, struct menu_data *menu) /* Clear previous found network list */ g_scan_net_idx = 1; if (g_found_network_list) - g_list_free_full(g_found_network_list, (void *)mesh_network_destroy); + g_list_free_full(g_found_network_list, (void *)wifi_mesh_network_destroy); g_found_network_list = NULL; - ret = mesh_foreach_found_mesh_network(mesh, found_mesh_network_cb, NULL); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_foreach_found_mesh_network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_foreach_found_network(mesh, found_mesh_network_cb, NULL); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_foreach_found_network: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_foreach_found_mesh_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_foreach_found_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_specific_scan(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_specific_scan(MManager *mm, struct menu_data *menu) { int ret; int channel = 1; @@ -191,59 +191,59 @@ static int run_mesh_specific_scan(MManager *mm, struct menu_data *menu) if (strlen(mesh_channel)) channel = (unsigned short)strtol(mesh_channel, NULL, 10); - ret = mesh_specific_scan(mesh, meshid, channel); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_specific_scan(mesh, meshid, channel); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to specific scan: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_specific_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_specific_scan() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_cancel_scan(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_cancel_scan(MManager *mm, struct menu_data *menu) { int ret; msg("Cancel Scan"); - ret = mesh_cancel_scan(mesh); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to cancel scan: [%s(0x%X)]", mesh_error_to_string(ret), ret); + ret = wifi_mesh_cancel_scan(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to cancel scan: [%s(0x%X)]", wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_cancel_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_cancel_scan() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_enable(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_enable(MManager *mm, struct menu_data *menu) { int ret; msg("Enable Mesh"); - ret = mesh_enable_mesh(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_start_mesh(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to enable mesh network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_enable_mesh() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_start_mesh() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } -static int run_mesh_disable(MManager *mm, struct menu_data *menu) +static int run_wifi_mesh_disable(MManager *mm, struct menu_data *menu) { int ret; msg("Disable Mesh"); - ret = mesh_disable_mesh(mesh); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to disable mesh network: [%s(0x%X)]", mesh_error_to_string(ret), ret); + ret = wifi_mesh_stop_mesh(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to disable mesh network: [%s(0x%X)]", wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_disable_mesh() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_stop_mesh() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -255,45 +255,45 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu) char *_bssid = NULL; int _channel = -1; bool joined = false; - mesh_connection_state_e _state = MESH_CONNECTION_STATE_DISCONNECTED; - mesh_security_type_e _security = MESH_SECURITY_NONE; - mesh_network_h network = NULL; + wifi_mesh_connection_state_e _state = WIFI_MESH_CONNECTION_STATE_DISCONNECTED; + wifi_mesh_security_type_e _security = MESH_SECURITY_NONE; + wifi_mesh_network_h network = NULL; msg("Get Joined Mesh Network Information"); - ret = mesh_is_joined(mesh, &joined); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_is_joined(mesh, &joined); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to check network join status: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - ret = mesh_get_joined_network(mesh, &network); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_get_joined_network(mesh, &network); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to get joined mesh network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } if (NULL != network) { - mesh_network_get_meshid(network, &_meshid); + wifi_mesh_network_get_meshid(network, &_meshid); msgb(" Mesh ID = %s", _meshid); - mesh_network_get_bssid(network, &_bssid); + wifi_mesh_network_get_bssid(network, &_bssid); msgb(" BSSID = %s", _bssid); - mesh_network_get_channel(network, &_channel); + wifi_mesh_network_get_channel(network, &_channel); msgb(" Channel = %d", _channel); - mesh_network_get_security(network, &_security); + wifi_mesh_network_get_security(network, &_security); msgb(" Security = %s", (MESH_SECURITY_SAE == _security) ? "SAE" : "NONE"); - mesh_network_get_connection_state(network, &_state); - msgb(" State = %s", _mesh_connection_event_to_string(_state)); + wifi_mesh_network_get_connection_state(network, &_state); + msgb(" State = %s", wifi_mesh_connection_event_to_string(_state)); if (_meshid) free(_meshid); if (_bssid) free(_bssid); } msg(""); - msg(" - mesh_get_joined_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_get_joined_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -303,14 +303,14 @@ static int run_get_connected_peers(MManager *mm, struct menu_data *menu) int ret; msg("Get Connected Mesh Peers"); - ret = mesh_foreach_connected_peers(mesh, connected_peer_cb, NULL); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_foreach_connected_peers: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_foreach_connected_peers(mesh, connected_peer_cb, NULL); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_foreach_connected_peers: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_foreach_connected_peers() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_foreach_connected_peers() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -331,13 +331,13 @@ static int run_set_gate(MManager *mm, struct menu_data *menu) if (strlen(stp)) _stp = (unsigned short)strtol(stp, NULL, 10); - ret = mesh_set_gate(mesh, _gate_announce, _hwmp_root_mode, _stp); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_set_gate(mesh, _gate_announce, _hwmp_root_mode, _stp); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to set gate options: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_set_gate() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_set_gate() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -347,13 +347,13 @@ static int run_unset_gate(MManager *mm, struct menu_data *menu) int ret; msg("Disable All Gate Option"); - ret = mesh_unset_gate(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_unset_gate(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to unset gate option: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_unset_gate() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_unset_gate() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -378,14 +378,14 @@ static int run_set_softap(MManager *mm, struct menu_data *menu) if (strlen(security)) _security = (unsigned short)strtol(security, NULL, 10); - ret = mesh_set_softap(mesh, ssid, passphrase, + ret = wifi_mesh_set_softap(mesh, ssid, passphrase, _channel, _visibility, _max_stations, _security); - if (MESH_ERROR_NONE != ret) { + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to set softap options: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_set_softap() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_set_softap() ret: [0x%X] [%s]", ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -395,14 +395,14 @@ static int run_enable_softap(MManager *mm, struct menu_data *menu) int ret; msg("Enable SoftAp"); - ret = mesh_enable_softap(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_enable_softap(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to enable soft ap: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_enable_softap() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_enable_softap() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -412,14 +412,14 @@ static int run_disable_softap(MManager *mm, struct menu_data *menu) int ret; msg("Disable SoftAp"); - ret = mesh_disable_softap(mesh); - if (MESH_ERROR_NONE != ret) { + ret = wifi_mesh_disable_softap(mesh); + if (WIFI_MESH_ERROR_NONE != ret) { msgr("Failed to disable soft ap: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_disable_softap() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_disable_softap() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -428,8 +428,8 @@ static int run_create_network(MManager *mm, struct menu_data *menu) { int ret; int _mesh_channel = 1; - mesh_security_type_e security = MESH_SECURITY_NONE; - mesh_network_h net = NULL; + wifi_mesh_security_type_e security = MESH_SECURITY_NONE; + wifi_mesh_network_h net = NULL; msg("Create a new Mesh Network"); @@ -441,17 +441,17 @@ static int run_create_network(MManager *mm, struct menu_data *menu) security = ((1 == ret) ? MESH_SECURITY_SAE : MESH_SECURITY_NONE); } - mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, + wifi_mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, security, security == MESH_SECURITY_SAE ? mesh_passphrase : NULL); - ret = mesh_create_mesh_network(mesh, net); - mesh_network_destroy(net); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_create_mesh_network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_create_network(mesh, net); + wifi_mesh_network_destroy(net); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_create_network: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_create_mesh_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_create_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -460,8 +460,8 @@ static int run_connect_network(MManager *mm, struct menu_data *menu) { int ret; int idx = 1; - mesh_network_h net = NULL; - mesh_security_type_e security = MESH_SECURITY_NONE; + wifi_mesh_network_h net = NULL; + wifi_mesh_security_type_e security = MESH_SECURITY_NONE; msg("Connect to Mesh Network"); if (strlen(network_idx)) { @@ -481,11 +481,11 @@ static int run_connect_network(MManager *mm, struct menu_data *menu) } /* Set passphrase */ - mesh_network_get_security(net, &security); + wifi_mesh_network_get_security(net, &security); if (MESH_SECURITY_NONE != security) { if (strlen(mesh_passphrase)) { - ret = mesh_network_set_passphrase(net, mesh_passphrase); - if (MESH_ERROR_NONE != ret) + ret = wifi_mesh_network_set_passphrase(net, mesh_passphrase); + if (WIFI_MESH_ERROR_NONE != ret) msgr("Failed to set passphrase !"); } else { msgr("If security enabled, passphrase should be set !"); @@ -493,14 +493,14 @@ static int run_connect_network(MManager *mm, struct menu_data *menu) } } - ret = mesh_connect_mesh_network(mesh, net); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_connect_mesh_network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_connect_network(mesh, net); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_connect_network: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_connect_mesh_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_connect_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -509,7 +509,7 @@ static int run_disconnect_network(MManager *mm, struct menu_data *menu) { int ret; int idx = 1; - mesh_network_h net = NULL; + wifi_mesh_network_h net = NULL; msg("Disconnect with Mesh Network"); if (strlen(network_idx)) { @@ -528,14 +528,14 @@ static int run_disconnect_network(MManager *mm, struct menu_data *menu) } } - ret = mesh_disconnect_mesh_network(mesh, net); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_disconnect_mesh_network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_disconnect_network(mesh, net); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_disconnect_network: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_disconnect_mesh_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_disconnect_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -544,7 +544,7 @@ static int run_forget_network(MManager *mm, struct menu_data *menu) { int ret; int idx = 1; - mesh_network_h net = NULL; + wifi_mesh_network_h net = NULL; msg("Forget Mesh Network"); if (strlen(network_idx)) { @@ -563,14 +563,14 @@ static int run_forget_network(MManager *mm, struct menu_data *menu) } } - ret = mesh_forget_mesh_network(mesh, net); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_forget_mesh_network: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_forget_network(mesh, net); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_forget_network: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_forget_mesh_network() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_forget_network() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -580,14 +580,14 @@ static int run_get_station_information(MManager *mm, struct menu_data *menu) int ret; msg("Get Mesh Station Information"); - ret = mesh_get_stations_info(mesh, found_station_cb, NULL); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_get_stations_info: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_get_stations_info(mesh, found_station_cb, NULL); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_get_stations_info: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_get_stations_info() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_get_stations_info() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } @@ -597,21 +597,21 @@ static int run_get_mpath_information(MManager *mm, struct menu_data *menu) int ret; msg("Get Mesh Path Information"); - ret = mesh_get_mpath_info(mesh, found_mpath_cb, NULL); - if (MESH_ERROR_NONE != ret) { - msgr("Failed to mesh_get_mpath_info: [%s(0x%X)]", - mesh_error_to_string(ret), ret); + ret = wifi_mesh_get_mpath_info(mesh, found_mpath_cb, NULL); + if (WIFI_MESH_ERROR_NONE != ret) { + msgr("Failed to wifi_mesh_get_mpath_info: [%s(0x%X)]", + wifi_mesh_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - mesh_get_mpath_info() ret: [0x%X] [%s]", - ret, mesh_error_to_string(ret)); + msg(" - wifi_mesh_get_mpath_info() ret: [0x%X] [%s]", + ret, wifi_mesh_error_to_string(ret)); return RET_SUCCESS; } static struct menu_data menu_specific_scan[] = { { "1", "Mesh ID", NULL, NULL, meshid }, { "2", "Channel", NULL, NULL, mesh_channel }, - { "3", "Run", NULL, run_mesh_specific_scan, NULL }, + { "3", "Run", NULL, run_wifi_mesh_specific_scan, NULL }, { NULL, NULL, }, }; @@ -668,12 +668,12 @@ static struct menu_data menu_forget_network[] = { struct menu_data menu_mesh_network[] = { - { "1", "Scan", NULL, run_mesh_scan, NULL }, + { "1", "Scan", NULL, run_wifi_mesh_scan, NULL }, { "2", "Get found mesh network", NULL, run_get_found_mesh_network, NULL }, { "3", "Specific scan", menu_specific_scan, NULL, NULL }, - { "4", "Cancel scan", NULL, run_mesh_cancel_scan, NULL }, - { "5", "Enable mesh", NULL, run_mesh_enable, NULL }, - { "6", "Disable mesh", NULL, run_mesh_disable, NULL }, + { "4", "Cancel scan", NULL, run_wifi_mesh_cancel_scan, NULL }, + { "5", "Enable mesh", NULL, run_wifi_mesh_enable, NULL }, + { "6", "Disable mesh", NULL, run_wifi_mesh_disable, NULL }, { "7", "Get joined mesh network", NULL, run_get_joined_mesh_network, NULL }, { "8", "Set gate", menu_gate_option, NULL, NULL }, { "9", "Unset gate", NULL, run_unset_gate, NULL }, |