From 799c911b3f94adc470a02c7ba5f2900ab3fcbee7 Mon Sep 17 00:00:00 2001 From: Tobias Jahnke Date: Mon, 15 Oct 2018 14:22:58 +0200 Subject: 4a-hal-unicens: prepare support for Fiberdyne Amp Bug-AGL: SPEC-1758 - updated VolumeLib to support ctrl messages - added master volume setup for amplifier node - known issue: message transmission is commented out due to wrap_json issue Signed-off-by: Tobias Jahnke --- plugin/wrap_unicens.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'plugin/wrap_unicens.c') diff --git a/plugin/wrap_unicens.c b/plugin/wrap_unicens.c index 1b9a913..82d4cb4 100644 --- a/plugin/wrap_unicens.c +++ b/plugin/wrap_unicens.c @@ -108,8 +108,45 @@ extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *da return 0; } -/* ---------------------------- ASYNCHRONOUS API ---------------------------- */ +extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz) { + + json_object *j_query, *j_response = NULL; + int err = 1; + int node = (int)src_addr; + int msgid = (int)msg_id; + size_t data_size = (size_t)data_sz; + + AFB_ApiNotice(unicensHalApiHandle, "--- HAL triggering send message ---"); + goto OnErrorExit; + + + /* 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); */ + + if (err) { + AFB_ERROR("Failed to call wrap_ucs_sendmessage"); + goto OnErrorExit; + } + else { + AFB_INFO("Called wrap_ucs_sendmessage, res=%s", json_object_to_json_string(j_response)); + json_object_put(j_response); + } + + //j_query = NULL; + +OnErrorExit: + return err; +} +/* ---------------------------- ASYNCHRONOUS API ---------------------------- */ static void wrap_ucs_i2cwrite_cb(void *closure, int status, struct json_object *j_result, AFB_ApiT apiHandle) { async_job_t *job_ptr; @@ -172,3 +209,4 @@ extern int wrap_ucs_i2cwrite(uint16_t node, AFB_ServiceCall(unicensHalApiHandle, "UNICENS", "writei2c", j_query, wrap_ucs_i2cwrite_cb, job_ptr); return 0; } + -- cgit 1.2.3-korg