From e84bdbb07d4d8e97acfb4fec75faef0008a1caeb Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Mon, 3 May 2021 13:27:11 +0900 Subject: [PATCH] Add error handling for not supported functions Change-Id: I57f5e15e2bf53ec1d92902dcb3f7d42568af5f0f Signed-off-by: Jihoon Jung --- src/hal-api-uwb.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/hal-api-uwb.c b/src/hal-api-uwb.c index 03fe5a4..b2c3b06 100755 --- a/src/hal-api-uwb.c +++ b/src/hal-api-uwb.c @@ -75,6 +75,10 @@ int hal_uwb_start(uwb_hal_event_cbs_s *event_cbs) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->start) + return -ENOTSUP; + return g_uwb_funcs->start(event_cbs); } @@ -83,6 +87,10 @@ int hal_uwb_stop(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->stop) + return -ENOTSUP; + return g_uwb_funcs->stop(); } @@ -91,6 +99,10 @@ int hal_uwb_test(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->test) + return -ENOTSUP; + return g_uwb_funcs->test(); } @@ -99,6 +111,10 @@ int hal_uwb_reset(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->reset) + return -ENOTSUP; + return g_uwb_funcs->reset(); } @@ -107,6 +123,10 @@ int hal_uwb_factory_reset(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->factory_reset) + return -ENOTSUP; + return g_uwb_funcs->factory_reset(); } @@ -115,6 +135,10 @@ int hal_uwb_enable_network(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->enable_network) + return -ENOTSUP; + return g_uwb_funcs->enable_network(); } @@ -123,6 +147,10 @@ int hal_uwb_disable_network(void) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->disable_network) + return -ENOTSUP; + return g_uwb_funcs->disable_network(); } @@ -131,6 +159,10 @@ int hal_uwb_get_network_info(uwb_hal_network_s **network_info) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->get_network_info) + return -ENOTSUP; + return g_uwb_funcs->get_network_info(network_info); } @@ -139,6 +171,10 @@ int hal_uwb_set_configurations(uint16_t node_id, const GVariant *configurations) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->set_configurations) + return -ENOTSUP; + return g_uwb_funcs->set_configurations(node_id, configurations); } @@ -147,6 +183,10 @@ int hal_uwb_get_configurations(uint16_t node_id, GVariant **configurations) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->get_configurations) + return -ENOTSUP; + return g_uwb_funcs->get_configurations(node_id, configurations); } @@ -155,6 +195,10 @@ int hal_uwb_set_position(uint64_t node_id, int x, int y, int z) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->set_position) + return -ENOTSUP; + return g_uwb_funcs->set_position(node_id, x, y, z); } @@ -163,6 +207,10 @@ int hal_uwb_get_own_node(uwb_hal_node_s **own_node) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->get_own_node) + return -ENOTSUP; + return g_uwb_funcs->get_own_node(own_node); } @@ -171,6 +219,10 @@ int hal_uwb_send_message(const unsigned char *message, int message_length) { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->send_message) + return -ENOTSUP; + return g_uwb_funcs->send_message(message, message_length); } @@ -179,5 +231,9 @@ int hal_uwb_send_message_to(uint16_t node_id, const unsigned char *message, int { if (!g_uwb_funcs) return -ENOTSUP; + + if (!g_uwb_funcs->send_message_to) + return -ENOTSUP; + return g_uwb_funcs->send_message_to(node_id, message, message_length); } -- 2.7.4