X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=ucs2-afb%2Fucs_binding.c;h=c0a9fcf4f6a6b9d7749d18374c7026b0330ca811;hb=4d190f69cc90143c4de1b0d474cbf552fa165b78;hp=efb492825bbc367b8182d55b3fe202216bf4f86f;hpb=df80e736893306194e657b068d75096a3f142d54;p=apps%2Fagl-service-unicens.git diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c index efb4928..c0a9fcf 100644 --- a/ucs2-afb/ucs_binding.c +++ b/ucs2-afb/ucs_binding.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "ucs_binding.h" #include "ucs_interface.h" @@ -192,6 +193,14 @@ void UCSI_CB_OnAmsMessageReceived(void *pTag) Don't forget to call UCSI_ReleaseAmsMessage after that */ } +void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive) +{ +} + +void UCSI_CB_OnGpioStateChange(void *pTag, uint16_t nodeAddress, uint8_t gpioPinId, bool isHighState) +{ +} + bool Cdev_Init(CdevData_t *d, const char *fileName, bool read, bool write) { if (NULL == d || NULL == fileName) goto OnErrorExit; @@ -379,7 +388,6 @@ STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsC return 1; } - PUBLIC void ucs2_volume (struct afb_req request) { struct json_object *queryJ; int err; @@ -423,7 +431,7 @@ PUBLIC void ucs2_volume (struct afb_req request) { } -PUBLIC void ucs2_configure (struct afb_req request) { +PUBLIC void ucs2_initialise (struct afb_req request) { static UcsXmlVal_t *ucsConfig; static ucsContextT ucsContext; @@ -473,7 +481,59 @@ PUBLIC void ucs2_configure (struct afb_req request) { 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"); -} \ No newline at end of file +} +