diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-04 12:23:31 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-12 17:44:41 +0100 |
commit | 61f072c244fcf9b375f7066ef1798b60b234a956 (patch) | |
tree | f69d7cfd96e926eae04cf7fef6ae4157ae6e2156 /ctl-lib/ctl-lua.c | |
parent | 0249030fb60093ff7d8e6e5f7d9d8ce69233f0ac (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/ctl-lua.c')
-rw-r--r-- | ctl-lib/ctl-lua.c | 15 |
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}, |