aboutsummaryrefslogtreecommitdiffstats
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-13 15:02:55 +0100
commit39b20e02e650f37f187272688005ce3cd152752a (patch)
tree94f71d5b8d04c5e9030ba978e7ae3721f36dc803
parent040510494a9e7192707537b9050926cbac9494fe (diff)
New function to retrieve Api's name from LUA
Change-Id: I1678dced50f1cdaf3f2a3c9caff4aa5afa0c5b49 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-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},