static GDBusProxy *_gproxy_connman = NULL;
static GDBusProxy *_gproxy_connman_mesh = NULL;
static GDBusProxy *_gproxy_connman_technology = NULL;
+static GDBusProxy *_gproxy_connman_ethernet = NULL;
static int _meshd_close_gdbus_call(mesh_service *service);
static int _mesh_gdbus_get_mesh_network_property(mesh_service *service,
return proxy;
}
+static GDBusProxy *_proxy_get_connman_ethernet(mesh_service *service)
+{
+ GDBusProxy *proxy = NULL;
+ meshd_check_null_ret_error("service", service, NULL);
+
+ if (NULL == _gproxy_connman_ethernet) {
+ proxy = g_dbus_proxy_new_sync(service->connection,
+ G_DBUS_PROXY_FLAGS_NONE, NULL,
+ CONNMAN_SERVER_NAME, /* Name */
+ "/net/connman/technology/ethernet", /* Object Path */
+ CONNMAN_INTERFACE_TECH, /* interface Name */
+ NULL, NULL);
+ } else
+ proxy = _gproxy_connman_ethernet;
+
+ return proxy;
+}
+
static GDBusProxy *_proxy_get_connman_technology(mesh_service *service)
{
GDBusProxy *proxy = NULL;
g_dbus_proxy_set_default_timeout(
G_DBUS_PROXY(_gproxy_connman_technology), MESH_DBUS_PROXY_TIMEOUT);
+ _gproxy_connman_ethernet = _proxy_get_connman_ethernet(service);
+ meshd_check_null_ret_error("_gproxy_connman_ethernet", _gproxy_connman_ethernet,
+ MESHD_ERROR_IO_ERROR);
+ g_dbus_proxy_set_default_timeout(
+ G_DBUS_PROXY(_gproxy_connman_ethernet), MESH_DBUS_PROXY_TIMEOUT);
+
/* Subscribe events */
_meshd_subscribe_event(service);
/* Scan is not in progress */
if (g_strrstr(error->message, "Already exists"))
ret = MESHD_ERROR_NONE;
-
+
g_error_free(error);
}
return MESHD_ERROR_NONE;
}
+
+
+int mesh_gdbus_enable_ethernet_interface(mesh_service *service, bool state)
+{
+ int ret = MESHD_ERROR_NONE;
+ GVariant *variant = NULL;
+ GError *error = NULL;
+ mesh_interface_s *info = NULL;
+
+ meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
+ meshd_check_null_ret_error("connection", service->connection,
+ MESHD_ERROR_INVALID_PARAMETER);
+ meshd_check_null_ret_error("_gproxy_connman_technology",
+ _gproxy_connman_technology, MESHD_ERROR_IO_ERROR);
+
+ info = service->interface_info;
+ meshd_check_null_ret_error("info", info, MESHD_ERROR_INVALID_PARAMETER);
+
+ variant = g_dbus_proxy_call_sync(_gproxy_connman_ethernet, "SetProperty",
+ g_variant_new("(sv)", "Powered", g_variant_new_boolean(state)),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (variant) {
+ MESH_LOGD("Successfully requested. [Powered]");
+ } else if (error) {
+ ret = MESHD_ERROR_IO_ERROR;
+ MESH_LOGE("Failed DBus call [%s]", error->message);
+
+ /* Interface not exists (Not created yet) */
+ if (g_strrstr(error->message, "No such device"))
+ ret = MESHD_ERROR_NONE;
+ g_error_free(error);
+ }
+
+ return ret;
+}
+
#include "mesh.h"
#include "mesh-log.h"
#include "mesh-util.h"
+#include "mesh-gdbus.h"
#include "mesh-request.h"
#include "mesh-netlink.h"
#include "mesh-interface.h"
MESH_LOGE("Status : %d %d %d", ret, info->can_be_gate, state);
if (MESHD_ERROR_NONE == ret) {
if (info->can_be_gate != state) {
+ mesh_gdbus_enable_ethernet_interface(service, state);
/* Detect external network state (i.e. Ethernet)
and decide to make gate enabled */
if (state)
MESH_LOGD("External interface state has been changed : [%d]", state);
info->can_be_gate = state;
}
+ } else {
+ /* In error case, we call enable etheret again for OdroidU3 */
+ mesh_gdbus_enable_ethernet_interface(service, true);
}
+
#if 0
_get_mpath_info(service);
#endif