summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-lua.c
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2017-11-02 11:58:32 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:54 +0100
commit5ea27091ffd08d0c9cb9368d274bd0998fd89a77 (patch)
treefbb15fa89b8a98ba5a43565b98cb91c3253b65f3 /ctl-lib/ctl-lua.c
parentf90b319be45e0fc16b608e2c0639648180d3af76 (diff)
Modifiy timer to supper DynAPI
th Please enter the commit message for your changes. Lines starting Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-lua.c')
-rw-r--r--ctl-lib/ctl-lua.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c
index 85bd9c2..cdb245a 100644
--- a/ctl-lib/ctl-lua.c
+++ b/ctl-lib/ctl-lua.c
@@ -959,18 +959,23 @@ OnErrorExit:
// Timer Callback
// Set timer
-STATIC int LuaTimerSetCB (void *handle) {
- LuaCbHandleT *LuaCbHandle = (LuaCbHandleT*) handle;
+STATIC int LuaTimerSetCB (TimerHandleT *timer) {
+ LuaCbHandleT *LuaCbHandle = (LuaCbHandleT*) timer->context;
int count;
// push timer handle and user context on Lua stack
lua_getglobal(luaState, LuaCbHandle->callback);
- count=1;
// Push AFB client context on the stack
+ count=1;
LuaAfbSourceT *afbSource= LuaSourcePush(luaState, LuaCbHandle->source);
if (!afbSource) goto OnErrorExit;
+ // Push AFB client context on the stack
+ count ++;
+ lua_pushlightuserdata(luaState, timer);
+ if (!afbSource) goto OnErrorExit;
+
// Push user Context
count+= LuaPushArgument(LuaCbHandle->source, LuaCbHandle->context);
@@ -1014,13 +1019,14 @@ STATIC int LuaTimerSet(lua_State* luaState) {
json_object *contextJ = LuaPopOneArg(source, luaState, LUA_FIST_ARG + 3);
if (lua_gettop(luaState) != LUA_FIST_ARG+3 || !timerJ || !callback || !contextJ) {
- lua_pushliteral(luaState, "LuaTimerSet-Syntax timerset (source, timerT, 'callback', contextT)");
+ lua_pushliteral(luaState, "LuaTimerSet: Syntax timerset (source, timerT, 'callback', contextT)");
goto OnErrorExit;
}
int err = wrap_json_unpack(timerJ, "{ss, s?s si, si !}", "uid", &uid, "info", &info, "delay", &delay, "count", &count);
if (err) {
- lua_pushliteral(luaState, "LuaTimerSet-Syntax timerT={uid:xxx delay:ms, count:xx}");
+
+ lua_pushliteral(luaState, "LuaTimerSet: Syntax timerT={uid:xxx delay:ms, count:xx}");
goto OnErrorExit;
}