summaryrefslogtreecommitdiffstats
path: root/ctl-lib
AgeCommit message (Collapse)AuthorFilesLines
2018-05-28Increase lua script max message sizeJonathan Aillet1-1/+1
Increase lua script max message size to avoid app-controller warning messages when a lua print message is too long with 4a-softmixer. Change-Id: I3c2496ea3e5bd971b7682328f7a6227e36b6d706 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-28Prevent lost of config file path when searchingJonathan Aillet1-3/+7
Prevent lost of config file path when searching by keeping only the first file found. Add a warning if multiple files are found. Change-Id: I97262c4dbbc53bb921ef25b9100491cf3e29a056 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-28Correct way that api actions are handled in controllerJonathan Aillet1-23/+25
Don't create a new object each time a action is executed. Correction in the way that args are added in the api query. Correction to return the response of the api call if received. Optimization of how get/put are done in 'ActionExecOne' function. Change-Id: I30d0d6450599b7da7bfa9ad29b21d1be8ea6243e Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-28Handle more metadata in the controller.Jonathan Aillet2-5/+9
Add fields that will be searched for during controller metadata section parsing. These fields are optional, so they will be copied in CtlConfigT if they are present. Otherwise, no error will be raised. The added fields are : - 'author' which should contain the author name of the configuration file. - 'date' which should contain the date of the configuration file last modification. Change-Id: Iab480533d85c4a52ea5f6a70fb6f9b8d0b866af4 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-28Add possibility to set prefix to NULL in CtlConfigScanJonathan Aillet1-1/+1
When prefix is set to NULL, only the middle name of the process will be used to find configuration files. Example: when the binder is named 'afb-4a-hal', and the prefix parameter is set to NULL, the 'CtlConfigScan' function will search for 4a-*.json config files in 'dirList' list. Change-Id: I8a9ee7df670d992f5461c865591ced9ba46fe8a0 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-22Fixed compilation warnings with gcc-7.2.0Thierry Bultel4-9/+9
Replaced some 'size_t' by 'int' Change-Id: Iaf58b4b65f9aa2e82c0a87af45f21ca62fa4d84e Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-05-18Add an external field to CtlConfigTJonathan Aillet1-0/+1
Add an external field to CtlConfigT to store external data (by casting to void *). Change-Id: I368319f4cde6dc0409b5672809cc19a08e43dd67 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-05-18Make action item from a LUA action mandatoryRomain Forlot1-13/+1
It is already mandatory from a JSON schema point of view so here it should be the same. Also it simplifies the process avoiding the guess and deduction... Change-Id: I3197b4c7798589f4c62814407909270cdabd1dae Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-18Handle no prefix givenRomain Forlot1-3/+8
If no prefix given, then only use the binder name to search config file. Change-Id: I504ea27dccb8892e12e09d3e9e42bc281bcf87b0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-18Good usage of strncat and strncpyRomain Forlot5-58/+75
This change ensure that there are no write over the destination buffer size Change-Id: Ic213e70fab83dfae39a8ff030c823a6ce68aab64 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-18Update to the new JSON syntaxRomain Forlot1-1/+1
Change-Id: I4ee750f4d95e9fe47352e6cd1dfaeaa94c292e30 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-18Detect failure at OnLoad action callsRomain Forlot4-5/+12
Be able to detect that an action has failed on an Onload section processing to avoid retrieving a wrong context after that. Change-Id: If694b11eb0a37154b539c421e43bebdb15d498c0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-18Improve reliability and function callsRomain Forlot1-2/+4
Don't calls two times the same function. As well as avoiding using the function return to get its length Change-Id: I26c37f9a376b2c243ffd7a5ad0ddf935c8b5d0e9 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-17Correctly release request JSON objectRomain Forlot1-1/+1
A JSON object coming from an AFB request is handled by the appfw. So, it release it once request has been executed. ActionExecOne also decrement the reference count of the json_object, so to make the count right it is needed to call a json_object_get here. Change-Id: I4c74a767e8e51e8b975ebe66c97f5b1f5b3aba05 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-17Add AFB macrosRomain Forlot1-0/+6
This adds a macro to be able to retrieve the rootdir fd from the binding using V2 or DynAPI version the same way. Change-Id: I4e9e805b729118944f07ccedae6cccc6b950058b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-17Don't use assert in controller.Romain Forlot1-3/+2
Rather use tests with a test framework. Change-Id: I1c626c7cc96403587a57ae23af67c95f6ed2f862 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-16Change lua2c JSON syntax.Romain Forlot1-6/+16
Clearer JSON writing config. Schema provide informations about objects Change-Id: I55e7c9bef442abaa577c59ab2005da1f315f9312 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-16Search for Event sectionRomain Forlot1-7/+15
Don't use a static and fixed index to reach event section. Rather browse sections array to find it Change-Id: I4eed8abf73f674034da252aa9d133325f82e62c2 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-16Fix: changes key name.Romain Forlot1-1/+1
We could have several file Change-Id: Ia612cb6989a05cc47505ec8975ae825be160af2a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-16Fix: arguments pointer NULL checkRomain Forlot1-2/+5
Change-Id: I666136b1f1fb21d223fa16f299de2ce5430a0c7e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-16Fix wrong error message.Romain Forlot1-2/+2
Signature was wrong since last modification about controller and lua integration that now transport source informations. Change-Id: I8f98415b55978e6b7221415ad6169e8d2bc1c959 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-15Simplify action definitionRomain Forlot1-19/+67
Because before uri could be a path it wasn't suits for parsing as we can't have any character chosen as separator. As now, first part isn't a path but rather a plugin/resource uid then it fine since the separator isn't allowed in the uid So # is forbidden for uid by the schema. Change-Id: Ida3d7acb46687188c44a472c057c58301cb1d9c6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-14Fix: Dyn API Action loading procedureRomain Forlot5-436/+454
Change-Id: Ibb7dbc32580100c588d06e283abb57cc37875312 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-14Use new version of function GetBindingDirPathRomain Forlot2-15/+16
That follow the last update in afb-helpers submodule used. Change-Id: Ia6149ae96c1591f3d0791f4263e8beafbe6e764d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-14FormatRomain Forlot12-319/+259
Change-Id: Ied901f39cd6814e5afd9811248b0a1fb401f3e76 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-11Loads l2c functions per plugin.Romain Forlot4-50/+59
L2C functions are prefixed with either the chosen prefix or plugin uid by default. Change-Id: Id296ec629c803ab06cd05f5278fed3c48cbcf10e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-11Improve json object releaseRomain Forlot1-3/+2
For convenience queryJ will always be released. Users has to call json_object_get to be able to use it after that. API subcall use an intermediate variable to avoid modifying this parameter in case of user wanna use it after that. Change-Id: I98f478d3fc0c4ef28234811333b9effd8289e74d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-11Improve way to loading an actionRomain Forlot3-160/+153
Split and cleaner function that load from JSON object an object CtlActionT that could be used by the controller. Also use a new syntax that reduce the number of JSON fields to parse based on a URI syntax. Change-Id: Iabc447368ca56e3a4279fb728ba2f546e11c961b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-09Upgrade config schemaRomain Forlot8-226/+440
Change the way to load LUA scripts. They are now considerate as Plugin and loads with them. This imply rework of how to search and find plugins as well as the way to load LUA. Also load an harcoded LUA scripts providing LUA helpers and managing global variables lock unlock mechanism Change-Id: I64e38aa27278d0cfdca787155db2d0c89953f905 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-09Fix: callback execution conditionRomain Forlot1-1/+1
Test the wrong pointer to know if there is a CB to execute. Action pointer could be void as the loading callback isn't stored in it. Change-Id: I3281cdd603cc8b90059331fcff694b354eae1db0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-30Fix conversion compilation warningRomain Forlot2-3/+3
Change-Id: I0d5350c1e454bc118e4470ae7ff0eafe253cd2bf Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-29Fix link to afb-helpers renamed from afb-utilitiesRomain Forlot1-1/+1
Change-Id: I5f17060c00de8bf7825fbd842db2cca8f2142df7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-25Release json_objects used to launched the actionRomain Forlot1-0/+4
Instead of only have API subcall releasing the json_object now release in all cases to be coherent. This should be argument to be passed to an action, treated in that action then after that has been done, this object has no more meanings and should be released. Change-Id: I371f0c3db34f4126a812d70b7e3ccb9f8bb5f776 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-25Format, get rid of conversion type warning.Romain Forlot2-9/+7
Change-Id: I8cde66dc613fd36e7061f45918520ecd1cdf2825 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-25Use an intermadiary variable avoiding side effets.Romain Forlot1-10/+13
Previously using parameter and modifying it which could involves side effects. Better to use an intermediary json_object to be fills with action->argsJ and queryJ object meld together. Also fix segfault after json_object_put called inside AFB_ServiceSync doing a json_object_get() on object to be conserved Change-Id: I4618a7bc87e111afa1fe047168ba7232241ac4c8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-04-23Old audio controller traces left behindRomain Forlot1-1/+1
Change-Id: I2423376e9c0c616ba62439b387f7da23f710dbb0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-03-21Linting: Initialize fullprefix variableRomain Forlot1-1/+1
Change-Id: I24b0b0f87f1315220cf668c170fc3c13a85f46bb Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-21Fix memory leakRomain Forlot1-0/+4
Change-Id: I5ba04ecfb7809f9132e7958c5044b3d821830e8a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-19Change prefix generation, simpler is betterRomain Forlot1-3/+5
Change-Id: Ieb4801b9162f9f8f374b352fb66bed82a8854b7f Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-19Add binding rootdir to searched path for conf and pluginsRomain Forlot2-2/+26
Change-Id: I4526dd9afc76ac9c63ecb6e800157a0678485955 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-18Make public ConfigSearch functionRomain Forlot2-1/+2
Change-Id: I6da8b9d463ef9adc604bc59285189e45dfb63a7a Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-18Fix segfault when no l2c functions definedRomain Forlot2-2/+2
Mark "ldpath" parameter as optional like it is. Change-Id: If32e078f5a4349ab895b1fd4b8f0a8c542d247a1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-14Get back on track l2c functions.Romain Forlot6-15/+48
Change-Id: I8425f0de60a35b4e287c8829fe72cbca80bc55df Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-14Fix warning compile about uninitialized variableRomain Forlot1-2/+2
Change-Id: I5b07409a7d7c9b5e038accb973b3232775e40c23 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-12-11Avoid compile warning, memory leaks, lintingRomain Forlot4-8/+14
Change-Id: Ida18aeab20d5b894609c1a9c2f6fc2a71a0b4a23 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-30Fix wrong json object pointed.Romain Forlot1-3/+2
Change-Id: Id485aa5ddf8d78a1fc48922cb3c3161fb65dea1b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-29Protect exec when no files found.Romain Forlot1-28/+31
ScanForConfig return null when no files found which isn't handled until now. Change-Id: I70d6b4a45be9d434aca049e3cd3260dfc38a7ff7 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-29wrong json unpacking fails.Romain Forlot1-1/+1
Change-Id: Ie0246192b014c3550207fab1fb6512aeb6e5bce1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-29Wrong increment always fails load an actionRomain Forlot1-1/+0
Change-Id: I7a8a3ac4846f1190caf1a4dde066e50dc592d58b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-29Loading additional files from JSON sectionRomain Forlot2-24/+47
Now handle "files" object inside section loading to externalize JSON definition and could split them in several files if needed. "files" could be specified inside a section object, each files will be parsed to found same key than the current section and append content to the existing section's objects Change-Id: I4414684d08c5214cf96b365f9b0a72b13578a6ca Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>