summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-manager
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-04-18 12:40:25 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-05-24 12:05:52 +0200
commit68138a3ec7a78ad7304d291ff92d8e5292847c4e (patch)
tree9157134d50a749c838afdf93a49c4ce17a018347 /4a-hal/4a-hal-manager
parent196e723e79a1f5eae41cf4a8b1450df0679a4af8 (diff)
Clarify internals hal functions and files names
The purpose of this commit is to have of a more standard way to name files and functions used to generate/handle hal api (generated from hal json configuration file). It occurred to me that 'hal-controller' was not a good name because it is harder for people who don't know about the app-controller to understanded what is the purpose of these files/functions. It was renamed to 'internal-hal' because it's about hal that are all handle/load by hal-manager in opposition of external-hal that are independant binding/binder that can register themselves to hal-manager. BUG-AGL: SPEC-2329 Change-Id: I11b7efe64ec474b004a2a15ed8969b9db95d428f Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-manager')
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c35
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.c41
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.h4
3 files changed, 42 insertions, 38 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 77ae52f..32fbb25 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -62,8 +62,8 @@ void HalMgrLoaded(afb_req_t request)
char cardIdString[32];
afb_api_t apiHandle;
- struct HalMgrData *HalMgrGlobalData;
- struct SpecificHalData *currentHalData;
+ struct HalMgrData *halMgrData;
+ struct HalData *currentHalData;
json_object *requestJson, *requestAnswer, *apiObject;
@@ -72,12 +72,13 @@ void HalMgrLoaded(afb_req_t request)
return;
}
- if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle);
+ if(! halMgrData) {
afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- currentHalData = HalMgrGlobalData->halDataList;
+ currentHalData = halMgrData->halDataList;
if(! currentHalData) {
afb_req_success(request, NULL, "No Hal Api loaded");
@@ -136,8 +137,8 @@ void HalMgrLoad(afb_req_t request)
char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
afb_api_t apiHandle;
- struct HalMgrData *HalMgrGlobalData;
- struct SpecificHalData *addedHal;
+ struct HalMgrData *halMgrData;
+ struct HalData *addedHal;
json_object *requestJson, *apiReceivedMetadata;
@@ -146,7 +147,8 @@ void HalMgrLoad(afb_req_t request)
return;
}
- if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle);
+ if(! halMgrData) {
afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
@@ -174,7 +176,7 @@ void HalMgrLoad(afb_req_t request)
return;
}
- addedHal = HalUtlAddHalApiToHalList(&HalMgrGlobalData->halDataList);
+ addedHal = HalUtlAddHalToHalList(&halMgrData->halDataList);
addedHal->internal = 0;
// TBD JAI : initialize external to unavailable once event from external hal will be handled
@@ -207,8 +209,8 @@ void HalMgrUnload(afb_req_t request)
char *apiName;
afb_api_t apiHandle;
- struct HalMgrData *HalMgrGlobalData;
- struct SpecificHalData *HalToRemove;
+ struct HalMgrData *halMgrData;
+ struct HalData *halToRemove;
json_object *requestJson;
@@ -217,7 +219,8 @@ void HalMgrUnload(afb_req_t request)
return;
}
- if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle);
+ if(! halMgrData) {
afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
@@ -232,18 +235,18 @@ void HalMgrUnload(afb_req_t request)
return;
}
- HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->halDataList, apiName);
- if(! HalToRemove) {
+ halToRemove = HalUtlSearchHalDataByApiName(&halMgrData->halDataList, apiName);
+ if(! halToRemove) {
afb_req_fail(request, "requested_api", "Can't find api to remove");
return;
}
- if(HalToRemove->internal) {
- afb_req_fail(request, "requested_api", "Can't remove an internal controller api");
+ if(halToRemove->internal) {
+ afb_req_fail(request, "requested_api", "Can't remove an internal hal");
return;
}
- if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->halDataList, HalToRemove)) {
+ if(HalUtlRemoveSelectedHalFromList(&halMgrData->halDataList, halToRemove)) {
afb_req_fail(request, "unregister_error", "Didn't succeed to remove specified api");
return;
}
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c
index 017199f..4d2fbf1 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.c
@@ -25,7 +25,7 @@
#include "4a-hal-utilities-data.h"
#include "4a-hal-utilities-verbs-loader.h"
-#include "../4a-hal-controllers/4a-hal-controllers-api-loader.h"
+#include "../4a-internals-hal/4a-internals-hal-api-loader.h"
#include "4a-hal-manager.h"
#include "4a-hal-manager-cb.h"
@@ -54,11 +54,11 @@ afb_verb_t HalManagerApiStaticVerbs[] =
};
/*******************************************************************************
- * HAL Manager get 'SpecificHalData' linked list *
+ * HAL Manager get 'HalData' linked list *
from HAL list function *
******************************************************************************/
-struct SpecificHalData **HalMngGetHalDataList(void)
+struct HalData **HalMngGetHalDataList(void)
{
return &localHalMgrGlobalData.halDataList;
}
@@ -69,8 +69,8 @@ struct SpecificHalData **HalMngGetHalDataList(void)
static int HalMgrInitApi(afb_api_t apiHandle)
{
- struct SpecificHalData *currentCtlHalData;
- struct HalMgrData *HalMgrGlobalData;
+ struct HalData *currentHalData;
+ struct HalMgrData *halMgrData;
if(! apiHandle)
return -1;
@@ -79,21 +79,22 @@ static int HalMgrInitApi(afb_api_t apiHandle)
AFB_default = apiHandle;
// Retrieve section config from api handle
- if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle)))
+ halMgrData = (struct HalMgrData *) afb_api_get_userdata(apiHandle);
+ if(! halMgrData)
return -2;
- if(HalUtlInitializeHalMgrData(apiHandle, HalMgrGlobalData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO))
+ if(HalUtlInitializeHalMgrData(apiHandle, halMgrData, HAL_MANAGER_API_NAME, HAL_MANAGER_API_INFO))
return -3;
- currentCtlHalData = HalMgrGlobalData->halDataList;
+ currentHalData = halMgrData->halDataList;
- while(currentCtlHalData) {
- if(! currentCtlHalData->apiName)
+ while(currentHalData) {
+ if(! currentHalData->apiName)
return -4;
- else if(afb_api_require_api(apiHandle, currentCtlHalData->apiName, 1))
+ else if(afb_api_require_api(apiHandle, currentHalData->apiName, 1))
return -5;
- currentCtlHalData = currentCtlHalData->next;
+ currentHalData = currentHalData->next;
}
return 0;
@@ -101,15 +102,15 @@ static int HalMgrInitApi(afb_api_t apiHandle)
static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle)
{
- struct HalMgrData *HalMgrGlobalData;
+ struct HalMgrData *halMgrData;
if(! cbdata || ! apiHandle)
return -1;
- HalMgrGlobalData = (struct HalMgrData *) cbdata;
+ halMgrData = (struct HalMgrData *) cbdata;
// Save closure as api's data context
- afb_api_set_userdata(apiHandle, HalMgrGlobalData);
+ afb_api_set_userdata(apiHandle, halMgrData);
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, HalManagerApiStaticVerbs)) {
@@ -128,13 +129,13 @@ static int HalMgrLoadApi(void *cbdata, afb_api_t apiHandle)
return 0;
}
-int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalMgrCreateApi(afb_api_t apiHandle, struct HalMgrData *halMgrData)
{
- if(! apiHandle || ! HalMgrGlobalData)
+ if(! apiHandle || ! halMgrData)
return -1;
// Create one API
- return afb_api_new_api(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, halMgrData) ? 0 : -1;
}
/*******************************************************************************
@@ -158,8 +159,8 @@ int afbBindingEntry(afb_api_t apiHandle)
if(rc < 0)
status--;
- // Load Hal-Ctls using Api v3
- rc = HalCtlsCreateAllApi(apiHandle, &localHalMgrGlobalData);
+ // Load internals Hal using Api v3
+ rc = InternalHalCreateAllApi(apiHandle, &localHalMgrGlobalData);
if(rc < 0)
status -= rc;
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.h b/4a-hal/4a-hal-manager/4a-hal-manager.h
index b9eabba..4a53bdd 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.h
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.h
@@ -23,7 +23,7 @@
#define HAL_MANAGER_API_NAME "4a-hal-manager"
#define HAL_MANAGER_API_INFO "Manager for 4A HAL APIs"
-// HAL Manager get 'SpecificHalData' linked list
-struct SpecificHalData **HalMngGetHalDataList(void);
+// HAL Manager get 'HalData' linked list
+struct HalData **HalMngGetHalDataList(void);
#endif /* _HALMGR_BINDING_INCLUDE_ */ \ No newline at end of file