aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-afb
diff options
context:
space:
mode:
Diffstat (limited to 'ucs2-afb')
-rw-r--r--ucs2-afb/CMakeLists.txt28
-rw-r--r--ucs2-afb/ucs_apidef.h98
-rw-r--r--ucs2-afb/ucs_apidef.json56
-rw-r--r--ucs2-afb/ucs_apihat.c55
-rw-r--r--ucs2-afb/ucs_apihat.h48
-rw-r--r--ucs2-afb/ucs_binding.c92
-rw-r--r--ucs2-afb/ucs_binding.h9
7 files changed, 253 insertions, 133 deletions
diff --git a/ucs2-afb/CMakeLists.txt b/ucs2-afb/CMakeLists.txt
index ee5099e..9bac628 100644
--- a/ucs2-afb/CMakeLists.txt
+++ b/ucs2-afb/CMakeLists.txt
@@ -16,28 +16,44 @@
# limitations under the License.
###########################################################################
+
+# Generate API-v2 hat from OpenAPI json definition
+macro(SET_TARGET_GENSKEL TARGET_NAME API_DEF_NAME)
+ add_custom_command(OUTPUT ${API_DEF_NAME}.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${API_DEF_NAME}.json
+ COMMAND afb-genskel ${API_DEF_NAME}.json >${API_DEF_NAME}.h
+ )
+ add_custom_target(${API_DEF_NAME}_OPENAPI DEPENDS ${API_DEF_NAME}.h)
+ add_dependencies(${TARGET_NAME} ${API_DEF_NAME}_OPENAPI)
+
+endmacro(SET_TARGET_GENSKEL)
+
# Add target to project dependency list
-PROJECT_TARGET_ADD(ucs2)
+PROJECT_TARGET_ADD(ucs2-afb)
# Define project Targets
- ADD_LIBRARY(ucs2 MODULE ucs_binding.c ucs_apihat.c)
+ ADD_LIBRARY(${TARGET_NAME} MODULE ucs_apihat.c ucs_binding.c )
+
+ # Generate API-v2 hat from OpenAPI json definition
+ SET_TARGET_GENSKEL(${TARGET_NAME} ucs_apidef)
# Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(ucs2 PROPERTIES
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
LABELS "BINDING"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
+ OUTPUT_NAME ucs2
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(ucs2
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
ucs2-inter
${link_libraries}
)
# installation directory
- INSTALL(TARGETS ucs2
+ INSTALL(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR})
diff --git a/ucs2-afb/ucs_apidef.h b/ucs2-afb/ucs_apidef.h
new file mode 100644
index 0000000..c23f066
--- /dev/null
+++ b/ucs2-afb/ucs_apidef.h
@@ -0,0 +1,98 @@
+
+static const char _afb_description_v2_UNICENS[] =
+ "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/schem"
+ "a-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\"u"
+ "cs2\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"UNICENS\""
+ ",\"version\":2,\"prefix\":\"ucs2_\",\"postfix\":\"\",\"start\":null,\"on"
+ "event\":null,\"init\":null,\"scope\":\"\",\"private\":false}},\"servers\""
+ ":[{\"url\":\"ws://{host}:{port}/api/monitor\",\"description\":\"Unicens2"
+ " API.\",\"variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\""
+ "default\":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/"
+ "afb-event\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#"
+ "/components/schemas/afb-reply-v2\"},\"afb-event\":{\"$ref\":\"#/componen"
+ "ts/schemas/afb-event-v2\"},\"afb-reply-v2\":{\"title\":\"Generic respons"
+ "e.\",\"type\":\"object\",\"required\":[\"jtype\",\"request\"],\"properti"
+ "es\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-reply\"},\"request\""
+ ":{\"type\":\"object\",\"required\":[\"status\"],\"properties\":{\"status"
+ "\":{\"type\":\"string\"},\"info\":{\"type\":\"string\"},\"token\":{\"typ"
+ "e\":\"string\"},\"uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"str"
+ "ing\"}}},\"response\":{\"type\":\"object\"}}},\"afb-event-v2\":{\"type\""
+ ":\"object\",\"required\":[\"jtype\",\"event\"],\"properties\":{\"jtype\""
+ ":{\"type\":\"string\",\"const\":\"afb-event\"},\"event\":{\"type\":\"str"
+ "ing\"},\"data\":{\"type\":\"object\"}}}},\"x-permissions\":{\"config\":{"
+ "\"permission\":\"urn:AGL:permission:UNICENS:public:initialise\"},\"monit"
+ "or\":{\"permission\":\"urn:AGL:permission:UNICENS:public:monitor\"}},\"r"
+ "esponses\":{\"200\":{\"description\":\"A complex object array response\""
+ ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/"
+ "schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"description\":\""
+ "List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/"
+ "x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"name\":\"cfg"
+ "path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"responses"
+ "\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/initialise\""
+ ":{\"description\":\"configure Unicens2 lib from NetworkConfig.XML.\",\"g"
+ "et\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"}"
+ ",\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":tr"
+ "ue,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\""
+ "#/components/responses/200\"}}}},\"/volume\":{\"description\":\"Set Mast"
+ "er Volume.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permi"
+ "ssions/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"value\",\""
+ "required\":true,\"schema\":{\"type\":\"integer\"}}],\"responses\":{\"200"
+ "\":{\"$ref\":\"#/components/responses/200\"}}}},\"/monitor\":{\"descript"
+ "ion\":\"Subscribe to Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref"
+ "\":\"#/components/x-permissions/monitor\"},\"responses\":{\"200\":{\"$re"
+ "f\":\"#/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" }
+};
+
+ void ucs2_listconfig(struct afb_req req);
+ void ucs2_initialise(struct afb_req req);
+ void ucs2_volume(struct afb_req req);
+ void ucs2_monitor(struct afb_req req);
+
+static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
+ {
+ .verb = "listconfig",
+ .callback = ucs2_listconfig,
+ .auth = &_afb_auths_v2_UNICENS[0],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "initialise",
+ .callback = ucs2_initialise,
+ .auth = &_afb_auths_v2_UNICENS[0],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "volume",
+ .callback = ucs2_volume,
+ .auth = &_afb_auths_v2_UNICENS[1],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "monitor",
+ .callback = ucs2_monitor,
+ .auth = &_afb_auths_v2_UNICENS[1],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ { .verb = NULL }
+};
+
+const struct afb_binding_v2 afbBindingV2 = {
+ .api = "UNICENS",
+ .specification = _afb_description_v2_UNICENS,
+ .info = NULL,
+ .verbs = _afb_verbs_v2_UNICENS,
+ .preinit = NULL,
+ .init = NULL,
+ .onevent = NULL,
+ .noconcurrency = 0
+};
+
diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json
index 5aa33a2..c200f74 100644
--- a/ucs2-afb/ucs_apidef.json
+++ b/ucs2-afb/ucs_apidef.json
@@ -1,6 +1,6 @@
{
"openapi": "3.0.0",
- "$schema": "file:///home/fulup/Workspace/AGL-AppFW/unicens2rc-afb/etc/openapi-schema.json",
+ "$schema": "http:iot.bzh/download/openapi/schema-3.0/default-schema.json",
"info": {
"description": "",
"title": "ucs2",
@@ -13,8 +13,8 @@
"start": null ,
"onevent": null,
"init": null,
- "scope": "static",
- "private": true
+ "scope": "",
+ "private": false
}
},
"servers": [
@@ -39,12 +39,12 @@
"components": {
"schemas": {
"afb-reply": {
- "$ref": "#/components/schemas/afb-reply-v1"
+ "$ref": "#/components/schemas/afb-reply-v2"
},
"afb-event": {
- "$ref": "#/components/schemas/afb-event-v1"
+ "$ref": "#/components/schemas/afb-event-v2"
},
- "afb-reply-v1": {
+ "afb-reply-v2": {
"title": "Generic response.",
"type": "object",
"required": [ "jtype", "request" ],
@@ -67,7 +67,7 @@
"response": { "type": "object" }
}
},
- "afb-event-v1": {
+ "afb-event-v2": {
"type": "object",
"required": [ "jtype", "event" ],
"properties": {
@@ -102,8 +102,27 @@
}
},
"paths": {
+ "/listconfig": {
+ "description": "List Config Files",
+ "get": {
+ "x-permissions": {
+ "$ref": "#/components/x-permissions/config"
+ },
+ "parameters": [
+ {
+ "in": "query",
+ "name": "cfgpath",
+ "required": false,
+ "schema": { "type": "string" }
+ }
+ ],
+ "responses": {
+ "200": {"$ref": "#/components/responses/200"}
+ }
+ }
+ },
"/initialise": {
- "description": "Initialise Unicens2 lib from NetworkConfig.XML.",
+ "description": "configure Unicens2 lib from NetworkConfig.XML.",
"get": {
"x-permissions": {
"$ref": "#/components/x-permissions/config"
@@ -121,8 +140,27 @@
}
}
},
+ "/volume": {
+ "description": "Set Master Volume.",
+ "get": {
+ "x-permissions": {
+ "$ref": "#/components/x-permissions/monitor"
+ },
+ "parameters": [
+ {
+ "in": "query",
+ "name": "value",
+ "required": true,
+ "schema": { "type": "integer" }
+ }
+ ],
+ "responses": {
+ "200": {"$ref": "#/components/responses/200"}
+ }
+ }
+ },
"/monitor": {
- "description": "Subscribe to Unicens2 Events.",
+ "description": "Subscribe to Unicens Event.",
"get": {
"x-permissions": {
"$ref": "#/components/x-permissions/monitor"
diff --git a/ucs2-afb/ucs_apihat.c b/ucs2-afb/ucs_apihat.c
index fd5d88f..9a6abd9 100644
--- a/ucs2-afb/ucs_apihat.c
+++ b/ucs2-afb/ucs_apihat.c
@@ -16,59 +16,8 @@
*/
#define _GNU_SOURCE
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <math.h>
-#include <sys/time.h>
-#include <sys/types.h>
#include "ucs_binding.h"
-const struct afb_binding_interface *afbIface;
-struct afb_service afbSrv;
-
-/*
- * array of the verbs exported to afb-daemon
- */
-static const struct afb_verb_desc_v1 binding_verbs[] = {
- /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */
- { .name= "initialise", .session= AFB_SESSION_NONE, .callback= ucs2Init, .info= "Parse XML & initialise Unicens " },
- { .name= "setvol" , .session= AFB_SESSION_NONE, .callback= ucs2SetVol, .info= "Set Volume" },
- // { .name= "monitor" , .session= AFB_SESSION_NONE, .callback= ucs2Monitor, .info= "Subscribe to network error" },
-
-
- { .name= NULL } /* marker for end of the array */
-};
-
-/*
- * description of the binding for afb-daemon
- */
-static const struct afb_binding binding_description = {
- /* description conforms to VERSION 1 */
- .type= AFB_BINDING_VERSION_1,
- .v1= {
- .prefix= "UNICENS",
- .info= "UNICENS MOST Control API",
- .verbs = binding_verbs
- }
-};
-
-// this is call when after all bindings are loaded
- int afbBindingV1ServiceInit(struct afb_service service) {
- afbSrv = service;
- return (0);
-}
-
-/*
- * activation function for registering the binding called by afb-daemon
- */
- const struct afb_binding *afbBindingV1Register(const struct afb_binding_interface *itf) {
- afbIface= itf;
-
- return &binding_description; /* returns the description of the binding */
-}
-
+// include code generated from afb-genskel
+#include "ucs_apidef.h"
diff --git a/ucs2-afb/ucs_apihat.h b/ucs2-afb/ucs_apihat.h
deleted file mode 100644
index 8926344..0000000
--- a/ucs2-afb/ucs_apihat.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * AlsaLibMapping -- provide low level interface with AUDIO lib (extracted from alsa-json-gateway code)
- * Copyright (C) 2015,2016,2017, Fulup Ar Foll fulup@iot.bzh
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UCS2BINDING_H
-#define UCS2BINDING_H
-
-#ifndef PUBLIC
- #define PUBLIC
-#endif
-#define STATIC static
-
-#include <json-c/json.h>
-#include <afb/afb-binding.h>
-#include <afb/afb-service-itf.h>
-
-#include "ucs_interface.h"
-
-#ifndef CONTROL_CDEV_TX
-#error FATAL: CONTROL_CDEV_TX missing (check ./etc/config.cmake + rerun cmake)
-#endif
-#ifndef CONTROL_CDEV_RX
-#error FATAL: CONTROL_CDEV_RX missing (check ./etc/config.cmake + rerun cmake)
-#endif
-
-// import from AlsaAfbBinding
-extern const struct afb_binding_interface *afbIface;
-extern struct afb_service afbSrv;
-
-// API verbs prototype
-PUBLIC void initUcs2 (struct afb_req request);
-
-
-#endif /* UCS2BINDING_H */
-
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index 59e1532..c0a9fcf 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -34,6 +34,7 @@
#include <time.h>
#include <assert.h>
#include <errno.h>
+#include <dirent.h>
#include "ucs_binding.h"
#include "ucs_interface.h"
@@ -65,11 +66,18 @@ typedef struct {
static ucsContextT *ucsContextS;
PUBLIC void UcsXml_CB_OnError(const char format[], uint16_t vargsCnt, ...) {
- /*DEBUG (afbIface, format, args); */
+ /*AFB_DEBUG (afbIface, format, args); */
va_list args;
va_start (args, vargsCnt);
vfprintf (stderr, format, args);
va_end(args);
+
+ va_list argptr;
+ char outbuf[300];
+ va_start(argptr, vargsCnt);
+ vsprintf(outbuf, format, argptr);
+ va_end(argptr);
+ AFB_WARNING (outbuf);
}
PUBLIC uint16_t UCSI_CB_OnGetTime(void *pTag) {
@@ -99,8 +107,8 @@ STATIC int onTimerCB (sd_event_source* source,uint64_t timer, void* pTag) {
PUBLIC void UCSI_CB_OnSetServiceTimer(void *pTag, uint16_t timeout) {
uint64_t usec;
/* set a timer with 250ms accuracy */
- sd_event_now(afb_daemon_get_event_loop(afbIface->daemon), CLOCK_BOOTTIME, &usec);
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, onTimerCB, pTag);
+ sd_event_now(afb_daemon_get_event_loop(), CLOCK_BOOTTIME, &usec);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, onTimerCB, pTag);
}
@@ -121,7 +129,7 @@ void UCSI_CB_OnUserMessage(void *pTag, bool isError, const char format[],
vsprintf(outbuf, format, argptr);
va_end(argptr);
if (isError)
- NOTICE (afbIface, outbuf);
+ AFB_NOTICE (outbuf);
}
/** UCSI_Service cannot be called directly within UNICENS context, need to service stack through mainloop */
@@ -137,7 +145,7 @@ STATIC int OnServiceRequiredCB (sd_event_source *source, uint64_t usec, void *pT
PUBLIC void UCSI_CB_OnServiceRequired(void *pTag) {
/* push an asynchronous request for loopback to call UCSI_Service */
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, 0, 0, OnServiceRequiredCB, pTag);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, 0, 0, OnServiceRequiredCB, pTag);
}
/* Callback when ever this UNICENS wants to send a message to INIC. */
@@ -173,7 +181,7 @@ PUBLIC void UCSI_CB_OnTxRequest(void *pTag, const uint8_t *pData, uint32_t len)
* \param pTag - Pointer given by the integrator by UCSI_Init
*/
void UCSI_CB_OnStop(void *pTag) {
- NOTICE (afbIface, "UNICENS stopped");
+ AFB_NOTICE ("UNICENS stopped");
}
@@ -239,7 +247,7 @@ int onReadCB (sd_event_source* src, int fileFd, uint32_t revents, void* pTag) {
return 0;
ok= UCSI_ProcessRxData(&ucsContext->ucsiData, pBuffer, (uint16_t)len);
if (!ok) {
- DEBUG (afbIface, "Buffer overrun (not handle)");
+ AFB_DEBUG ("Buffer overrun (not handle)");
/* Buffer overrun could replay pBuffer */
}
return 0;
@@ -272,7 +280,7 @@ STATIC UcsXmlVal_t* ParseFile(struct afb_req request) {
xmlBuffer[readSize] = '\0'; /* In any case, terminate it. */
if (readSize != fdStat.st_size) {
- afb_req_fail_f (request, "fileread-fail", "File to read fullfile '%s' size(%d!=%d)", filename, readSize, fdStat.st_size);
+ afb_req_fail_f (request, "fileread-fail", "File to read fullfile '%s' size(%d!=%d)", filename, (int)readSize, (int)fdStat.st_size);
goto OnErrorExit;
}
@@ -300,8 +308,8 @@ STATIC int volOnSvcCB (sd_event_source* source,uint64_t timer, void* pTag) {
/* This callback is fire each time an volume event wait in the queue */
void volumeCB (uint16_t timeout) {
uint64_t usec;
- sd_event_now(afb_daemon_get_event_loop(afbIface->daemon), CLOCK_BOOTTIME, &usec);
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, volOnSvcCB, ucsContextS);
+ sd_event_now(afb_daemon_get_event_loop(), CLOCK_BOOTTIME, &usec);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, volOnSvcCB, ucsContextS);
}
STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsContextT *ucsContext) {
@@ -380,8 +388,7 @@ STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsC
return 1;
}
-
-PUBLIC void ucs2SetVol (struct afb_req request) {
+PUBLIC void ucs2_volume (struct afb_req request) {
struct json_object *queryJ;
int err;
@@ -424,7 +431,7 @@ PUBLIC void ucs2SetVol (struct afb_req request) {
}
-PUBLIC void ucs2Init (struct afb_req request) {
+PUBLIC void ucs2_initialise (struct afb_req request) {
static UcsXmlVal_t *ucsConfig;
static ucsContextT ucsContext;
@@ -447,7 +454,7 @@ PUBLIC void ucs2Init (struct afb_req request) {
UCSI_Init(&ucsContext.ucsiData, &ucsContext);
/* register aplayHandle file fd into binder mainloop */
- err = sd_event_add_io(afb_daemon_get_event_loop(afbIface->daemon), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
+ err = sd_event_add_io(afb_daemon_get_event_loop(), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
if (err < 0) {
afb_req_fail_f (request, "register-mainloop", "Cannot hook events to mainloop");
goto OnErrorExit;
@@ -473,3 +480,60 @@ PUBLIC void ucs2Init (struct afb_req request) {
OnErrorExit:
return;
}
+
+
+// List Avaliable Configuration Files
+PUBLIC void ucs2_listconfig (struct afb_req request) {
+ struct json_object *queryJ, *tmpJ, *responseJ;
+ DIR *dirHandle;
+ char *dirPath, *dirList;
+ int error=0;
+
+ queryJ = afb_req_json(request);
+ if (queryJ && json_object_object_get_ex (queryJ, "cfgpath" , &tmpJ)) {
+ strdup (json_object_get_string(tmpJ));
+ } else {
+ dirList = strdup (UCS2_CFG_PATH);
+ AFB_NOTICE ("fgpath:missing uses UCS2_CFG_PATH=%s", UCS2_CFG_PATH);
+ }
+
+ responseJ = json_object_new_array();
+ for (dirPath= strtok(dirList, ":"); dirPath && *dirPath; dirPath=strtok(NULL,":")) {
+ struct dirent *dirEnt;
+
+ dirHandle = opendir (dirPath);
+ if (!dirHandle) {
+ AFB_NOTICE ("ucs2_listconfig dir=%s not readable", dirPath);
+ error++;
+ continue;
+ }
+
+ AFB_NOTICE ("ucs2_listconfig scanning: %s", dirPath);
+ while ((dirEnt = readdir(dirHandle)) != NULL) {
+ // Unknown type is accepted to support dump filesystems
+ if (dirEnt->d_type == DT_REG || dirEnt->d_type == DT_UNKNOWN) {
+ struct json_object *pathJ = json_object_new_object();
+ json_object_object_add(pathJ, "dirpath", json_object_new_string(dirPath));
+ json_object_object_add(pathJ, "basename", json_object_new_string(dirEnt->d_name));
+ json_object_array_add(responseJ, pathJ);
+ }
+ }
+ }
+
+ free (dirList);
+
+ if (!error) afb_req_success(request,responseJ,NULL);
+ else {
+ char info[40];
+ snprintf (info, sizeof(info), "[%d] where not scanned", error);
+ afb_req_success(request,responseJ, info);
+ }
+
+ return;
+}
+
+PUBLIC void ucs2_monitor (struct afb_req request) {
+
+ afb_req_success(request,NULL,"UNICENS-to_be_done");
+}
+
diff --git a/ucs2-afb/ucs_binding.h b/ucs2-afb/ucs_binding.h
index 5b74730..4265762 100644
--- a/ucs2-afb/ucs_binding.h
+++ b/ucs2-afb/ucs_binding.h
@@ -18,6 +18,9 @@
#ifndef UCS2BINDING_H
#define UCS2BINDING_H
+// Use Version of AGL Application Framework API
+#define AFB_BINDING_VERSION 2
+
#ifndef PUBLIC
#define PUBLIC
#endif
@@ -25,7 +28,6 @@
#include <json-c/json.h>
#include <afb/afb-binding.h>
-#include <afb/afb-service-itf.h>
#include "ucs_interface.h"
@@ -41,8 +43,9 @@ extern const struct afb_binding_interface *afbIface;
extern struct afb_service afbSrv;
// API verbs prototype
-PUBLIC void ucs2Init (struct afb_req request);
-PUBLIC void ucs2SetVol (struct afb_req request);
+PUBLIC void ucs2_configure (struct afb_req request);
+PUBLIC void ucs2_volume (struct afb_req request);
+PUBLIC void ucs2_monitor (struct afb_req request);
#endif /* UCS2BINDING_H */