summaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-02-19 17:05:04 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-02-19 17:17:04 +0100
commit0c4921b83a13bcb96bf03fb0e7a0733c3e202474 (patch)
treece1320c7a3292b853115c4686d0320a32ac7ffd0 /4a-hal
parent974f211eaabb5fc6049c459b4b0f2ac8da617b7e (diff)
Updates for latest alsacore changes
Updates calls to 'infoget' of 'alsacore' due to recent changes in alsacore. Change-Id: If7259c50cceac26fea6e0966eaccb5a1ed5d132b Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c33
1 files changed, 16 insertions, 17 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 f814e74..214fca9 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
@@ -73,9 +73,9 @@ int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath)
{
int errorToReturn, cardId;
- char *returnedError = NULL, *returnedInfo = NULL, *cardIdString = NULL;
+ char *returnedError = NULL, *returnedInfo = NULL;
- json_object *toSendJ, *responseJ = NULL, *devidJ;
+ json_object *toSendJ, *responseJ = NULL;
if(! apiHandle) {
AFB_API_ERROR(apiHandle, "Api handle not available");
@@ -87,7 +87,7 @@ int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath)
return -2;
}
- wrap_json_pack(&toSendJ, "{s:s}", "devpath", devPath);
+ wrap_json_pack(&toSendJ, "{s:s}", "cardPath", devPath);
if(afb_api_call_sync(apiHandle,
ALSACORE_API,
@@ -111,21 +111,20 @@ int HalCtlsGetCardIdByCardPath(afb_api_t apiHandle, char *devPath)
ALSACORE_API);
errorToReturn = -4;
}
- else if(json_object_object_get_ex(responseJ, "devid", &devidJ) && json_object_is_type(devidJ, json_type_string)) {
- cardIdString = (char *) json_object_get_string(devidJ);
- if(sscanf(cardIdString, "hw:%i", &cardId) == 1) {
- json_object_put(responseJ);
- return cardId;
- }
- else {
- AFB_API_WARNING(apiHandle, "Could not get valid devid from string: '%s'", cardIdString);
- errorToReturn = -5;
- }
+ else if(! json_object_is_type(responseJ, json_type_object)) {
+ AFB_API_ERROR(apiHandle,
+ "Seems that %s call to api %s succeed but the returned response is invalid",
+ ALSACORE_GETINFO_VERB,
+ ALSACORE_API);
+ errorToReturn = -5;
}
- else {
- AFB_API_WARNING(apiHandle, "Response devid is not present/valid");
+ else if(wrap_json_unpack(responseJ, "{s:i}", "cardNb", &cardId)) {
+ AFB_API_WARNING(apiHandle, "Response card id is not present/valid");
errorToReturn = -6;
}
+ else {
+ return cardId;
+ }
if(responseJ)
json_object_put(responseJ);
@@ -423,7 +422,7 @@ int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl
&returnedInfo)) {
AFB_API_ERROR(apiHandle,
"Something went wrong during call to verb '%s' of api '%s' with error '%s' and info '%s'",
- ALSACORE_GETINFO_VERB,
+ ALSACORE_ADDCTL_VERB,
ALSACORE_API,
returnedError ? returnedError : "not returned",
returnedInfo ? returnedInfo : "not returned");
@@ -439,7 +438,7 @@ int HalCtlsCreateAlsaCtl(afb_api_t apiHandle, char *cardId, struct CtlHalAlsaCtl
else if(wrap_json_unpack(responseJ, "{s:i}", "id", &alsaCtlToCreate->numid)) {
AFB_API_ERROR(apiHandle,
"Can't get create id from %s of %s api",
- ALSACORE_GETINFO_VERB,
+ ALSACORE_ADDCTL_VERB,
ALSACORE_API);
err = -7;
}