Update Installation Documentation
[apps/agl-service-unicens.git] / ucs2-afb / ucs_apihat.c
1 /*
2  * Copyright (C) 2016 "IoT.bzh"
3  * Author Fulup Ar Foll <fulup@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #define _GNU_SOURCE
19 #include <stdio.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <errno.h>
23 #include <netdb.h>
24 #include <fcntl.h>
25 #include <math.h>
26 #include <sys/time.h>
27 #include <sys/types.h>
28
29 #include "ucs_binding.h"
30
31 const struct afb_binding_interface *afbIface;
32 struct afb_service afbSrv;
33
34 /*
35  * array of the verbs exported to afb-daemon
36  */
37 static const struct afb_verb_desc_v1 binding_verbs[] = {
38   /* VERB'S NAME            SESSION MANAGEMENT          FUNCTION TO CALL         SHORT DESCRIPTION */
39   { .name= "initialise", .session= AFB_SESSION_NONE,  .callback= ucs2Init,      .info= "Parse XML & initialise Unicens " },
40   { .name= "setvol"    , .session= AFB_SESSION_NONE,  .callback= ucs2SetVol,    .info= "Set Volume" },
41  //  { .name= "monitor"   , .session= AFB_SESSION_NONE,  .callback= ucs2Monitor,   .info= "Subscribe to network error" },
42
43
44   { .name= NULL } /* marker for end of the array */
45 };
46
47 /*
48  * description of the binding for afb-daemon
49  */
50 static const struct afb_binding binding_description = {
51   /* description conforms to VERSION 1 */
52   .type= AFB_BINDING_VERSION_1,
53   .v1= {
54     .prefix= "UNICENS",
55     .info= "UNICENS MOST Control API",
56     .verbs = binding_verbs
57   }
58 };
59
60 // this is call when after all bindings are loaded
61  int afbBindingV1ServiceInit(struct afb_service service) {
62    afbSrv =  service;
63    return (0);
64 }
65
66 /*
67  * activation function for registering the binding called by afb-daemon
68  */
69  const struct afb_binding *afbBindingV1Register(const struct afb_binding_interface *itf) {
70     afbIface= itf;
71
72     return &binding_description;        /* returns the description of the binding */
73 }
74