summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-manager/4a-hal-manager.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-21 17:07:36 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:58 +0100
commit756f8d02b445631df44243d528165fb1fe414487 (patch)
tree1ef835068d6cf24f33eeb0a0a136865a23a1884e /4a-hal/4a-hal-manager/4a-hal-manager.c
parent524ad81cd52d52555d0e6cbaf865f6bb6cfecb25 (diff)
Move from controller functions to afb functions
Move from controller 'afb-definitions.h' functions to application framework 'afb/afb-binding.h' functions. Change-Id: I4cd62af881ef8ac949b082ede9dfcc4736d1e12c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-manager/4a-hal-manager.c')
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c
index c510d17..75177e7 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.c
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <string.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-verbs-loader.h"
@@ -31,7 +31,7 @@
#include "4a-hal-manager-cb.h"
// Default api to print log when apihandle not available
-AFB_ApiT AFB_default;
+afb_api_t AFB_default;
// Local (static) Hal manager data structure
static struct HalMgrData localHalMgrGlobalData;
@@ -41,7 +41,7 @@ static struct HalMgrData localHalMgrGlobalData;
******************************************************************************/
// Hal manager exported verbs
-AFB_ApiVerbs HalManagerApiStaticVerbs[] =
+afb_verb_t HalManagerApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "ping", .callback = HalMgrPing, .info = "Ping test"},
@@ -67,7 +67,7 @@ struct SpecificHalData **HalMngGetFirstHalData(void)
* Dynamic API functions for hal manager *
******************************************************************************/
-static int HalMgrInitApi(AFB_ApiT apiHandle)
+static int HalMgrInitApi(afb_api_t apiHandle)
{
struct SpecificHalData *currentCtlHalData;
struct HalMgrData *HalMgrGlobalData;
@@ -79,8 +79,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
AFB_default = apiHandle;
// Retrieve section config from api handle
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData)
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle)))
return -2;
if(HalUtlInitializeHalMgrData(apiHandle, HalMgrGlobalData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO))
@@ -91,7 +90,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
while(currentCtlHalData) {
if(! currentCtlHalData->apiName)
return -4;
- else if(AFB_RequireApi(apiHandle, currentCtlHalData->apiName, 1))
+ else if(afb_api_require_api(apiHandle, currentCtlHalData->apiName, 1))
return -5;
currentCtlHalData = currentCtlHalData->next;
@@ -100,7 +99,7 @@ static int HalMgrInitApi(AFB_ApiT apiHandle)
return 0;
}
-static int HalMgrLoadApi(void *cbdata, AFB_ApiT apiHandle)
+static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle)
{
struct HalMgrData *HalMgrGlobalData;
@@ -110,39 +109,39 @@ static int HalMgrLoadApi(void *cbdata, AFB_ApiT apiHandle)
HalMgrGlobalData = (struct HalMgrData *) cbdata;
// Save closure as api's data context
- AFB_ApiSetUserData(apiHandle, HalMgrGlobalData);
+ afb_api_set_userdata(apiHandle, HalMgrGlobalData);
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, HalManagerApiStaticVerbs)) {
- AFB_ApiError(apiHandle, "Load section : fail to register static verbs");
+ AFB_API_ERROR(apiHandle, "Load section : fail to register static verbs");
return 1;
}
// Declare an event manager for Hal Manager
- AFB_ApiOnEvent(apiHandle, HalMgrDispatchApiEvent);
+ afb_api_on_event(apiHandle, HalMgrDispatchApiEvent);
// Init Api function (does not receive user closure ???)
- AFB_ApiOnInit(apiHandle, HalMgrInitApi);
+ afb_api_on_init(apiHandle, HalMgrInitApi);
- AFB_ApiSeal(apiHandle);
+ afb_api_seal(apiHandle);
return 0;
}
-int HalMgrCreateApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData)
{
if(! apiHandle || ! HalMgrGlobalData)
return -1;
// Create one API
- return AFB_NewApi(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, HalMgrGlobalData) ? 0 : -1;
+ return afb_api_new_api(apiHandle, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO, 1, HalMgrLoadApi, HalMgrGlobalData) ? 0 : -1;
}
/*******************************************************************************
* Startup function *
******************************************************************************/
-int afbBindingEntry(AFB_ApiT apiHandle)
+int afbBindingEntry(afb_api_t apiHandle)
{
int status = 0, rc;
@@ -152,7 +151,7 @@ int afbBindingEntry(AFB_ApiT apiHandle)
// Hugely hack to make all V2 AFB_DEBUG to work in fileutils
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Binding start");
+ AFB_API_NOTICE(apiHandle, "Binding start");
// Load Hal-Manager using Api v3
rc = HalMgrCreateApi(apiHandle, &localHalMgrGlobalData);