aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-19 16:23:46 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-12-20 11:10:17 +0100
commitcdbaaf3f0821c3f991d5a938e5343f877309315a (patch)
tree861c213a275c9a5e100f6e13ac6811419c35ee85
parent3aa9dec5d719e5c18d32c3c0b47786ae64f11955 (diff)
Send back control previous and current values
Send back control previous and current values if the value(s) specified in request json has been applied correctly when calling halmap verbs. Bug-AGL: SPEC-1313 Change-Id: Ie190b4749a6739945a82532909281fb70c92df5d Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
index 7ea61ac..f360ceb 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
@@ -491,7 +491,9 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
*convertedJ,
*answerJ,
*previousControlValuesJ,
- *normalizedPreviousControlValuesJ;
+ *normalizedPreviousControlValuesJ,
+ *appliedControlValuesJ,
+ *normalizedAppliedControlValuesJ;
apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
if(! apiHandle) {
@@ -557,10 +559,10 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
}
json_object_put(previousControlValuesJ);
- json_object_put(normalizedPreviousControlValuesJ);
if(! json_object_is_type(requestJson, json_type_object)) {
AFB_ReqFailF(request, "request_json", "Request json is not valid '%s'", json_object_get_string(requestJson));
+ json_object_put(normalizedPreviousControlValuesJ);
return;
}
@@ -568,6 +570,7 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
AFB_ReqFailF(request,
"request_json", "Error when trying to get request value object inside request '%s'",
json_object_get_string(requestJson));
+ json_object_put(normalizedPreviousControlValuesJ);
return;
}
@@ -580,21 +583,49 @@ void HalCtlsActionOnAlsaCtl(AFB_ReqT request)
"request_json",
"Error when trying to convert request values '%s'",
json_object_get_string(valueJ));
+ json_object_put(normalizedPreviousControlValuesJ);
return;
}
if(HalCtlsSetAlsaCtlValue(apiHandle, cardIdString, currentAlsaCtl->ctl.numid, convertedJ)) {
AFB_ReqFailF(request,
"alsa_control_call_error",
- "Error while trying to set value on alsa control %i, device '%s', message '%s'",
+ "Error while trying to set value on alsa control %i, device '%s', converted '%s'",
currentAlsaCtl->ctl.numid,
cardIdString,
- json_object_get_string(requestJson));
+ json_object_get_string(convertedJ));
json_object_put(convertedJ);
+ json_object_put(normalizedPreviousControlValuesJ);
return;
}
json_object_put(convertedJ);
- AFB_ReqSuccess(request, NULL, "Action on alsa control correctly done");
+ if(HalCtlsGetAlsaCtlValues(apiHandle, cardIdString, &currentAlsaCtl->ctl, &appliedControlValuesJ)) {
+ AFB_ReqFailF(request, "applied_values", "Error when trying to get applied alsa control values");
+ json_object_put(normalizedPreviousControlValuesJ);
+ return;
+ }
+ else if(HalCtlsConvertJsonValues(apiHandle,
+ &currentAlsaCtl->ctl.alsaCtlProperties,
+ appliedControlValuesJ,
+ &normalizedAppliedControlValuesJ,
+ CONVERSION_ALSACORE_TO_NORMALIZED)) {
+ AFB_ReqFailF(request,
+ "request_json",
+ "Error when trying to normalize applied values json '%s'",
+ json_object_get_string(appliedControlValuesJ));
+ json_object_put(normalizedPreviousControlValuesJ);
+ json_object_put(appliedControlValuesJ);
+ return;
+ }
+
+ json_object_put(appliedControlValuesJ);
+
+ wrap_json_pack(&answerJ,
+ "{s:o, s:o}",
+ "previous", normalizedPreviousControlValuesJ,
+ "current", normalizedAppliedControlValuesJ);
+
+ AFB_ReqSuccess(request, answerJ, "Values correctly applied on alsa control");
} \ No newline at end of file