summaryrefslogtreecommitdiffstats
path: root/MOST_UNICENS/wrap_unicens.c
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2018-10-10 15:52:57 +0200
committerTobias Jahnke <tobias.jahnke@microchip.com>2018-10-12 12:32:24 +0000
commit178a830b8ad85813b7bf0b271be79f3a8d3a6277 (patch)
tree8d31174db1ff79796c91588c2fc47fe1fbdad648 /MOST_UNICENS/wrap_unicens.c
parentf938776e3cdeba1375a866e12f66a5b9c4151627 (diff)
Bug-AGL: SPEC-1758 As preparation before introducing UNICENS 4a plugin: - Init volume library at first - Add fiberdyne master volume - Introduce commands sent by control messages - Removes outdated controls - Known issue: turn ALSA volume above "93" to hear some sound Change-Id: I591c6b109a51c9da602ad08514b67c2ec573e09c Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com>
Diffstat (limited to 'MOST_UNICENS/wrap_unicens.c')
-rw-r--r--MOST_UNICENS/wrap_unicens.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/MOST_UNICENS/wrap_unicens.c b/MOST_UNICENS/wrap_unicens.c
index 095a2fe..4b75780 100644
--- a/MOST_UNICENS/wrap_unicens.c
+++ b/MOST_UNICENS/wrap_unicens.c
@@ -334,3 +334,35 @@ OnErrorExit:
json_object_put(j_query);
return err;
}
+
+extern int wrap_ucs_sendmessage(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;
+ int node = (int)src_addr;
+ int msgid = (int)msg_id;
+ size_t data_size = (size_t)data_sz;
+
+ /* 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);
+
+ err = afb_service_call_sync("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;
+}