Browse Source

add:继续完善topic

Dozingfiretruck 4 years ago
parent
commit
189271eb08

+ 88 - 0
luat/modules/luat_lib_ctiot.c

@@ -156,6 +156,16 @@ static int luat_ctiot_msg_handler(lua_State *L, void* ptr)
 	}
 	lua_getglobal(L, "sys_pub");
 	lua_pushstring(L, tag);
+/*
+@sys_pub ctiot
+CTIOT 接收回调消息
+CTIOT_RX
+@string data, CTIOT 接收数据
+@usage
+sys.subscribe("CTIOT_RX", function(data)
+    log.info("CTIOT_RX", data:toHex())
+end)
+*/
 	if (CTIOT_EVENT_RX == type)
 	{
 		lua_pushlstring(L, buff + 6, len);
@@ -163,6 +173,84 @@ static int luat_ctiot_msg_handler(lua_State *L, void* ptr)
 	}
 	else
 	{
+/*
+@sys_pub ctiot
+CTIOT 发送回调消息
+CTIOT_TX
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_TX", function (error, error_code, param)
+    log.info("CTIOT_TX", error, error_code, param)
+end)
+*/
+
+/*
+@sys_pub ctiot
+CTIOT REG回调消息
+CTIOT_REG
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_REG", function (error, error_code, param)
+    log.info("CTIOT_REG", error, error_code, param)
+end)
+*/
+
+/*
+@sys_pub ctiot
+CTIOT DEREG回调消息
+CTIOT_DEREG
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_DEREG", function (error, error_code, param)
+    log.info("CTIOT_DEREG", error, error_code, param)
+end)
+*/
+
+/*
+@sys_pub ctiot
+CTIOT 唤醒回调消息
+CTIOT_WAKEUP
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_WAKEUP", function (error, error_code, param)
+    log.info("CTIOT_WAKEUP", error, error_code, param)
+end)
+*/
+
+/*
+@sys_pub ctiot
+CTIOT 其他回调消息
+CTIOT_OTHER
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_OTHER", function (error, error_code, param)
+    log.info("CTIOT_OTHER", error, error_code, param)
+end)
+*/
+
+/*
+@sys_pub ctiot
+CTIOT FOTA回调消息
+CTIOT_FOTA
+@bool error, 是否成功
+@number error_code, 错误代码
+@number param, 数据
+@usage
+sys.subscribe("CTIOT_FOTA", function (error, error_code, param)
+    log.info("CTIOT_FOTA", error, error_code, param)
+end)
+*/
+
 		lua_pushboolean(L, error);
 		lua_pushinteger(L, error_code);
 		lua_pushinteger(L, param);

+ 15 - 0
luat/modules/luat_lib_keyboard.c

@@ -16,6 +16,21 @@
 static int l_keyboard_handler(lua_State *L, void* ptr) {
     rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
     lua_getglobal(L, "sys_pub");
+/*
+@sys_pub keyboard
+键盘矩阵消息
+KB_INC
+@number port, keyboard id 当前固定为0, 可以无视
+@number data, keyboard 按键 需要配合init的map进行解析
+@number state, 按键状态 1 为按下, 0 为 释放
+@usage
+sys.subscribe("KB_INC", function(port, data, state)
+    -- port 当前固定为0, 可以无视
+    -- data, 需要配合init的map进行解析
+    -- state, 1 为按下, 0 为 释放
+    log.info("keyboard", port, data, state)
+end)
+*/
     lua_pushstring(L, "KB_INC");
     lua_pushinteger(L, msg->arg1);
     lua_pushinteger(L, msg->arg2);

+ 10 - 0
luat/modules/luat_lib_socket.c

@@ -87,6 +87,16 @@ static int luat_lib_netc_msg_handler(lua_State* L, void* ptr) {
             sprintf(buff, "NETC_END_%x", ent->netc_id);
             //LLOGD("FUCK [%s]", buff);
             lua_pushstring(L, buff);
+/*
+@sys_pub socket
+连接断开
+NETC_END_xx
+@usage
+sys.taskInit(function()
+    sys.waitUntil("NETC_END_".. id, 30000)
+    log.info("GET NETC_END or timeout")
+end)
+*/
             lua_call(L, 1, 0);
         }
         if (ent->lua_ref) {

+ 13 - 0
luat/modules/luat_lib_touchkey.c

@@ -59,6 +59,19 @@ int l_touchkey_handler(lua_State *L, void* ptr) {
         lua_pushinteger(L, 0);
         return 1;
     }
+/*
+@sys_pub touchkey
+触摸按键消息
+TOUCHKEY_INC
+@number port, 传感器id
+@number state, 计数器,触摸次数统计
+@usage
+sys.subscribe("TOUCHKEY_INC", function(id, count)
+    -- 传感器id
+    -- 计数器,触摸次数统计
+    log.info("touchkey", id, count)
+end)
+*/
     lua_pushliteral(L, "TOUCHKEY_INC");
     lua_pushinteger(L, msg->arg1);
     lua_pushinteger(L, msg->arg2);