Add service error enums
authorJiwan Kim <ji-wan.kim@samsung.com>
Thu, 1 Jun 2017 07:25:34 +0000 (16:25 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
- Add 'service_error_e' to get error code from service.
- Print message to notify the return state of API.

CMakeLists.txt
include/mesh.h
include/service_error.h [new file with mode: 0644]
src/mesh_dbus.c
test/main.c
test/menu.h
test/mesh_device.c
test/mesh_network.c

index d57e98d..a9eb25d 100644 (file)
@@ -49,6 +49,7 @@ INSTALL(
         DIRECTORY ${INC_DIR}/ DESTINATION include/network
         FILES_MATCHING
         PATTERN "mesh_*.h" EXCLUDE
+        PATTERN "service_*.h" EXCLUDE
         PATTERN "${INC_DIR}/*.h"
         )
 
index 4879f7f..8b34e28 100644 (file)
@@ -50,18 +50,18 @@ typedef void *mesh_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;
 
 /**
diff --git a/include/service_error.h b/include/service_error.h
new file mode 100644 (file)
index 0000000..53b4036
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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__ */
index b1f64e0..e9fc5ac 100644 (file)
 #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;
@@ -130,7 +155,7 @@ static void _mesh_remove_networks()
 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;
 
@@ -153,7 +178,8 @@ int _mesh_get_scan_result(mesh_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));
@@ -190,7 +216,7 @@ int _mesh_get_scan_result(mesh_h handle)
                return MESH_ERROR_IO_ERROR;
        }
 
-       return MESH_ERROR_NONE;
+       return result;
 }
 
 static void _mesh_signal_handler(GDBusConnection *connection,
@@ -204,8 +230,9 @@ 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));
@@ -398,7 +425,7 @@ int _mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler)
 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;
 
@@ -413,21 +440,22 @@ int _mesh_enable(mesh_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;
 
@@ -445,8 +473,9 @@ int _mesh_disable(mesh_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);
@@ -454,13 +483,13 @@ int _mesh_disable(mesh_h handle)
        }
        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;
 
@@ -473,21 +502,22 @@ int _mesh_scan(mesh_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;
 
@@ -500,21 +530,22 @@ int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel)
                                -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;
 
@@ -527,15 +558,16 @@ int _mesh_cancel_scan(mesh_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,
@@ -575,7 +607,7 @@ 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;
 
@@ -588,21 +620,22 @@ int _mesh_enable_mesh(mesh_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;
 
@@ -615,22 +648,23 @@ int _mesh_disable_mesh(mesh_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;
 
@@ -643,21 +677,23 @@ int _mesh_is_joined(mesh_h handle, int* is_joined)
                                -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;
@@ -672,46 +708,42 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network)
                                -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;
 
@@ -724,21 +756,22 @@ int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce)
                                -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;
 
@@ -751,15 +784,16 @@ int _mesh_unset_gate(mesh_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,
@@ -768,7 +802,7 @@ 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;
 
@@ -782,21 +816,22 @@ int _mesh_set_softap(mesh_h handle, const char* ssid,
                                -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;
 
@@ -809,21 +844,22 @@ int _mesh_enable_softap(mesh_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;
 
@@ -836,21 +872,22 @@ int _mesh_disable_softap(mesh_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;
@@ -864,21 +901,22 @@ int _mesh_create_network(mesh_h handle, mesh_network_h _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;
@@ -892,21 +930,22 @@ int _mesh_connect_network(mesh_h handle, mesh_network_h _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;
@@ -920,21 +959,22 @@ int _mesh_disconnect_network(mesh_h handle, mesh_network_h _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;
@@ -950,24 +990,22 @@ int _mesh_forget_network(mesh_h handle, mesh_network_h _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;
 
@@ -988,7 +1026,7 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_
                                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));
@@ -1098,20 +1136,20 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_
                }
                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;
 
@@ -1135,7 +1173,7 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data)
                _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));
@@ -1186,20 +1224,20 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data)
                }
                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;
 
@@ -1212,14 +1250,15 @@ int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, cons
                                -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;
 }
 
index 2199a1f..76aeb56 100644 (file)
@@ -44,15 +44,17 @@ const char* mesh_error_to_string(mesh_error_e err)
        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";
        }
 }
 
@@ -73,26 +75,27 @@ static const char* _mesh_event_to_string(mesh_event_e e)
 
 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;
        }
 }
index 95c4453..dbcd195 100644 (file)
@@ -46,6 +46,10 @@ __BEGIN_DECLS
 #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)
index 6206a3b..57a85ad 100644 (file)
@@ -36,11 +36,12 @@ static int run_mesh_create(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -51,11 +52,12 @@ static int run_mesh_destroy(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -66,18 +68,20 @@ static int run_mesh_enable(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -88,11 +92,12 @@ static int run_mesh_disable(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -106,11 +111,12 @@ static int run_mesh_set_interfaces(MManager *mm, struct menu_data *menu)
        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;
 }
index 273b160..e14bcc3 100644 (file)
@@ -58,8 +58,8 @@ void found_mesh_network_cb(mesh_network_h network, void* user_data)
        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;
        }
 
@@ -115,10 +115,11 @@ static int run_mesh_scan(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -136,11 +137,13 @@ static int run_get_found_mesh_network(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -156,11 +159,12 @@ static int run_mesh_specific_scan(MManager *mm, struct menu_data *menu)
                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;
 }
@@ -171,10 +175,11 @@ static int run_mesh_cancel_scan(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -185,11 +190,12 @@ static int run_mesh_enable(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -200,10 +206,11 @@ static int run_mesh_disable(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -219,18 +226,23 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu)
        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;
 }
 
@@ -248,11 +260,12 @@ static int run_set_gate(MManager *mm, struct menu_data *menu)
                _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;
 }
@@ -263,11 +276,12 @@ static int run_unset_gate(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -281,7 +295,6 @@ static int run_set_softap(MManager *mm, struct menu_data *menu)
        int _security = 2;
        msg("Set SoftAp Option");
 
-
        if (strlen(softap_channel))
                _channel = (unsigned short)strtol(softap_channel, NULL, 10);
        if (strlen(visibility)) {
@@ -293,12 +306,15 @@ 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, _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;
 }
 
@@ -308,11 +324,14 @@ static int run_enable_softap(MManager *mm, struct menu_data *menu)
        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;
 }
 
@@ -322,11 +341,13 @@ static int run_disable_softap(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -345,11 +366,13 @@ static int run_create_network(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -364,7 +387,7 @@ static int run_connect_network(MManager *mm, struct menu_data *menu)
        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;
                }
        }
@@ -372,17 +395,19 @@ static int run_connect_network(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -397,7 +422,7 @@ static int run_disconnect_network(MManager *mm, struct menu_data *menu)
        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;
                }
        }
@@ -405,17 +430,19 @@ static int run_disconnect_network(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -430,7 +457,7 @@ static int run_forget_network(MManager *mm, struct menu_data *menu)
        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;
                }
        }
@@ -438,17 +465,19 @@ static int run_forget_network(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -459,11 +488,13 @@ static int run_get_station_information(MManager *mm, struct menu_data *menu)
        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;
 }
@@ -474,11 +505,13 @@ static int run_get_mpath_information(MManager *mm, struct menu_data *menu)
        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;
 }