summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-manager
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-09 17:49:51 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:52:51 +0200
commit957ccad167159cecf6fa7e33c75ec9692ce6af29 (patch)
treeb9c64460c30d17891e558a04cd8154884558cefa /4a-hal/4a-hal-manager
parent14412fb98e96921c710407a1c336b628a449ebc5 (diff)
Add device id when hal metadata are asked
Add device id to response when hal metadata are asked (with verb 'loaded'). Also handle this metadata when an external hal is registered (verb 'loaded'). Change-Id: I25fafce13c8a215ed5991cfee2a399d8d6631c47 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-manager')
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index bea1eda..cdb50b7 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -64,6 +64,8 @@ void HalMgrLoaded(AFB_ReqT request)
int requestJsonErr, requestOptionValue;
uint64_t cpt, numberOfLoadedApi;
+ char cardIdString[10];
+
AFB_ApiT apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *currentHalData;
@@ -108,8 +110,13 @@ void HalMgrLoaded(AFB_ReqT request)
// Case if request key is 'verbose' and value is bigger than 0
if(! requestJsonErr && requestOptionValue > 0) {
for(cpt = 0; cpt < numberOfLoadedApi; cpt++) {
+ if(currentHalData->sndCardId >= 0)
+ snprintf(cardIdString, 6, "hw:%i", currentHalData->sndCardId);
+ else
+ snprintf(cardIdString, 10, "not-found");
+
wrap_json_pack(&apiObject,
- "{s:s s:i s:s s:i s:s s:s s:s s:s}",
+ "{s:s s:i s:s s:i s:s s:s s:s s:s s:s}",
"api", currentHalData->apiName,
"status", (int) currentHalData->status,
"sndcard", currentHalData->sndCardPath,
@@ -117,7 +124,8 @@ void HalMgrLoaded(AFB_ReqT request)
"info", currentHalData->info ? currentHalData->info : "",
"author", currentHalData->author ? currentHalData->author : "",
"version", currentHalData->version ? currentHalData->version : "",
- "date", currentHalData->date ? currentHalData->date : "");
+ "date", currentHalData->date ? currentHalData->date : "",
+ "snd-dev-id", cardIdString);
json_object_array_add(requestAnswer, apiObject);
currentHalData = currentHalData->next;
@@ -137,6 +145,8 @@ void HalMgrLoaded(AFB_ReqT request)
void HalMgrLoad(AFB_ReqT request)
{
+ int cardId = -1;
+
char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
AFB_ApiT apiHandle;
@@ -169,19 +179,18 @@ void HalMgrLoad(AFB_ReqT request)
}
if(wrap_json_unpack(apiReceviedMetadata,
- "{s:s s:s s?:s s?:s s?:s s?:s}",
+ "{s:s s:s s?:s s?:s s?:s s?:s s?:i}",
"api", &apiName,
"uid", &sndCardPath,
"info", &info,
"author", &author,
"version", &version,
- "date", &date)) {
+ "date", &date,
+ "snd-dev-id", &cardId)) {
AFB_ReqFail(request, "api_metadata", "Can't metadata of api to register");
return;
}
- // TBD JAI: try connect to the api to test if it really exists
-
addedHal = HalUtlAddHalApiToHalList(HalMgrGlobalData);
addedHal->internal = false;
@@ -203,7 +212,9 @@ void HalMgrLoad(AFB_ReqT request)
if(date)
addedHal->date = strdup(date);
- // TBD JAI: add subscription to this api status events
+ addedHal->sndCardId = cardId;
+
+ // TBD JAI: add subscription to this api status events, if subscription fails, remove hal from list
AFB_ReqSuccess(request, NULL, "Api successfully registered");
}