summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c77
-rw-r--r--README.md6
2 files changed, 38 insertions, 45 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 680863e..d4d1495 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -60,8 +60,7 @@ void HalMgrPing(AFB_ReqT request)
void HalMgrLoaded(AFB_ReqT request)
{
- int requestJsonErr = 0, requestOptionValue;
- uint64_t cpt, numberOfLoadedApi;
+ int requestJsonErr = 0, allHal = 0, verbose = 0;
char cardIdString[10];
@@ -83,8 +82,9 @@ void HalMgrLoaded(AFB_ReqT request)
return;
}
- numberOfLoadedApi = HalUtlGetNumberOfHalInList(&HalMgrGlobalData->first);
- if(! numberOfLoadedApi) {
+ currentHalData = HalMgrGlobalData->first;
+
+ if(! currentHalData) {
AFB_ReqSuccess(request, NULL, "No Hal Api loaded");
return;
}
@@ -95,48 +95,41 @@ void HalMgrLoaded(AFB_ReqT request)
return;
}
- currentHalData = HalMgrGlobalData->first;
-
requestJson = AFB_ReqJson(request);
- if(! requestJson) {
+ if(! requestJson)
AFB_ReqNotice(request, "%s: Can't get request json", __func__);
- }
- else {
- // Get request option
- requestJsonErr = wrap_json_unpack(requestJson, "{s:i}", "verbose", &requestOptionValue);
- }
-
- // 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}",
- "api", currentHalData->apiName,
- "status", (int) currentHalData->status,
- "sndcard", currentHalData->sndCardPath,
- "internal", (int) currentHalData->internal,
- "info", currentHalData->info ? currentHalData->info : "",
- "author", currentHalData->author ? currentHalData->author : "",
- "version", currentHalData->version ? currentHalData->version : "",
- "date", currentHalData->date ? currentHalData->date : "",
- "snd-dev-id", cardIdString);
- json_object_array_add(requestAnswer, apiObject);
-
- currentHalData = currentHalData->next;
+ else
+ requestJsonErr = wrap_json_unpack(requestJson, "{s?:b s?:b}", "all", &allHal, "verbose", &verbose);
+
+ while(currentHalData) {
+ if(allHal || currentHalData->status == HAL_STATUS_READY) {
+ // Case if request key is 'verbose' and value is bigger than 0
+ if(! requestJsonErr && verbose) {
+ 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}",
+ "api", currentHalData->apiName,
+ "status", (int) currentHalData->status,
+ "sndcard", currentHalData->sndCardPath,
+ "internal", (int) currentHalData->internal,
+ "info", currentHalData->info ? currentHalData->info : "",
+ "author", currentHalData->author ? currentHalData->author : "",
+ "version", currentHalData->version ? currentHalData->version : "",
+ "date", currentHalData->date ? currentHalData->date : "",
+ "snd-dev-id", cardIdString);
+ json_object_array_add(requestAnswer, apiObject);
+ }
+ // Case if request is empty or not handled
+ else {
+ json_object_array_add(requestAnswer, json_object_new_string(currentHalData->apiName));
+ }
}
- }
- // Case if request is empty or not handled
- else {
- for(cpt = 0; cpt < numberOfLoadedApi; cpt++) {
- json_object_array_add(requestAnswer, json_object_new_string(currentHalData->apiName));
- currentHalData = currentHalData->next;
- }
+ currentHalData = currentHalData->next;
}
AFB_ReqSuccess(request, requestAnswer, "Requested data");
diff --git a/README.md b/README.md
index 67eb682..6bb00af 100644
--- a/README.md
+++ b/README.md
@@ -173,15 +173,15 @@ Connect to your 4a binder using afb-client-demo
afb-client-demo ws://localhost:1234/api?token=
```
-### List the loaded hal
+### List the ready hal
-In the connected client, try to list the loaded hal:
+In the connected client, try to list the ready hal:
```4a-hal-manager loaded```
And now with more information:
-```4a-hal-manager loaded { "verbose" : 1 }```
+```4a-hal-manager loaded { "verbose" : true }```
### Play with an 'internal' hal (described in a json configuration file)