aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Jahnke <tobias.jahnke@microchip.com>2018-05-07 16:07:17 +0200
committerWalt Miner <walt@linux.com>2018-06-08 11:56:36 +0000
commit2c74cc419677a6470f537a2a374a3b31fee5da07 (patch)
tree0c140493100e49499506ff506f1f877ab4e5d238
parent3285a51b4d6b6d5e8aeba1f3dda76806f931a6b9 (diff)
agl-service-unicens: prepare control message transmission in b64 format
Bug-AGL: SPEC-1177 Add new verb sendmessageb64. Change-Id: I4f7c67141ede4e5c5d5f60acb4dd93ca4b46c271 Signed-off-by: Tobias Jahnke <tobias.jahnke@microchip.com> (cherry picked from commit 84c3e1b169038e181526b4fbadab3d8f9322717c)
-rw-r--r--htdocs/UNICENS.html3
-rw-r--r--ucs2-afb/ucs_apidef.h81
-rw-r--r--ucs2-afb/ucs_apidef.json44
-rw-r--r--ucs2-afb/ucs_binding.c4
4 files changed, 101 insertions, 31 deletions
diff --git a/htdocs/UNICENS.html b/htdocs/UNICENS.html
index e2505ae..bc01401 100644
--- a/htdocs/UNICENS.html
+++ b/htdocs/UNICENS.html
@@ -40,6 +40,9 @@
<ol>
<li><button onclick="callbinder('UNICENS','sendmessage', {node: 0x270, msgid: 0x5AC4, data:[0x01,0x02,0xFF]})">Send ControlMsg to 0x270</button></li>
</ol>
+ <ol>
+ <li><button onclick="callbinder('UNICENS','sendmessageb64', {node: 0x270, msgid: 0x5AC4, data:'ESIzRA=='})">Send ControlMsgB64 to 0x270</button></li>
+ </ol>
<br>
<br>
<div id="main" style="visibility:hidden">
diff --git a/ucs2-afb/ucs_apidef.h b/ucs2-afb/ucs_apidef.h
index 2323599..6b8c23a 100644
--- a/ucs2-afb/ucs_apidef.h
+++ b/ucs2-afb/ucs_apidef.h
@@ -22,44 +22,55 @@ static const char _afb_description_v2_UNICENS[] =
"event\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\"object\"}}"
"}},\"x-permissions\":{\"config\":{\"permission\":\"urn:AGL:permission:UN"
"ICENS:public:initialise\"},\"monitor\":{\"permission\":\"urn:AGL:permiss"
- "ion:UNICENS:public:monitor\"}},\"responses\":{\"200\":{\"description\":\""
- "A complex object array response\",\"content\":{\"application/json\":{\"s"
- "chema\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}},\"paths\":{\""
- "/listconfig\":{\"description\":\"List Config Files\",\"get\":{\"x-permis"
- "sions\":{\"$ref\":\"#/components/x-permissions/config\"},\"parameters\":"
- "[{\"in\":\"query\",\"name\":\"cfgpath\",\"required\":false,\"schema\":{\""
- "type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/res"
- "ponses/200\"}}}},\"/initialise\":{\"description\":\"configure Unicens2 l"
- "ib from NetworkConfig.XML.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/co"
- "mponents/x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"nam"
- "e\":\"filename\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\""
- "responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/sub"
- "scribe\":{\"description\":\"Subscribe to network events.\",\"get\":{\"x-"
- "permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"respon"
- "ses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/subscribe"
- "rx\":{\"description\":\"Subscribe to Rx control message events.\",\"get\""
- ":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\""
- "responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/wri"
- "tei2c\":{\"description\":\"Writes I2C command to remote node.\",\"get\":"
- "{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"p"
- "arameters\":[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"sch"
- "ema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"n"
- "ame\":\"data\",\"required\":true,\"schema\":{\"type\":\"array\",\"format"
- "\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{\"$ref\":\""
- "#/components/responses/200\"}}}},\"/sendmessage\":{\"description\":\"Tra"
- "nsmits a control message to a node.\",\"get\":{\"x-permissions\":{\"$ref"
- "\":\"#/components/x-permissions/monitor\"},\"parameters\":[{\"in\":\"que"
- "ry\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":\"integer\""
- ",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\",\"required\""
+ "ion:UNICENS:public:monitor\"},\"controller\":{\"permission\":\"urn:AGL:p"
+ "ermission:UNICENS:public:controller\"}},\"responses\":{\"200\":{\"descri"
+ "ption\":\"A complex object array response\",\"content\":{\"application/j"
+ "son\":{\"schema\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}},\"p"
+ "aths\":{\"/listconfig\":{\"description\":\"List Config Files\",\"get\":{"
+ "\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"},\"par"
+ "ameters\":[{\"in\":\"query\",\"name\":\"cfgpath\",\"required\":false,\"s"
+ "chema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/com"
+ "ponents/responses/200\"}}}},\"/initialise\":{\"description\":\"configure"
+ " Unicens2 lib from NetworkConfig.XML.\",\"get\":{\"x-permissions\":{\"$r"
+ "ef\":\"#/components/x-permissions/config\"},\"parameters\":[{\"in\":\"qu"
+ "ery\",\"name\":\"filename\",\"required\":true,\"schema\":{\"type\":\"str"
+ "ing\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\""
+ "}}}},\"/subscribe\":{\"description\":\"Subscribe to network events.\",\""
+ "get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\""
+ "},\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\""
+ "/subscriberx\":{\"description\":\"Subscribe to Rx control message events"
+ ".\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/mo"
+ "nitor\"},\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\""
+ "}}}},\"/writei2c\":{\"description\":\"Writes I2C command to remote node."
+ "\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/mon"
+ "itor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"node\",\"required\""
":true,\"schema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\""
"query\",\"name\":\"data\",\"required\":true,\"schema\":{\"type\":\"array"
"\",\"format\":\"int32\"},\"style\":\"simple\"}],\"responses\":{\"200\":{"
- "\"$ref\":\"#/components/responses/200\"}}}}}}"
+ "\"$ref\":\"#/components/responses/200\"}}}},\"/sendmessage\":{\"descript"
+ "ion\":\"Transmits a control message to a node.\",\"get\":{\"x-permission"
+ "s\":{\"$ref\":\"#/components/x-permissions/monitor\"},\"parameters\":[{\""
+ "in\":\"query\",\"name\":\"node\",\"required\":true,\"schema\":{\"type\":"
+ "\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"msgid\","
+ "\"required\":true,\"schema\":{\"type\":\"integer\",\"format\":\"int32\"}"
+ "},{\"in\":\"query\",\"name\":\"data\",\"required\":true,\"schema\":{\"ty"
+ "pe\":\"array\",\"format\":\"int32\"},\"style\":\"simple\"}],\"responses\""
+ ":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/sendmessageb64"
+ "\":{\"description\":\"Transmits a control message to a node.\",\"get\":{"
+ "\"x-permissions\":{\"$ref\":\"#/components/x-permissions/controller\"},\""
+ "parameters\":[{\"in\":\"query\",\"name\":\"node\",\"required\":true,\"sc"
+ "hema\":{\"type\":\"integer\",\"format\":\"int32\"}},{\"in\":\"query\",\""
+ "name\":\"msgid\",\"required\":true,\"schema\":{\"type\":\"integer\",\"fo"
+ "rmat\":\"int32\"}},{\"in\":\"query\",\"name\":\"data\",\"required\":fals"
+ "e,\"schema\":{\"type\":\"string\",\"format\":\"byte\"},\"style\":\"simpl"
+ "e\"}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}"
+ "}}}"
;
static const struct afb_auth _afb_auths_v2_UNICENS[] = {
{ .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
- { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
+ { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" },
+ { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:controller" }
};
void ucs2_listconfig(struct afb_req req);
@@ -68,6 +79,7 @@ static const struct afb_auth _afb_auths_v2_UNICENS[] = {
void ucs2_subscriberx(struct afb_req req);
void ucs2_writei2c(struct afb_req req);
void ucs2_sendmessage(struct afb_req req);
+ void ucs2_sendmessageb64(struct afb_req req);
static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
{
@@ -113,6 +125,13 @@ static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
.session = AFB_SESSION_NONE_V2
},
{
+ .verb = "sendmessageb64",
+ .callback = ucs2_sendmessageb64,
+ .auth = &_afb_auths_v2_UNICENS[2],
+ .info = "Transmits a control message to a node.",
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
.verb = NULL,
.callback = NULL,
.auth = NULL,
diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json
index 954e275..623d58e 100644
--- a/ucs2-afb/ucs_apidef.json
+++ b/ucs2-afb/ucs_apidef.json
@@ -87,6 +87,9 @@
},
"monitor": {
"permission": "urn:AGL:permission:UNICENS:public:monitor"
+ },
+ "controller": {
+ "permission": "urn:AGL:permission:UNICENS:public:controller"
}
},
"responses": {
@@ -235,6 +238,47 @@
"200": {"$ref": "#/components/responses/200"}
}
}
+ },
+ "/sendmessageb64": {
+ "description": "Transmits a control message to a node.",
+ "get": {
+ "x-permissions": {
+ "$ref": "#/components/x-permissions/controller"
+ },
+ "parameters": [
+ {
+ "in": "query",
+ "name": "node",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
+ }
+ },
+ {
+ "in": "query",
+ "name": "msgid",
+ "required": true,
+ "schema": {
+ "type": "integer",
+ "format": "int32"
+ }
+ },
+ {
+ "in": "query",
+ "name": "data",
+ "required": false,
+ "schema": {
+ "type": "string",
+ "format": "byte"
+ },
+ "style": "simple"
+ }
+ ],
+ "responses": {
+ "200": {"$ref": "#/components/responses/200"}
+ }
+ }
}
}
}
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index 553ed36..4f36576 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -857,6 +857,10 @@ PUBLIC void ucs2_sendmessage(struct afb_req request) {
}
}
+PUBLIC void ucs2_sendmessageb64(struct afb_req req) {
+ afb_req_fail_f(req, "not-implemented", "Function not yet implemented.");
+}
+
PUBLIC int ucs2_initbinding(void) {
#ifndef DISABLE_AUTOSTART
char *filename = GetDefaultConfig();