summaryrefslogtreecommitdiffstats
path: root/ctl-lib
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-12-04 12:23:31 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-05 15:22:26 +0100
commitc3fa161dd4ce60236153e827027b1e1f09e48033 (patch)
tree94f71d5b8d04c5e9030ba978e7ae3721f36dc803 /ctl-lib
parent8bef6c3c5dd49b6708c2a0c077ee88ee57a461af (diff)
New function to retrieve Api's name from LUA
Change-Id: I1678dced50f1cdaf3f2a3c9caff4aa5afa0c5b49 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r--ctl-lib/ctl-lua.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c
index b61885d..ac2b499 100644
--- a/ctl-lib/ctl-lua.c
+++ b/ctl-lib/ctl-lua.c
@@ -654,6 +654,20 @@ static int LuaAfbEventMake(lua_State* luaState) {
return 1;
}
+static int LuaAfbGetApiName(lua_State* luaState) {
+
+ CtlSourceT *source = LuaSourcePop(luaState, LUA_FIRST_ARG);
+ if (!source) {
+ lua_pushliteral(luaState, "LuaAfbEventSubscribe-Fail Invalid request handle");
+ return 0;
+ }
+
+ // extract and return afbSource from timer handle
+ lua_pushstring(luaState, source->api->apiname);
+
+ return 1; // return argument
+}
+
static int LuaAfbGetUid(lua_State* luaState) {
CtlSourceT *source = LuaSourcePop(luaState, LUA_FIRST_ARG);
@@ -1288,6 +1302,7 @@ static const luaL_Reg afbFunction[] = {
{"subscribe", LuaAfbEventSubscribe},
{"evtmake", LuaAfbEventMake},
{"evtpush", LuaAfbEventPush},
+ {"getapiname", LuaAfbGetApiName},
{"getuid", LuaAfbGetUid},
{"getrootdir", LuaAfbGetRootDir},
{"status", LuaAfbGetStatus},