+
+/* parse array or single command */
+PUBLIC void ucs2_writei2c (afb_req_t request) {
+
+ struct json_object *j_obj;
+
+ j_obj = ucs2_validate_command(request, "writei2c");
+
+ if (j_obj) {
+ ucs2_writei2c_cmd(request, j_obj);
+ }
+}
+
+PUBLIC void ucs2_sendmessage(afb_req_t req) {
+ uint8_t *data_ptr = NULL;
+ size_t data_sz = 0;
+ int ret, node_addr, msg_id = 0;
+ struct json_object *j_obj;
+
+ j_obj = ucs2_validate_command(req, "sendmessageb64");
+
+ if (!j_obj) {
+ AFB_API_NOTICE(afbBindingRoot, "validation of command failed");
+ goto OnErrorExit;
+ }
+
+ ret = wrap_json_unpack(j_obj, "{s:i, s:i, s?Y}", "node", &node_addr, "msgid", &msg_id, "data", &data_ptr, &data_sz);
+
+ if ((ret==0) &&
+ UCSI_SendAmsMessage(&ucsContextS->ucsiData, msg_id, node_addr, &data_ptr[0], data_sz)
+ ) {
+ afb_req_reply(req, NULL, NULL, "sendmessageb64 started successful");
+ }
+ else {
+ AFB_API_ERROR(afbBindingRoot, "sendmessageb64: scheduling command failed. ret: %d", ret);
+ afb_req_reply(req, NULL, "query-command-queue","ambiguous command or queue overload");
+ goto OnErrorExit;
+ }
+
+OnErrorExit:
+ if (data_ptr) {
+ free(data_ptr);
+ }
+ return;
+}
+
+PUBLIC int ucs2_initbinding(afb_api_t api) {
+#ifndef DISABLE_AUTOSTART
+ char *filename = GetDefaultConfig();
+ if (filename != NULL) {
+
+ AFB_API_NOTICE(afbBindingRoot, "AUTO-LOAD configuration: %s", filename);
+ if (StartConfiguration(filename) == 0) {
+ AFB_API_NOTICE(afbBindingRoot, "AUTO-LOAD successful");
+ } else {
+ AFB_API_NOTICE(afbBindingRoot, "AUTO-LOAD failed");
+ }
+ free(filename);
+ }
+#endif
+ return 0;
+}