aboutsummaryrefslogtreecommitdiffstats
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
committerRonan Le Martret <ronan.lemartret@iot.bzh>2017-11-24 10:37:52 +0100
commit3e6dbb17336cade4abf270193c164ea60b7b8389 (patch)
treefbb15fa89b8a98ba5a43565b98cb91c3253b65f3 /ctl-lib/ctl-lua.c
parent12dc78f18e54b92332ddd33c785b0d1e0352410b (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;
}