adds processing of data to i2c_write
[apps/agl-service-unicens.git] / ucs2-afb / ucs_apidef.h
1
2 static const char _afb_description_v2_UNICENS[] =
3     "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/schem"
4     "a-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\"u"
5     "cs2\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"UNICENS\""
6     ",\"version\":2,\"prefix\":\"ucs2_\",\"postfix\":\"\",\"start\":null,\"on"
7     "event\":null,\"init\":null,\"scope\":\"\",\"private\":false}},\"servers\""
8     ":[{\"url\":\"ws://{host}:{port}/api/monitor\",\"description\":\"Unicens2"
9     " API.\",\"variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\""
10     "default\":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/"
11     "afb-event\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#"
12     "/components/schemas/afb-reply-v2\"},\"afb-event\":{\"$ref\":\"#/componen"
13     "ts/schemas/afb-event-v2\"},\"afb-reply-v2\":{\"title\":\"Generic respons"
14     "e.\",\"type\":\"object\",\"required\":[\"jtype\",\"request\"],\"properti"
15     "es\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-reply\"},\"request\""
16     ":{\"type\":\"object\",\"required\":[\"status\"],\"properties\":{\"status"
17     "\":{\"type\":\"string\"},\"info\":{\"type\":\"string\"},\"token\":{\"typ"
18     "e\":\"string\"},\"uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"str"
19     "ing\"}}},\"response\":{\"type\":\"object\"}}},\"afb-event-v2\":{\"type\""
20     ":\"object\",\"required\":[\"jtype\",\"event\"],\"properties\":{\"jtype\""
21     ":{\"type\":\"string\",\"const\":\"afb-event\"},\"event\":{\"type\":\"str"
22     "ing\"},\"data\":{\"type\":\"object\"}}}},\"x-permissions\":{\"config\":{"
23     "\"permission\":\"urn:AGL:permission:UNICENS:public:initialise\"},\"monit"
24     "or\":{\"permission\":\"urn:AGL:permission:UNICENS:public:monitor\"}},\"r"
25     "esponses\":{\"200\":{\"description\":\"A complex object array response\""
26     ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/"
27     "schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"description\":\""
28     "List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/"
29     "x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"name\":\"cfg"
30     "path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"responses"
31     "\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/initialise\""
32     ":{\"description\":\"configure Unicens2 lib from NetworkConfig.XML.\",\"g"
33     "et\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"}"
34     ",\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":tr"
35     "ue,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\""
36     "#/components/responses/200\"}}}},\"/volume\":{\"description\":\"Set Mast"
37     "er Volume.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permi"
38     "ssions/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"value\",\""
39     "required\":true,\"schema\":{\"type\":\"integer\"}}],\"responses\":{\"200"
40     "\":{\"$ref\":\"#/components/responses/200\"}}}},\"/monitor\":{\"descript"
41     "ion\":\"Subscribe to Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref"
42     "\":\"#/components/x-permissions/monitor\"},\"responses\":{\"200\":{\"$re"
43     "f\":\"#/components/responses/200\"}}}},\"/write_i2c\":{\"description\":\""
44     "Writes I2C command to remote node.\",\"get\":{\"x-permissions\":{\"$ref\""
45     ":\"#/components/x-permissions/monitor\"},\"parameters\":[{\"in\":\"query"
46     "\",\"name\":\"node_address\",\"required\":true,\"schema\":{\"type\":\"in"
47     "teger\",\"format\":\"int32\"}},{\"in\":\"query\",\"name\":\"i2c_data\",\""
48     "required\":true,\"schema\":{\"type\":\"array\",\"format\":\"int32\"},\"s"
49     "tyle\":\"simple\"}],\"responses\":{\"200\":{\"$ref\":\"#/components/resp"
50     "onses/200\"}}}}}}"
51 ;
52
53 static const struct afb_auth _afb_auths_v2_UNICENS[] = {
54         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
55         { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
56 };
57
58  void ucs2_listconfig(struct afb_req req);
59  void ucs2_initialise(struct afb_req req);
60  void ucs2_volume(struct afb_req req);
61  void ucs2_monitor(struct afb_req req);
62  void ucs2_write_i2c(struct afb_req req);
63
64 static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
65     {
66         .verb = "listconfig",
67         .callback = ucs2_listconfig,
68         .auth = &_afb_auths_v2_UNICENS[0],
69         .info = NULL,
70         .session = AFB_SESSION_NONE_V2
71     },
72     {
73         .verb = "initialise",
74         .callback = ucs2_initialise,
75         .auth = &_afb_auths_v2_UNICENS[0],
76         .info = NULL,
77         .session = AFB_SESSION_NONE_V2
78     },
79     {
80         .verb = "volume",
81         .callback = ucs2_volume,
82         .auth = &_afb_auths_v2_UNICENS[1],
83         .info = NULL,
84         .session = AFB_SESSION_NONE_V2
85     },
86     {
87         .verb = "monitor",
88         .callback = ucs2_monitor,
89         .auth = &_afb_auths_v2_UNICENS[1],
90         .info = NULL,
91         .session = AFB_SESSION_NONE_V2
92     },
93     {
94         .verb = "write_i2c",
95         .callback = ucs2_write_i2c,
96         .auth = &_afb_auths_v2_UNICENS[1],
97         .info = NULL,
98         .session = AFB_SESSION_NONE_V2
99     },
100     { .verb = NULL }
101 };
102
103 const struct afb_binding_v2 afbBindingV2 = {
104     .api = "UNICENS",
105     .specification = _afb_description_v2_UNICENS,
106     .info = NULL,
107     .verbs = _afb_verbs_v2_UNICENS,
108     .preinit = NULL,
109     .init = NULL,
110     .onevent = NULL,
111     .noconcurrency = 0
112 };
113