aboutsummaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-utilities
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-01 21:56:45 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:52:51 +0200
commitb62ab4c3fa9595715538dda7dfa330dcb77b0778 (patch)
tree4b0ae68e77eb7e192fd0900ff2ca03e8db00663c /4a-hal/4a-hal-utilities
parentd7496f864274e75f0635a0c20b93175d00a26114 (diff)
Include afb-definitions when using application framework
Include <afb-definitions.h> from 'app-controller' instead of <afb/afb-binding.h> and use its definitions. It allows to migrate from an application framework version to another with less impact on the code. Change-Id: I22359cd3fe22145b3d6c551f227be2ba7e1b65d5 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-utilities')
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c50
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h7
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.c2
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.h9
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c2
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h7
6 files changed, 37 insertions, 40 deletions
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
index 12ee3e1..bb12119 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
@@ -27,7 +27,7 @@
* Handle application framework response function *
******************************************************************************/
-enum CallError HalUtlHandleAppFwCallError(afb_dynapi *apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
+enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
{
json_object *returnedRequestJ, *returnedStatusJ, *returnedInfoJ;
@@ -35,50 +35,50 @@ enum CallError HalUtlHandleAppFwCallError(afb_dynapi *apiHandle, char *apiCalled
return CALL_ERROR_INVALID_ARGS;
if(! json_object_object_get_ex(callReturnJ, "request", &returnedRequestJ)) {
- AFB_DYNAPI_WARNING(apiHandle, "Couldn't get response request object");
+ AFB_ApiWarning(apiHandle, "Couldn't get response request object");
return CALL_ERROR_REQUEST_UNAVAILABLE;
}
if(! json_object_is_type(returnedRequestJ, json_type_object)) {
- AFB_DYNAPI_WARNING(apiHandle, "Response request object is not valid");
+ AFB_ApiWarning(apiHandle, "Response request object is not valid");
return CALL_ERROR_REQUEST_NOT_VALID;
}
if(! json_object_object_get_ex(returnedRequestJ, "status", &returnedStatusJ)) {
- AFB_DYNAPI_WARNING(apiHandle, "Couldn't get response status object");
+ AFB_ApiWarning(apiHandle, "Couldn't get response status object");
return CALL_ERROR_REQUEST_STATUS_UNAVAILABLE;
}
if(! json_object_is_type(returnedStatusJ, json_type_string)) {
- AFB_DYNAPI_WARNING(apiHandle, "Response status object is not valid");
+ AFB_ApiWarning(apiHandle, "Response status object is not valid");
return CALL_ERROR_REQUEST_STATUS_NOT_VALID;
}
*returnedStatus = (char *) json_object_get_string(returnedStatusJ);
if(! strcmp(*returnedStatus, "unknown-api")) {
- AFB_DYNAPI_WARNING(apiHandle, "Api %s not found", apiCalled);
+ AFB_ApiWarning(apiHandle, "Api %s not found", apiCalled);
return CALL_ERROR_API_UNAVAILABLE;
}
if(! strcmp(*returnedStatus, "unknown-verb")) {
- AFB_DYNAPI_WARNING(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
+ AFB_ApiWarning(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
return CALL_ERROR_VERB_UNAVAILABLE;
}
if(! json_object_object_get_ex(returnedRequestJ, "info", &returnedInfoJ)) {
- AFB_DYNAPI_WARNING(apiHandle, "Couldn't get response info object");
+ AFB_ApiWarning(apiHandle, "Couldn't get response info object");
return CALL_ERROR_REQUEST_INFO_UNAVAILABLE;
}
if(! json_object_is_type(returnedInfoJ, json_type_string)) {
- AFB_DYNAPI_WARNING(apiHandle, "Response info object is not valid");
+ AFB_ApiWarning(apiHandle, "Response info object is not valid");
return CALL_ERROR_REQUEST_INFO_NOT_VALID;
}
*returnedInfo = (char *) json_object_get_string(returnedInfoJ);
- AFB_DYNAPI_WARNING(apiHandle,
+ AFB_ApiWarning(apiHandle,
"Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
apiCalled,
verbCalled,
@@ -88,20 +88,20 @@ enum CallError HalUtlHandleAppFwCallError(afb_dynapi *apiHandle, char *apiCalled
return CALL_ERROR_RETURNED;
}
-void HalUtlHandleAppFwCallErrorInRequest(afb_request *request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
+void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
{
char **returnedStatus, **returnedInfo;
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
if(! request || ! apiCalled || ! verbCalled || ! callReturnJ) {
- afb_request_fail_f(request, "invalid_args", "%s: invalid arguments", __func__);
+ AFB_ReqFailF(request, "invalid_args", "%s: invalid arguments", __func__);
return;
}
- apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
+ apiHandle = (AFB_ApiT) afb_request_get_dynapi(request);
if(! apiHandle) {
- afb_request_fail_f(request, "api_handle", "%s: Can't get hal manager api handle", __func__);
+ AFB_ReqFailF(request, "api_handle", "%s: Can't get hal manager api handle", __func__);
return;
}
@@ -115,25 +115,25 @@ void HalUtlHandleAppFwCallErrorInRequest(afb_request *request, char *apiCalled,
case CALL_ERROR_REQUEST_STATUS_NOT_VALID:
case CALL_ERROR_REQUEST_INFO_UNAVAILABLE:
case CALL_ERROR_REQUEST_INFO_NOT_VALID:
- afb_request_fail(request, errorStatusToSend, "Error with response object");
+ AFB_ReqFail(request, errorStatusToSend, "Error with response object");
return;
case CALL_ERROR_API_UNAVAILABLE:
- afb_request_fail_f(request, errorStatusToSend, "Api %s not found", apiCalled);
+ AFB_ReqFailF(request, errorStatusToSend, "Api %s not found", apiCalled);
return;
case CALL_ERROR_VERB_UNAVAILABLE:
- afb_request_fail_f(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
+ AFB_ReqFailF(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
return;
case CALL_ERROR_RETURNED:
- afb_request_fail_f(request,
- errorStatusToSend,
- "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
- apiCalled,
- verbCalled,
- *returnedStatus,
- *returnedInfo);
+ AFB_ReqFailF(request,
+ errorStatusToSend,
+ "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
+ apiCalled,
+ verbCalled,
+ *returnedStatus,
+ *returnedInfo);
return;
case CALL_ERROR_INVALID_ARGS:
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
index 54cdcc2..3279e40 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
@@ -22,8 +22,7 @@
#include <wrap-json.h>
-#define AFB_BINDING_VERSION dyn
-#include <afb/afb-binding.h>
+#include <afb-definitions.h>
// Enum for the type of error detected
enum CallError {
@@ -40,7 +39,7 @@ enum CallError {
};
// Handle application framework response function
-enum CallError HalUtlHandleAppFwCallError(afb_dynapi *apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
-void HalUtlHandleAppFwCallErrorInRequest(afb_request *request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
+enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
+void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
#endif /* _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
index 62bdb8f..48e6f9e 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
@@ -187,7 +187,7 @@ struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGl
* Hal Manager data handling functions *
******************************************************************************/
-uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
+uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
{
if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info)
return -1;
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
index 34ca3e8..053be6f 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
@@ -22,8 +22,7 @@
#include <wrap-json.h>
-#define AFB_BINDING_VERSION dyn
-#include <afb/afb-binding.h>
+#include <afb-definitions.h>
#include <ctl-config.h>
@@ -54,7 +53,7 @@ struct CtlHalSpecificData {
struct CtlHalStreamsDataT ctlHalStreamsData;
// TODO JAI : add structure to hold halmap section data
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
CtlConfigT *ctrlConfig;
};
@@ -84,7 +83,7 @@ struct HalMgrData {
struct SpecificHalData usedCardId[ALSA_MAX_CARD];
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
struct SpecificHalData *first;
};
@@ -97,7 +96,7 @@ uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData);
struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *apiName);
// Exported verbs for 'struct HalMgrData' handling
-uint8_t HalUtlInitializeHalMgrData(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
+uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData);
#endif /* _HAL_UTILITIES_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
index 5d10f4f..6212c05 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
@@ -28,7 +28,7 @@
* TODO JAI : Use API-V3 instead of API-PRE-V3 *
******************************************************************************/
-int HalUtlLoadVerbs(afb_dynapi *apiHandle, struct HalUtlApiVerb *verbs)
+int HalUtlLoadVerbs(AFB_ApiT apiHandle, struct HalUtlApiVerb *verbs)
{
int idx, errCount = 0;
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
index 3bad080..113a0b0 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
@@ -20,19 +20,18 @@
#include <stdio.h>
-#define AFB_BINDING_VERSION dyn
-#include <afb/afb-binding.h>
+#include <afb-definitions.h>
// Structure to store data necessary to add a verb to a dynamic api
struct HalUtlApiVerb {
const char *verb; /* name of the verb, NULL only at end of the array */
- void (*callback)(afb_request *req); /* callback function implementing the verb */
+ void (*callback)(AFB_ReqT req); /* callback function implementing the verb */
const struct afb_auth *auth; /* required authorisation, can be NULL */
const char *info; /* some info about the verb, can be NULL */
uint32_t session;
};
// Verb that allows to add verb to a dynamic api
-int HalUtlLoadVerbs(afb_dynapi *apiHandle, struct HalUtlApiVerb *verbs);
+int HalUtlLoadVerbs(AFB_ApiT apiHandle, struct HalUtlApiVerb *verbs);
#endif /* _HAL_UTILITIES_VERBS_LOADER_INCLUDE_ */ \ No newline at end of file