summaryrefslogtreecommitdiffstats
path: root/plugin/wrap_unicens.c
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2018-10-15 14:22:58 +0200
committerTobias Jahnke <tobias.jahnke@microchip.com>2018-12-18 13:01:13 +0100
commit2fac61e232dbdc5135345a07b19a66a5ebb2a015 (patch)
tree80d00b70d6adfa38a24829908f48fa8ad08df161 /plugin/wrap_unicens.c
parent3798969ce5771058d9526e2b3cbfec2c74e23fed (diff)
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 <tobias.jahnke@microchip.com>
Diffstat (limited to 'plugin/wrap_unicens.c')
-rw-r--r--plugin/wrap_unicens.c40
1 files changed, 39 insertions, 1 deletions
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;
}
+