summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-manager
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal/4a-hal-manager')
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c88
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.h17
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-events.h3
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.c14
4 files changed, 60 insertions, 62 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 75198a9..41517f6 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -33,9 +33,9 @@
******************************************************************************/
// TODO JAI : to implement
-void HalMgrDispatchApiEvent(afb_dynapi *apiHandle, const char *evtLabel, json_object *eventJ)
+void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ)
{
- AFB_DYNAPI_WARNING(apiHandle, "JAI :%s not implemented yet", __func__);
+ AFB_ApiWarning(apiHandle, "JAI :%s not implemented yet", __func__);
// Use "4a-hal-manager-events.h" to handle events
}
@@ -43,18 +43,18 @@ void HalMgrDispatchApiEvent(afb_dynapi *apiHandle, const char *evtLabel, json_ob
* TODO JAI : Present for test, delete this function when validated *
******************************************************************************/
-void HalMgrPing(afb_request *request)
+void HalMgrPing(AFB_ReqT request)
{
static int count = 0;
count++;
if(request->dynapi)
- AFB_REQUEST_NOTICE(request, "JAI :%s (%s): ping count = %d", request->api, request->dynapi->apiname, count);
+ AFB_ReqNotice(request, "JAI :%s (%s): ping count = %d", request->api, request->dynapi->apiname, count);
else
- AFB_REQUEST_NOTICE(request, "JAI: %s: ping count = %d", request->api, count);
+ AFB_ReqNotice(request, "JAI: %s: ping count = %d", request->api, count);
- afb_request_success(request, json_object_new_int(count), NULL);
+ AFB_ReqSucess(request, json_object_new_int(count), NULL);
return;
}
@@ -63,44 +63,44 @@ void HalMgrPing(afb_request *request)
* HAL Manager verbs functions *
******************************************************************************/
-void HalMgrLoaded(afb_request *request)
+void HalMgrLoaded(AFB_ReqT request)
{
int requestJsonErr, requestOptionValue;
uint64_t cpt, numberOfLoadedApi;
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *currentHalData;
json_object *requestJson, *requestAnswer, *apiObject;
- apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
+ apiHandle = (AFB_ApiT ) afb_request_get_dynapi(request);
if(! apiHandle) {
- afb_request_fail(request, "api_handle", "Can't get hal manager api handle");
+ AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
return;
}
HalMgrGlobalData = (struct HalMgrData *) afb_dynapi_get_userdata(apiHandle);
if(! HalMgrGlobalData) {
- afb_request_fail(request, "hal_manager_data", "Can't get hal manager data");
+ AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- requestJson = afb_request_json(request);
+ requestJson = AFB_ReqJson(request);
if(! requestJson) {
- afb_request_fail(request, "request_json", "Can't get request json");
+ AFB_ReqFail(request, "request_json", "Can't get request json");
return;
}
numberOfLoadedApi = HalUtlGetNumberOfHalInList(HalMgrGlobalData);
if(! numberOfLoadedApi) {
- afb_request_success(request, NULL, "No Hal Api loaded");
+ AFB_ReqSucess(request, NULL, "No Hal Api loaded");
return;
}
requestAnswer = json_object_new_array();
if(! requestAnswer) {
- afb_request_fail(request, "json_answer", "Can't generate json answer");
+ AFB_ReqFail(request, "json_answer", "Can't generate json answer");
return;
}
@@ -136,39 +136,39 @@ void HalMgrLoaded(afb_request *request)
}
}
- afb_request_success(request, requestAnswer, "Requested data");
+ AFB_ReqSucess(request, requestAnswer, "Requested data");
}
-void HalMgrLoad(afb_request *request)
+void HalMgrLoad(AFB_ReqT request)
{
char *apiName, *sndCard, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *addedHal;
struct json_object *requestJson, *apiReceviedMetadata;
- apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
+ apiHandle = (AFB_ApiT) afb_request_get_dynapi(request);
if(! apiHandle) {
- afb_request_fail(request, "api_handle", "Can't get hal manager api handle");
+ AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
return;
}
HalMgrGlobalData = (struct HalMgrData *) afb_dynapi_get_userdata(apiHandle);
if(! HalMgrGlobalData) {
- afb_request_fail(request, "hal_manager_data", "Can't get hal manager data");
+ AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- requestJson = afb_request_json(request);
+ requestJson = AFB_ReqJson(request);
if(! requestJson) {
- afb_request_fail(request, "request_json", "Can't get request json");
+ AFB_ReqFail(request, "request_json", "Can't get request json");
return;
}
if(! json_object_object_get_ex(requestJson, "metadata", &apiReceviedMetadata)) {
- afb_request_fail(request, "api_metadata", "Can't get api to register metadata");
+ AFB_ReqFail(request, "api_metadata", "Can't get api to register metadata");
return;
}
@@ -180,7 +180,7 @@ void HalMgrLoad(afb_request *request)
"author", &author,
"version", &version,
"date", &date)) {
- afb_request_fail(request, "api_metadata", "Can't metadata of api to register");
+ AFB_ReqFail(request, "api_metadata", "Can't metadata of api to register");
return;
}
@@ -208,75 +208,75 @@ void HalMgrLoad(afb_request *request)
// TODO JAI: add subscription to this api status events
- afb_request_success(request, NULL, "Api successfully registered");
+ AFB_ReqSucess(request, NULL, "Api successfully registered");
}
-void HalMgrUnload(afb_request *request)
+void HalMgrUnload(AFB_ReqT request)
{
char *apiName;
- afb_dynapi *apiHandle;
+ AFB_ApiT apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *HalToRemove;
struct json_object *requestJson;
- apiHandle = (afb_dynapi *) afb_request_get_dynapi(request);
+ apiHandle = (AFB_ApiT) afb_request_get_dynapi(request);
if(! apiHandle) {
- afb_request_fail(request, "api_handle", "Can't get hal manager api handle");
+ AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
return;
}
HalMgrGlobalData = (struct HalMgrData *) afb_dynapi_get_userdata(apiHandle);
if(! HalMgrGlobalData) {
- afb_request_fail(request, "hal_manager_data", "Can't get hal manager data");
+ AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- requestJson = afb_request_json(request);
+ requestJson = AFB_ReqJson(request);
if(! requestJson) {
- afb_request_fail(request, "request_json", "Can't get request json");
+ AFB_ReqFail(request, "request_json", "Can't get request json");
return;
}
if(wrap_json_unpack(requestJson, "{s:s}", "api", &apiName)) {
- afb_request_fail(request, "requested_api", "Can't get api to remove");
+ AFB_ReqFail(request, "requested_api", "Can't get api to remove");
return;
}
HalToRemove = HalUtlSearchHalDataByApiName(HalMgrGlobalData, apiName);
if(! HalToRemove) {
- afb_request_fail(request, "requested_api", "Can't find api to remove");
+ AFB_ReqFail(request, "requested_api", "Can't find api to remove");
return;
}
if(HalToRemove->internal) {
- afb_request_fail(request, "requested_api", "Can't remove an internal controller api");
+ AFB_ReqFail(request, "requested_api", "Can't remove an internal controller api");
return;
}
if(HalUtlRemoveSelectedHalFromList(HalMgrGlobalData, HalToRemove)) {
- afb_request_fail(request, "unregister_error", "Didn't succeed to remove specified api");
+ AFB_ReqFail(request, "unregister_error", "Didn't succeed to remove specified api");
return;
}
// TODO JAI: remove subscription to this api status events
- afb_request_success(request, NULL, "Api successfully unregistered");
+ AFB_ReqSucess(request, NULL, "Api successfully unregistered");
}
// TODO JAI : to implement
-void HalMgrSubscribeEvent(afb_request *request)
+void HalMgrSubscribeEvent(AFB_ReqT request)
{
- AFB_REQUEST_WARNING(request, "JAI :%s not implemented yet", __func__);
+ AFB_ReqWarning(request, "JAI :%s not implemented yet", __func__);
- afb_request_success(request, json_object_new_boolean(false), NULL);
+ AFB_ReqSucess(request, json_object_new_boolean(false), NULL);
}
// TODO JAI : to implement
-void HalMgrUnsubscribeEvent(afb_request *request)
+void HalMgrUnsubscribeEvent(AFB_ReqT request)
{
- AFB_REQUEST_WARNING(request, "JAI :%s not implemented yet", __func__);
+ AFB_ReqWarning(request, "JAI :%s not implemented yet", __func__);
- afb_request_success(request, json_object_new_boolean(false), NULL);
+ AFB_ReqSucess(request, json_object_new_boolean(false), NULL);
} \ No newline at end of file
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.h b/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
index 728191d..4213196 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.h
@@ -20,19 +20,18 @@
#include <stdio.h>
-#define AFB_BINDING_VERSION dyn
-#include <afb/afb-binding.h>
+#include <afb-definitions.h>
// Event handler
-void HalMgrDispatchApiEvent(afb_dynapi *apiHandle, const char *evtLabel, json_object *eventJ);
+void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ);
// Exported verbs callbacks
-void HalMgrPing(afb_request *request);
+void HalMgrPing(AFB_ReqT request);
-void HalMgrLoaded(afb_request *request);
-void HalMgrLoad(afb_request *request);
-void HalMgrUnload(afb_request *request);
-void HalMgrSubscribeEvent(afb_request *request);
-void HalMgrUnsubscribeEvent(afb_request *request);
+void HalMgrLoaded(AFB_ReqT request);
+void HalMgrLoad(AFB_ReqT request);
+void HalMgrUnload(AFB_ReqT request);
+void HalMgrSubscribeEvent(AFB_ReqT request);
+void HalMgrUnsubscribeEvent(AFB_ReqT request);
#endif /* _HALMGR_CB_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-events.h b/4a-hal/4a-hal-manager/4a-hal-manager-events.h
index f7ad61e..e1c84c6 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-events.h
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-events.h
@@ -20,8 +20,7 @@
#include <stdio.h>
-#define AFB_BINDING_VERSION dyn
-#include <afb/afb-binding.h>
+#include <afb-definitions.h>
// TODO JAI: declare events handlers functions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c
index df2ead5..8df5365 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.c
@@ -29,7 +29,7 @@
#include "4a-hal-manager-cb.h"
// Default api to print log when apihandle not available
-afb_dynapi *AFB_default;
+AFB_ApiT AFB_default;
/*******************************************************************************
* HAL Manager verbs table *
@@ -53,7 +53,7 @@ struct HalUtlApiVerb HalManagerApiStaticVerbs[] =
* TODO JAI : Use API-V3 instead of API-PRE-V3 *
******************************************************************************/
-static int HalMgrInitApi(afb_dynapi *apiHandle)
+static int HalMgrInitApi(AFB_ApiT apiHandle)
{
struct HalMgrData *HalMgrGlobalData;
@@ -74,7 +74,7 @@ static int HalMgrInitApi(afb_dynapi *apiHandle)
return 0;
}
-static int HalMgrLoadApi(void *cbdata, afb_dynapi *apiHandle)
+static int HalMgrLoadApi(void *cbdata, AFB_ApiT apiHandle)
{
struct HalMgrData *HalMgrGlobalData;
@@ -88,7 +88,7 @@ static int HalMgrLoadApi(void *cbdata, afb_dynapi *apiHandle)
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, HalManagerApiStaticVerbs)) {
- AFB_DYNAPI_ERROR(apiHandle, "%s : load section : fail to register static V2 verbs", __func__);
+ AFB_ApiError(apiHandle, "%s : load section : fail to register static V2 verbs", __func__);
return 1;
}
@@ -103,7 +103,7 @@ static int HalMgrLoadApi(void *cbdata, afb_dynapi *apiHandle)
return 0;
}
-int HalMgrCreateApi(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalMgrCreateApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
{
if(! apiHandle || ! HalMgrGlobalData)
return -1;
@@ -117,7 +117,7 @@ int HalMgrCreateApi(afb_dynapi *apiHandle, struct HalMgrData *HalMgrGlobalData)
* TODO JAI : Use API-V3 instead of API-PRE-V3 *
******************************************************************************/
-int afbBindingVdyn(afb_dynapi *apiHandle)
+int afbBindingVdyn(AFB_ApiT apiHandle)
{
int status = 0, rc;
struct HalMgrData *HalMgrGlobalData;
@@ -132,7 +132,7 @@ int afbBindingVdyn(afb_dynapi *apiHandle)
// Hugely hack to make all V2 AFB_DEBUG to work in fileutils
AFB_default = apiHandle;
- AFB_DYNAPI_NOTICE(apiHandle, "In %s", __func__);
+ AFB_ApiNotice(apiHandle, "In %s", __func__);
// Load Hal-Manager using DynApi
rc = HalMgrCreateApi(apiHandle, HalMgrGlobalData);