diff options
author | Frederic Marec <frederic.marec@iot.bzh> | 2019-05-10 11:04:34 +0200 |
---|---|---|
committer | Frederic Marec <frederic.marec@iot.bzh> | 2019-05-10 11:04:34 +0200 |
commit | a13401e9b5393edf65cd1ca8c11491926b5568ff (patch) | |
tree | c15ffdfbdb7084517cbfc2466a9db4fb1850a2af | |
parent | baaa5116b2299b2b01b9fa3199ba95786c2d8a77 (diff) |
Change order in appcontroler usage documentationhalibut_7.99.1halibut/7.99.17.99.1
Change order in appcontroler usage documentation to be more clear.
Now that most of bindings are migrate.
The migration part in documentation should be at the bottom to be less confiusing
Bug-AGL: SPEC-2395
Change-Id: Ibd22e493ae9d8903375c775947f56944aa4318ea
Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
-rw-r--r-- | docs/Usage.md | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/docs/Usage.md b/docs/Usage.md index e89aade..420d42a 100644 --- a/docs/Usage.md +++ b/docs/Usage.md @@ -1,5 +1,56 @@ # Usage +## Add libappcontroller as a static library to your binding + +In your `config.cmake` file, add a dependency to the controller library, i.e: + +```cmake +set(PKG_REQUIRED_LIST + json-c + afb-daemon + appcontroller --> this is the controller library dependency name. +) +``` + +Or you can also use the [FIND_PACKAGE](https://cmake.org/cmake/help/v3.6/command/find_package.html?highlight=find_package) +CMake command to add it. + +## Declare your controller config section in your binding + +```C +// CtlSectionT syntax: +// key: "section name in config file" +// loadCB: callback to process section +// handle: a void* pass to callback when processing section +static CtlSectionT ctlSections[]= { + {.key="plugins" , .loadCB= PluginConfig, .handle= &halCallbacks}, + {.key="onload" , .loadCB= OnloadConfig}, + {.key="halmap" , .loadCB= MapConfigLoad}, + {.key=NULL} +}; + +``` + +## Do the controller config parsing at binding pre-init + +```C + // check if config file exist + const char *dirList= getenv("CTL_CONFIG_PATH"); + if (!dirList) dirList=CONTROL_CONFIG_PATH; + + const char *configPath = CtlConfigSearch(apiHandle, dirList, "prefix"); + if(!confiPath) return -1; + + ctlConfig = CtlConfigLoad(dirList, ctlSections); + if (!ctlConfig) return -1; +``` + +## Execute the controller config during binding init + +```C + int err = CtlConfigExec (ctlConfig); +``` + ## (Optional) Migrate from the git submodule version ### Remove the git submodule version @@ -133,55 +184,4 @@ should migrate: #define AFB_ApiOnEvent afb_api_on_event #define AFB_ApiOnInit afb_api_on_init #define AFB_ApiSeal afb_api_seal -``` - -## Add libappcontroller as a static library to your binding - -In your `config.cmake` file, add a dependency to the controller library, i.e: - -```cmake -set(PKG_REQUIRED_LIST - json-c - afb-daemon - appcontroller --> this is the controller library dependency name. -) -``` - -Or you can also use the [FIND_PACKAGE](https://cmake.org/cmake/help/v3.6/command/find_package.html?highlight=find_package) -CMake command to add it. - -## Declare your controller config section in your binding - -```C -// CtlSectionT syntax: -// key: "section name in config file" -// loadCB: callback to process section -// handle: a void* pass to callback when processing section -static CtlSectionT ctlSections[]= { - {.key="plugins" , .loadCB= PluginConfig, .handle= &halCallbacks}, - {.key="onload" , .loadCB= OnloadConfig}, - {.key="halmap" , .loadCB= MapConfigLoad}, - {.key=NULL} -}; - -``` - -## Do the controller config parsing at binding pre-init - -```C - // check if config file exist - const char *dirList= getenv("CTL_CONFIG_PATH"); - if (!dirList) dirList=CONTROL_CONFIG_PATH; - - const char *configPath = CtlConfigSearch(apiHandle, dirList, "prefix"); - if(!confiPath) return -1; - - ctlConfig = CtlConfigLoad(dirList, ctlSections); - if (!ctlConfig) return -1; -``` - -## Execute the controller config during binding init - -```C - int err = CtlConfigExec (ctlConfig); -``` +```
\ No newline at end of file |