- Add 'service_error_e' to get error code from service.
- Print message to notify the return state of API.
DIRECTORY ${INC_DIR}/ DESTINATION include/network
FILES_MATCHING
PATTERN "mesh_*.h" EXCLUDE
+ PATTERN "service_*.h" EXCLUDE
PATTERN "${INC_DIR}/*.h"
)
* @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_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_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
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_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_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_e;
/**
--- /dev/null
+/*
+ * Copyright (c) 2017 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_SERVICE_ERROR_H__
+#define __MESH_SERVICE_ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ SERVICE_ERROR_NONE = 0, /**< Successful */
+ SERVICE_ERROR_IO_ERROR, /**< I/O error */
+ SERVICE_ERROR_NO_DATA, /**< Data not exists */
+ SERVICE_ERROR_OUT_OF_MEMORY, /**< out of memory */
+ SERVICE_ERROR_OPERATION_FAILED, /**< operation failed */
+ SERVICE_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ SERVICE_ERROR_ALREADY_REGISTERED, /**< Request already registered */
+ SERVICE_ERROR_IN_PROGRESS /**< operation is in progress */
+} service_error_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __MESH_SERVICE_ERROR_H__ */
#include "mesh_log.h"
#include "mesh_dbus.h"
#include "mesh_private.h"
+#include "service_error.h"
static GDBusProxy *_gproxy_mesh_service = NULL;
static int _mesh_close_gdbus_call(mesh_h m);
+static mesh_error_e __convert_service_error_type(service_error_e err_type)
+{
+ switch (err_type) {
+ case SERVICE_ERROR_NONE:
+ return MESH_ERROR_NONE;
+ case SERVICE_ERROR_IO_ERROR:
+ return MESH_ERROR_IO_ERROR;
+ case SERVICE_ERROR_NO_DATA:
+ return MESH_ERROR_NO_DATA;
+ case SERVICE_ERROR_OUT_OF_MEMORY:
+ return MESH_ERROR_OUT_OF_MEMORY;
+ case SERVICE_ERROR_OPERATION_FAILED:
+ return MESH_ERROR_OPERATION_FAILED;
+ case SERVICE_ERROR_INVALID_PARAMETER:
+ return MESH_ERROR_INVALID_PARAMETER;
+ case SERVICE_ERROR_ALREADY_REGISTERED:
+ return MESH_ERROR_ALREADY_IN_PROGRESS;
+ case SERVICE_ERROR_IN_PROGRESS:
+ return MESH_ERROR_NOW_IN_PROGRESS;
+ default:
+ return MESH_ERROR_OPERATION_FAILED;
+ }
+}
+
static GDBusProxy *_proxy_get_mesh_service(struct mesh_handle *handle)
{
GDBusProxy *proxy = NULL;
int _mesh_get_scan_result(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(aa{sv}u)", &iter, &result);
+ g_variant_get(variant, "(aa{sv}i)", &iter, &result);
+ result = __convert_service_error_type(result);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
struct mesh_network_s *network_info =
g_malloc0(sizeof(struct mesh_network_s));
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
static void _mesh_signal_handler(GDBusConnection *connection,
LOGD("signal received = %s", signal_name);
if (0 == g_strcmp0(signal_name, "mesh_enabled")) {
- unsigned int result;
- g_variant_get(parameters, "(u)", &result);
+ int result = MESH_ERROR_NONE;
+ g_variant_get(parameters, "(i)", &result);
+ result = __convert_service_error_type(result);
mesh_event_data_s ev;
ev.data.mesh_enable = calloc(1, sizeof(mesh_mesh_enabled_event_s));
int _mesh_enable(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("enabled status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_disable(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("Disabled status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
}
h->event_handler = NULL;
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_scan(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("scan status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("specific_scan status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_cancel_scan(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("cancle_scan status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_foreach_found_mesh_network(mesh_h handle,
int _mesh_enable_mesh(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("enable_mesh status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_disable_mesh(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("disable_mesh status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
/* TODO: Parameter verification required */
int _mesh_is_joined(mesh_h handle, int* is_joined)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("Mesh is_joined status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
struct mesh_network_s g_joined_network;
int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network)
{
+ int result = MESH_ERROR_NONE;
GVariant *variant = NULL;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
-
char *meshid = NULL;
char *bssid = NULL;
int channel = -1;
- unsigned int result;
- g_variant_get(variant, "(ssiu)", &meshid, &bssid, &channel, &result);
+ g_variant_get(variant, "(ssii)", &meshid, &bssid, &channel, &result);
LOGD("get_joined_mesh_network status 0x%x", result);
+ result = __convert_service_error_type(result);
if (MESH_ERROR_NONE != result)
- return (int)result;
+ return result;
if (meshid) {
- LOGE("meshid=%s", meshid);
+ LOGE(" Mesh ID : %s", meshid);
memcpy(g_joined_network.meshid, meshid, MAX_MESHID_LEN);
}
if (bssid) {
- LOGE("bssid=%s", bssid);
+ LOGE(" BSSID : %s", bssid);
memcpy(g_joined_network.bssid, bssid, MAX_BSSID_LEN);
}
g_joined_network.channel = channel;
g_joined_network.rssi = -1;
*_network= &g_joined_network;
-
- LOGE("meshid=%s bssid=%s", meshid, bssid);
-
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("set_gate status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_unset_gate(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("unset_gate status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_set_softap(mesh_h handle, const char* ssid,
int max_stations, int security)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("set_softap status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_enable_softap(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("enable_softap status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_disable_softap(mesh_h handle)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("disable_softap status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_create_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
struct mesh_network_s *n = _network;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("create_network status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_connect_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
struct mesh_network_s *n = _network;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("connect network status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
struct mesh_network_s *n = _network;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("disconnect network status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_forget_network(mesh_h handle, mesh_network_h _network)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
struct mesh_network_s *n = _network;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("forget_network status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
-
-//struct mesh_station_info_s g_station;
-
int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
NULL, &error);
if (variant) {
/* handle station list here */
- g_variant_get(variant, "(aa{sv}u)", &iter, &result);
+ g_variant_get(variant, "(aa{sv}i)", &iter, &result);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
struct mesh_station_info_s station;
memset(&station, 0, sizeof(struct mesh_station_info_s));
}
g_variant_iter_free(iter);
LOGD("get_saved_mesh_networks status 0x%x", result);
-
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
_mesh_remove_mpath();
/* handle station list here */
- g_variant_get(variant, "(aa{sv}u)", &iter, &result);
+ g_variant_get(variant, "(aa{sv}i)", &iter, &result);
LOGE("1");
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
struct mesh_mpath_dump_s *mpath = g_malloc0(sizeof(struct mesh_mpath_dump_s));
}
g_variant_iter_free(iter);
LOGD("get_saved_mesh_networks status 0x%x", result);
-
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, const char *softap)
{
GVariant *variant = NULL;
- unsigned int result;
+ int result = MESH_ERROR_NONE;
GError *error = NULL;
struct mesh_handle *h = handle;
-1,
NULL, &error);
if (variant) {
- g_variant_get(variant, "(u)", &result);
+ g_variant_get(variant, "(i)", &result);
LOGD("set_interfaces status 0x%x", result);
+ result = __convert_service_error_type(result);
} else if (error) {
LOGE("Failed DBus call [%s]", error->message);
g_error_free(error);
return MESH_ERROR_IO_ERROR;
}
- return MESH_ERROR_NONE;
+ return result;
}
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_ADDRESS_FAMILY_NOT_SUPPORTED)
+ CASE_TO_STR(MESH_ERROR_ALREADY_IN_PROGRESS)
CASE_TO_STR(MESH_ERROR_NOW_IN_PROGRESS)
- CASE_TO_STR(MESH_ERROR_OPERATION_FAILED)
- CASE_TO_STR(MESH_ERROR_OPERATION_ABORTED)
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)
default :
- return "MESH_ERROR_UNKNOWN";
+ return "Unknown Error";
}
}
void event_cb(mesh_event_e event_type, mesh_event_data_s* event)
{
- msgp("event received = %s", _mesh_event_to_string(event_type));
+ msg("");
+ msgp("Event received [%s]", _mesh_event_to_string(event_type));
switch(event_type) {
case MESH_MESH_ENABLED_EVENT: {
- msgp("Mesh Network Enabled Result = %d", event->data.mesh_enable->result);
+ msgp(" Mesh Network Enabled Result = %d", event->data.mesh_enable->result);
} break;
case MESH_SCAN_DONE_EVENT: {
- msgp("Mesh Scan Done");
+ msgp(" Mesh Scan Done");
} break;
case MESH_JOIN_NETWORK_EVENT:{
- msgp("Joined Network");
+ msgp(" Joined Network");
} break;
case MESH_LEFT_NETWORK_EVENT: {
- msgp("Left Current Network");
+ msgp(" Left Current Network");
} break;
case MESH_STATION_JOIN_EVENT: {
- msgp("New Station Joined = %s", event->data.sta_info->bssid);
+ msgp(" New Station Joined = %s", event->data.sta_info->bssid);
} break;
case MESH_STATION_LEFT_EVENT: {
- msgp("A Station Left = %s", event->data.sta_info->bssid);
+ msgp(" A Station Left = %s", event->data.sta_info->bssid);
} break;
}
}
#define msgn(fmt,args...) do { fprintf(stdout, fmt, ##args); \
fflush(stdout); } while (0)
+/* Bold (red) */
+#define msgr(fmt,args...) do { fprintf(stdout, ANSI_COLOR_RED fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
/* Bold (green) */
#define msgb(fmt,args...) do { fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
msg("create");
ret = mesh_initialize(&mesh);
- if (ret != 0) {
- msg("Failed to initialize mesh: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to initialize mesh: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_initialize() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("destroy");
ret = mesh_deinitialize(mesh);
- if (ret != 0) {
- msg("Failed to de-initialize mesh: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to de-initialize mesh: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_deinitialize() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("enable");
ret = mesh_set_event_cb(mesh, event_cb);
- if (ret != 0) {
- msg("Failed to set callback for mesh network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to set callback for mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_set_event_cb() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
ret = mesh_enable(mesh);
- if (ret != 0) {
- msg("Failed to enable mesh network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to enable mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_enable() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("disable");
ret = mesh_disable(mesh);
- if (ret != 0) {
- msg("Failed to disable mesh network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to disable mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_disable() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("set_interfaces");
ret = mesh_set_interfaces(mesh, mesh_interface, gate_interface, softap_interface);
- if (ret != 0) {
- msg("Failed to set interfaces: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to set interfaces: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_set_interfaces() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
int channel;
ret = mesh_network_clone(&net, network);
- if (0 != ret) {
- msg("Failed to clone found network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to clone found network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
return;
}
msg("Scan");
ret = mesh_scan(mesh);
- if (ret != 0) {
- msg("Failed to scan: [%s(0x%X)]", mesh_error_to_string(ret), ret);
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to scan: [%s(0x%X)]", mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
g_found_network_list = NULL;
ret = mesh_foreach_found_mesh_network(mesh, found_mesh_network_cb, NULL);
- if (ret != 0) {
- msg("Failed to mesh_foreach_found_mesh_network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_foreach_found_mesh_network: [%s(0x%X)]",
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));
return RET_SUCCESS;
}
channel = (unsigned short)strtol(mesh_channel, NULL, 10);
ret = mesh_specific_scan(mesh, meshid, channel);
- if (ret != 0) {
- msg("Failed to specific scan: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to specific scan: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_specific_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Cancel Scan");
ret = mesh_cancel_scan(mesh);
- if (ret != 0) {
- msg("Failed to cancel scan: [%s(0x%X)]", mesh_error_to_string(ret), ret);
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to cancel scan: [%s(0x%X)]", mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_cancel_scan() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Enable Mesh");
ret = mesh_enable_mesh(mesh);
- if (ret != 0) {
- msg("Failed to enable mesh network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to enable mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_enable_mesh() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Disable Mesh");
ret = mesh_disable_mesh(mesh);
- if (ret != 0) {
- msg("Failed to disable mesh network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to disable mesh network: [%s(0x%X)]", mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_disable_mesh() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Get Joined Mesh Network Information");
ret = mesh_get_joined_network(mesh, &network);
- if (ret != 0) {
- msg("Failed to enable mesh network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to enable mesh network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
-
- mesh_network_get_meshid(network, &_meshid);
- msgp("mesh id = %s", _meshid);
- mesh_network_get_bssid(network, &_bssid);
- msgp("bssid = %s", _bssid);
- mesh_network_get_channel(network, &_channel);
- msgp("channel = %d", _channel);
+ msg(" - mesh_get_joined_network() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
+ msg("");
+
+ if (NULL != network) {
+ mesh_network_get_meshid(network, &_meshid);
+ msgp(" Mesh ID = %s", _meshid);
+ mesh_network_get_bssid(network, &_bssid);
+ msgp(" BSSID = %s", _bssid);
+ mesh_network_get_channel(network, &_channel);
+ msgp(" Channel = %d", _channel);
+ }
return RET_SUCCESS;
}
_gate_announce = (unsigned short)strtol(gate_announce, NULL, 10);
ret = mesh_set_gate(mesh, _stp, _gate_announce);
- if (ret != 0) {
- msg("Failed to set gate options: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to set gate options: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_set_gate() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Disable All Gate Option");
ret = mesh_unset_gate(mesh);
- if (ret != 0) {
- msg("Failed to unset gate option: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to unset gate option: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_unset_gate() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
int _security = 2;
msg("Set SoftAp Option");
-
if (strlen(softap_channel))
_channel = (unsigned short)strtol(softap_channel, NULL, 10);
if (strlen(visibility)) {
if (strlen(security))
_security = (unsigned short)strtol(security, NULL, 10);
- ret = mesh_set_softap(mesh, ssid, passphrase, _channel, _visibility, _max_stations, _security);
- if (ret != 0) {
- msg("Failed to set softap options: [%s(0x%X)]",
+ ret = mesh_set_softap(mesh, ssid, passphrase,
+ _channel, _visibility, _max_stations, _security);
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to set softap options: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_set_softap() ret: [0x%X] [%s]", ret, mesh_error_to_string(ret));
+
return RET_SUCCESS;
}
msg("Enable SoftAp");
ret = mesh_enable_softap(mesh);
- if (ret != 0) {
- msg("Failed to enable soft ap: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to enable soft ap: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_enable_softap() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
+
return RET_SUCCESS;
}
msg("Disable SoftAp");
ret = mesh_disable_softap(mesh);
- if (ret != 0) {
- msg("Failed to disable soft ap: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to disable soft ap: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_disable_softap() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, 0);
ret = mesh_create_mesh_network(mesh, net);
mesh_network_destroy(net);
- if (ret != 0) {
- msg("Failed to mesh_create_mesh_network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_create_mesh_network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_create_mesh_network() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
if (strlen(network_idx)) {
idx = (unsigned short)strtol(network_idx, NULL, 10);
if (0 >= idx) {
- msg("Invalid index. set to 1");
+ msgp("Invalid index. set to 1");
idx = 1;
}
}
if (g_found_network_list) {
net = g_list_nth_data(g_found_network_list, idx - 1);
if (NULL == net) {
- msg("Failed to g_hash_table_find");
+ msgr("Failed to g_hash_table_find");
return RET_FAILURE;
}
}
ret = mesh_connect_mesh_network(mesh, net);
- if (ret != 0) {
- msg("Failed to mesh_connect_mesh_network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_connect_mesh_network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_connect_mesh_network() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
if (strlen(network_idx)) {
idx = (unsigned short)strtol(network_idx, NULL, 10);
if (0 >= idx) {
- msg("Invalid index. set to 1");
+ msgp("Invalid index. set to 1");
idx = 1;
}
}
if (g_found_network_list) {
net = g_list_nth_data(g_found_network_list, idx - 1);
if (NULL == net) {
- msg("Failed to g_hash_table_find");
+ msgr("Failed to g_hash_table_find");
return RET_FAILURE;
}
}
ret = mesh_disconnect_mesh_network(mesh, net);
- if (ret != 0) {
- msg("Failed to mesh_disconnect_mesh_network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_disconnect_mesh_network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_disconnect_mesh_network() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
if (strlen(network_idx)) {
idx = (unsigned short)strtol(network_idx, NULL, 10);
if (0 >= idx) {
- msg("Invalid index. set to 1");
+ msgp("Invalid index. set to 1");
idx = 1;
}
}
if (g_found_network_list) {
net = g_list_nth_data(g_found_network_list, idx - 1);
if (NULL == net) {
- msg("Failed to g_hash_table_find");
+ msgr("Failed to g_hash_table_find");
return RET_FAILURE;
}
}
ret = mesh_forget_mesh_network(mesh, net);
- if (ret != 0) {
- msg("Failed to mesh_forget_mesh_network: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_forget_mesh_network: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_forget_mesh_network() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Get Mesh Station Information");
ret = mesh_get_stations_info(mesh, found_station_cb, NULL);
- if (ret != 0) {
- msg("Failed to mesh_get_stations_info: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_get_stations_info: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_get_stations_info() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}
msg("Get Mesh Path Information");
ret = mesh_get_mpath_info(mesh, found_mpath_cb, NULL);
- if (ret != 0) {
- msg("Failed to mesh_get_mpath_info: [%s(0x%X)]",
+ if (MESH_ERROR_NONE != ret) {
+ msgr("Failed to mesh_get_mpath_info: [%s(0x%X)]",
mesh_error_to_string(ret), ret);
return RET_FAILURE;
}
+ msg(" - mesh_get_mpath_info() ret: [0x%X] [%s]",
+ ret, mesh_error_to_string(ret));
return RET_SUCCESS;
}