From 17aecba553cd2aa114e35f80589ef5d5372d4ea0 Mon Sep 17 00:00:00 2001 From: Tobias Jahnke Date: Mon, 15 Oct 2018 15:02:58 +0200 Subject: 4a-hal-unicens: Support Fiberdyne Amp Bug-AGL: SPEC-1758 Enables transmission of control messages to agl-service-unicens. Signed-off-by: Tobias Jahnke --- plugin/wrap_unicens.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'plugin') diff --git a/plugin/wrap_unicens.c b/plugin/wrap_unicens.c index 82d4cb4..382eea7 100644 --- a/plugin/wrap_unicens.c +++ b/plugin/wrap_unicens.c @@ -116,33 +116,31 @@ extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t int msgid = (int)msg_id; size_t data_size = (size_t)data_sz; - AFB_ApiNotice(unicensHalApiHandle, "--- HAL triggering send message ---"); - goto OnErrorExit; - - + AFB_ApiNotice(unicensHalApiHandle, "--- HAL triggering send message ---"); + /* skip data attribute if possible, wrap_json_unpack may fail to deal with * an empty Base64 string */ if (data_size > 0) wrap_json_pack(&j_query, "{s:i, s:i, s:Y}", "node", node, "msgid", msgid, "data", data_ptr, data_size); else wrap_json_pack(&j_query, "{s:i, s:i}", "node", node, "msgid", msgid); - + AFB_ApiNotice(unicensHalApiHandle, "wrap_ucs_sendmessage: jquery=%s", json_object_to_json_string(j_query)); - /* err = AFB_ServiceSync(unicensHalApiHandle, "UNICENS", "sendmessage", j_query, &j_response); */ + err = AFB_ServiceSync(unicensHalApiHandle, "UNICENS", "sendmessage", j_query, &j_response); - if (err) { - AFB_ERROR("Failed to call wrap_ucs_sendmessage"); - goto OnErrorExit; + if (err != 0) { + AFB_ApiError(unicensHalApiHandle, "Failed to call wrap_ucs_sendmessage ret=%d", err); } else { - AFB_INFO("Called wrap_ucs_sendmessage, res=%s", json_object_to_json_string(j_response)); - json_object_put(j_response); + AFB_ApiNotice(unicensHalApiHandle, "Called wrap_ucs_sendmessage, successful"); } - //j_query = NULL; + if (j_response != NULL) { + AFB_ApiNotice(unicensHalApiHandle, "wrap_ucs_sendmessage, response=%s", json_object_to_json_string(j_response)); + json_object_put(j_response); + } -OnErrorExit: return err; } -- cgit 1.2.3-korg