diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-06-11 20:49:01 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-10-08 15:52:51 +0200 |
commit | 3611753da97f29fc1342ac33a34a25f79acdc672 (patch) | |
tree | 1ce164fb290538b5b9ba5ae98111efb79aacc782 | |
parent | 4e05b191805c728fb2208bce4491eb322681b0c9 (diff) |
Print some errors in info verbs
Print errors info when an error happen during call to mixer 'info' verb.
Change-Id: Ic3b0b6312743af3ba41a7868d1347ce6b0fcc8cd
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
3 files changed, 18 insertions, 11 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c index 3d45260..c74e7a4 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c @@ -491,7 +491,7 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl void HalCtlsInfo(AFB_ReqT request) { - char *apiToCall; + char *apiToCall, *returnedStatus = NULL, *returnedInfo = NULL; AFB_ApiT apiHandle; CtlConfigT *ctrlConfig; @@ -524,15 +524,24 @@ void HalCtlsInfo(AFB_ReqT request) return; } - if(json_object_is_type(requestJson, json_type_object)) { + if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0) { apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName; if(! apiToCall) { AFB_ReqFail(request, "mixer_api", "Can't get mixer api"); return; } - if(HalCtlsGetInfoFromMixer(apiHandle, apiToCall, requestJson, &toReturnJ)) { - AFB_ReqFail(request, "mixer_info", "Call to mixer info verb didn't succeed"); + if(HalCtlsGetInfoFromMixer(apiHandle, apiToCall, requestJson, &toReturnJ, &returnedStatus, &returnedInfo)) { + if(returnedStatus && returnedInfo) { + AFB_ReqFailF(request, + "mixer_info", + "Call to mixer info verb didn't succeed with status '%s' and info '%s'", + returnedStatus, + returnedInfo); + } + else { + AFB_ReqFail(request, "mixer_info", "Call to mixer info verb didn't succeed"); + } return; } diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c index 600b119..059a2ac 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c @@ -281,10 +281,8 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle) return 0; } -int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ) +int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ, char **returnedStatus, char **returnedInfo) { - char *returnedStatus = NULL, *returnedInfo = NULL; - enum CallError returnedError; json_object *returnJ, *responseJ; @@ -305,14 +303,14 @@ int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *re } if(AFB_ServiceSync(apiHandle, apiToCall, MIXER_INFO_VERB, json_object_get(requestJson), &returnJ)) { - returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_INFO_VERB, returnJ, &returnedStatus, &returnedInfo); + returnedError = HalUtlHandleAppFwCallError(apiHandle, apiToCall, MIXER_INFO_VERB, returnJ, returnedStatus, returnedInfo); AFB_ApiError(apiHandle, "Error %i during call to verb %s of %s api with status '%s' and info '%s'", (int) returnedError, apiToCall, MIXER_INFO_VERB, - returnedStatus ? returnedStatus : "not returned", - returnedInfo ? returnedInfo : "not returned"); + *returnedStatus ? *returnedStatus : "not returned", + *returnedInfo ? *returnedInfo : "not returned"); return -4; } else if(json_object_object_get_ex(returnJ, "response", &responseJ)) { diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h index 9218ed4..4ba5e8d 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h @@ -54,6 +54,6 @@ enum MixerStatus { // HAL controllers handle mixer calls functions int HalCtlsAttachToMixer(AFB_ApiT apiHandle); -int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ); +int HalCtlsGetInfoFromMixer(AFB_ApiT apiHandle, char *apiToCall, json_object *requestJson, json_object **toReturnJ, char **returnedStatus, char **returnedInfo); #endif /* _HAL_CTLS_SOFTMIXER_LINK_INCLUDE_ */
\ No newline at end of file |