int message_length, void *user_data);
typedef void (*uwb_position_changed_cb)(uint64_t node_id, int x, int y, int z,
void *user_data);
+typedef void (*uwb_position_updated_cb)(uint64_t node_id, int x, int y, int z,
+ void *user_data);
+typedef void (*uwb_node_added_cb)(uwb_node_h remote_node, void *user_data);
+typedef void (*uwb_node_updated_cb)(uwb_node_h remote_node, void *user_data);
+typedef void (*uwb_node_removed_cb)(uwb_node_h remote_node, void *user_data);
typedef void (*uwb_get_network_finished_cb)(int result, uwb_network_h network, void *user_data);
typedef bool (*uwb_network_foreach_remote_node_cb)(uwb_node_h remote_node, void *user_data);
int uwb_factory_reset(void);
int uwb_set_message_received_cb(uwb_message_received_cb message_received_cb, void *user_data);
int uwb_set_position_changed_cb(uwb_position_changed_cb position_changed_cb, void *user_data);
+int uwb_set_position_updated_cb(uwb_position_updated_cb position_updated_cb, void *user_data);
+int uwb_set_node_added_cb(uwb_node_added_cb node_added_cb, void *user_data);
+int uwb_set_node_updated_cb(uwb_node_updated_cb node_updated_cb, void *user_data);
+int uwb_set_node_removed_cb(uwb_node_removed_cb uode_removed_cb, void *user_data);
int uwb_unset_message_received_cb(void);
int uwb_unset_position_changed_cb(void);
+int uwb_unset_position_updated_cb(void);
+int uwb_unset_node_added_cb(void);
+int uwb_unset_node_updated_cb(void);
+int uwb_unset_node_removed_cb(void);
+int uwb_network_enable(void);
+int uwb_network_disable(void);
+int uwb_location_engine_start(const char *server, int port);
+int uwb_location_engine_stop(void);
int uwb_node_set_position(uwb_node_h node, int x, int y, int z);
int uwb_node_send_message(const unsigned char *message, int len);
int uwb_node_send_message_to(uwb_node_h node, const unsigned char *message, int len);
</method>
<method name="FactoryReset">
</method>
+ <method name="EnableNetwork">
+ </method>
+ <method name="DisableNetwork">
+ </method>
+ <method name="StartLocationEngine">
+ <arg type="s" name="server" direction="in" />
+ <arg type="i" name="port" direction="in" />
+ </method>
+ <method name="StopLocationEngine">
+ </method>
<method name="GetOwnNode">
<arg type="a{sv}" name="own_node" direction="out" />
</method>
<arg type="i" name="y" />
<arg type="i" name="z" />
</signal>
+ <signal name="PositionUpdated">
+ <arg type="q" name="node_id" />
+ <arg type="i" name="x" />
+ <arg type="i" name="y" />
+ <arg type="i" name="z" />
+ </signal>
+ <signal name="NodeAdded">
+ <arg type="i" name="pan_id" />
+ <arg type="q" name="node_id" />
+ <arg type="i" name="x" />
+ <arg type="i" name="y" />
+ <arg type="i" name="z" />
+ </signal>
+ <signal name="NodeUpdated">
+ <arg type="i" name="pan_id" />
+ <arg type="q" name="node_id" />
+ <arg type="i" name="x" />
+ <arg type="i" name="y" />
+ <arg type="i" name="z" />
+ </signal>
+ <signal name="NodeRemoved">
+ <arg type="i" name="pan_id" />
+ <arg type="q" name="node_id" />
+ <arg type="i" name="x" />
+ <arg type="i" name="y" />
+ <arg type="i" name="z" />
+ </signal>
</interface>
</node>
#define UWB_DBUS_SERVICE "org.tizen.uwb" /**< For uwb dbus */
#define UWB_DBUS_MANAGER_PATH "/org/tizen/uwb/manager" /**< For manager dbus */
-
static struct _uwb_ctx {
Manager *manager_proxy;
uwb_message_received_cb message_received_cb;
void *message_received_user_data;
uwb_position_changed_cb position_changed_cb;
void *position_changed_user_data;
+
+ uwb_position_updated_cb position_updated_cb;
+ void *position_updated_user_data;
+ uwb_node_added_cb node_added_cb;
+ void *node_added_user_data;
+ uwb_node_updated_cb node_updated_cb;
+ void *node_updated_user_data;
+ uwb_node_removed_cb node_removed_cb;
+ void *node_removed_user_data;
+
uwb_get_network_finished_cb get_network_finished_cb;
uwb_network_foreach_remote_node_cb foreach_remote_node_cb;
} uwb_ctx = {NULL,};
uwb_ctx.position_changed_cb(node_id, x, y, z, uwb_ctx.position_changed_user_data);
}
+
+static void __position_updated(GObject *source_object,
+ guint16 node_id, gint x, gint y, gint z)
+{
+ _BEGIN();
+ if (uwb_ctx.position_updated_cb != NULL)
+ uwb_ctx.position_updated_cb(node_id, x, y, z, uwb_ctx.position_updated_user_data);
+}
+
+
+static void __node_added(GObject *source_object,
+ gint pan_id, guint16 node_id, gint x, gint y, gint z)
+{
+ _BEGIN();
+ uwb_node_s remote_node = {node_id, pan_id, true, 0, x, y, z};
+ if (uwb_ctx.node_added_cb != NULL)
+ uwb_ctx.node_added_cb(&remote_node, uwb_ctx.node_added_user_data);
+}
+
+
+static void __node_updated(GObject *source_object,
+ gint pan_id, guint16 node_id, gint x, gint y, gint z)
+{
+ _BEGIN();
+ uwb_node_s remote_node = {node_id, pan_id, true, 0, x, y, z};
+ if (uwb_ctx.node_updated_cb != NULL)
+ uwb_ctx.node_updated_cb(&remote_node, uwb_ctx.node_updated_user_data);
+}
+
+
+static void __node_removed(GObject *source_object,
+ gint pan_id, guint16 node_id, gint x, gint y, gint z)
+{
+ _BEGIN();
+ uwb_node_s remote_node = {node_id, pan_id, true, 0, x, y, z};
+ if (uwb_ctx.node_removed_cb != NULL)
+ uwb_ctx.node_removed_cb(&remote_node, uwb_ctx.node_removed_user_data);
+}
+
static int manager_proxy_init(void)
{
GError *error = NULL;
g_signal_connect(uwb_ctx.manager_proxy, "position-changed",
G_CALLBACK(__position_changed), NULL);
+ g_signal_connect(uwb_ctx.manager_proxy, "position-updated",
+ G_CALLBACK(__position_updated), NULL);
+
+ g_signal_connect(uwb_ctx.manager_proxy, "node-added",
+ G_CALLBACK(__node_added), NULL);
+
+ g_signal_connect(uwb_ctx.manager_proxy, "node-updated",
+ G_CALLBACK(__node_updated), NULL);
+
+ g_signal_connect(uwb_ctx.manager_proxy, "node-removed",
+ G_CALLBACK(__node_removed), NULL);
+
return UWB_ERROR_NONE;
}
return ret;
}
+EXPORT_API int uwb_set_position_updated_cb(uwb_position_updated_cb position_updated_cb, void *user_data)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.position_updated_cb = position_updated_cb;
+ uwb_ctx.position_updated_user_data = user_data;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_set_node_added_cb(uwb_node_added_cb node_added_cb, void *user_data)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_added_cb = node_added_cb;
+ uwb_ctx.node_added_user_data = user_data;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_set_node_updated_cb(uwb_node_updated_cb node_updated_cb, void *user_data)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_updated_cb = node_updated_cb;
+ uwb_ctx.node_updated_user_data = user_data;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_set_node_removed_cb(uwb_node_removed_cb node_removed_cb, void *user_data)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_removed_cb = node_removed_cb;
+ uwb_ctx.node_removed_user_data = user_data;
+
+ _END();
+
+ return ret;
+}
+
EXPORT_API int uwb_unset_message_received_cb(void)
{
int ret = UWB_ERROR_NONE;
return ret;
}
+EXPORT_API int uwb_unset_position_updated_cb(void)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.position_updated_cb = NULL;
+ uwb_ctx.position_updated_user_data = NULL;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_unset_node_added_cb(void)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_added_cb = NULL;
+ uwb_ctx.node_added_user_data = NULL;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_unset_node_updated_cb(void)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_updated_cb = NULL;
+ uwb_ctx.node_updated_user_data = NULL;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_unset_node_removed_cb(void)
+{
+ int ret = UWB_ERROR_NONE;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+
+ _BEGIN();
+
+ uwb_ctx.node_removed_cb = NULL;
+ uwb_ctx.node_removed_user_data = NULL;
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_network_enable(void)
+{
+ int ret = UWB_ERROR_NONE;
+ GError *error = NULL;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+ CHECK_NOT_INITIALIZED();
+
+ _BEGIN();
+
+ if (manager_call_enable_network_sync(uwb_ctx.manager_proxy, NULL, &error) == FALSE) {
+ _ERR("manager_call_enable_network_sync failed : %s", error->message);
+ __handle_error(error, &ret);
+ }
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_network_disable(void)
+{
+ int ret = UWB_ERROR_NONE;
+ GError *error = NULL;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+ CHECK_NOT_INITIALIZED();
+
+ _BEGIN();
+
+ if (manager_call_disable_network_sync(uwb_ctx.manager_proxy, NULL, &error) == FALSE) {
+ _ERR("manager_call_disable_network_sync failed : %s", error->message);
+ __handle_error(error, &ret);
+ }
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_location_engine_start(const char *server, int port)
+{
+ int ret = UWB_ERROR_NONE;
+ GError *error = NULL;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+ CHECK_NOT_INITIALIZED();
+
+ _BEGIN();
+
+ uwb_check_null_ret_error("server", server, UWB_ERROR_INVALID_PARAMETER);
+
+ if (manager_call_start_location_engine_sync(uwb_ctx.manager_proxy,
+ server, port, NULL, &error) == FALSE) {
+ _ERR("manager_call_start_location_engine_sync failed : %s", error->message);
+ __handle_error(error, &ret);
+ }
+
+ _END();
+
+ return ret;
+}
+
+EXPORT_API int uwb_location_engine_stop(void)
+{
+ int ret = UWB_ERROR_NONE;
+ GError *error = NULL;
+
+ CHECK_FEATURE_SUPPORTED(UWB_FEATURE);
+ CHECK_NOT_INITIALIZED();
+
+ _BEGIN();
+
+ if (manager_call_stop_location_engine_sync(uwb_ctx.manager_proxy, NULL, &error) == FALSE) {
+ _ERR("manager_call_stop_location_engine_sync failed : %s", error->message);
+ __handle_error(error, &ret);
+ }
+
+ _END();
+
+ return ret;
+}
+
EXPORT_API int uwb_get_own_node(uwb_node_h *own_node)
{
int ret = UWB_ERROR_NONE;
CMD_DEINITIALIZE,
CMD_RESET,
CMD_FACTORY_RESET,
+ CMD_NETWORK_ENABLE,
+ CMD_NETWORK_DISABLE,
CMD_GET_OWN_NODE,
+ CMD_LOCATION_ENGINE_START,
+ CMD_LOCATION_ENGINE_STOP,
CMD_GET_NETWORK,
CMD_SET_POSITION,
CMD_SEND_MESSAGE,
= "RESET",
[CMD_FACTORY_RESET]
= "FACTORY_RESET",
+ [CMD_NETWORK_ENABLE]
+ = "NETWORK_ENABLE",
+ [CMD_NETWORK_DISABLE]
+ = "NETWORK_DISABLE",
[CMD_GET_OWN_NODE]
= "GET_OWN_NODE",
+ [CMD_LOCATION_ENGINE_START]
+ = "LOCATION_ENGINE_START",
+ [CMD_LOCATION_ENGINE_STOP]
+ = "LOCATION_ENGINE_STOP",
[CMD_GET_NETWORK]
= "GET_NETWORK",
return;
}
+
+void __position_updated_cb(uint64_t node_id, int x, int y, int z,
+ void *user_data)
+{
+
+}
+
+void __node_added_cb(uwb_node_h remote_node, void *user_data)
+{
+
+}
+
+void __node_updated_cb(uwb_node_h remote_node, void *user_data)
+{
+
+}
+
+void __node_removed_cb(uwb_node_h remote_node, void *user_data)
+{
+
+}
+
void test_init(void)
{
int ret = 0;
ret = uwb_initialize();
__print_result(ret, "uwb_initialize");
+ uwb_set_position_updated_cb(__position_updated_cb, NULL);
+ uwb_set_node_added_cb(__node_added_cb, NULL);
+ uwb_set_node_updated_cb(__node_updated_cb, NULL);
+ uwb_set_node_removed_cb(__node_removed_cb, NULL);
+
return;
}
RET_IF_LOOP_IS_NULL();
+
+ uwb_unset_position_updated_cb();
+ uwb_unset_node_added_cb();
+ uwb_unset_node_updated_cb();
+ uwb_unset_node_removed_cb();
+
ret = uwb_deinitialize();
__print_result(ret, "uwb_deinitialize");
return;
}
+void test_network_enable(void)
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ ret = uwb_network_enable();
+ __print_result(ret, "uwb_network_enable");
+
+ return;
+}
+
+void test_network_disable(void)
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ ret = uwb_network_disable();
+ __print_result(ret, "uwb_network_disable");
+
+ return;
+}
+
bool __print_node_info(uwb_node_h node, void *user_data)
{
uint64_t distance = 0;
return;
}
+void test_location_engine_start(void)
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ ret = uwb_location_engine_start("localhost", 1883);
+ __print_result(ret, "uwb_location_engine_start");
+
+ return;
+}
+
+void test_location_engine_stop(void)
+{
+ int ret = 0;
+
+ RET_IF_LOOP_IS_NULL();
+
+ ret = uwb_location_engine_stop();
+ __print_result(ret, "uwb_location_engine_stop");
+
+ return;
+}
+
void __print_network_info(uwb_network_h uwb_network)
{
uint64_t pan_id = 0;
[CMD_FACTORY_RESET]
= test_factory_reset,
+ [CMD_NETWORK_ENABLE]
+ = test_network_enable,
+ [CMD_NETWORK_DISABLE]
+ = test_network_disable,
[CMD_GET_OWN_NODE]
= test_get_own_node,
+ [CMD_LOCATION_ENGINE_START]
+ = test_location_engine_start,
+ [CMD_LOCATION_ENGINE_STOP]
+ = test_location_engine_stop,
[CMD_GET_NETWORK]
= test_get_network,