allen 5 лет назад
Родитель
Сommit
aed7a3cde6

+ 1 - 0
bsp/air302/src/luat_air302_base.c

@@ -47,6 +47,7 @@ static const luaL_Reg loadedlibs[] = {
   {"sensor", luaopen_sensor},          // 传感器库,当前支持DS18B20
   {"http",  luaopen_http},              // http库
   {"fs",    luaopen_fs},                // 文件系统库
+  {"ctiot",	luaopen_ctiot},				// ctiot库,NB专用
   {NULL, NULL}
 };
 

+ 1 - 0
luat/include/luat_base.h

@@ -90,6 +90,7 @@ LUAMOD_API int luaopen_pm( lua_State *L);
 LUAMOD_API int luaopen_m2m( lua_State *L);
 LUAMOD_API int luaopen_libcoap( lua_State *L);
 LUAMOD_API int luaopen_lpmem( lua_State *L);
+LUAMOD_API int luaopen_ctiot( lua_State *L);
 
 /** sprintf需要支持longlong值的打印, 提供平台无关的实现*/
 int l_sprintf(char *buf, size_t size, const char *fmt, ...);

+ 26 - 0
luat/include/luat_ctiot.h

@@ -0,0 +1,26 @@
+
+#include "luat_base.h"
+
+#define LUAT_PM_SLEEP_MODE_NONE     0	//系统处于活跃状态,未采取任何的降低功耗状态
+#define LUAT_PM_SLEEP_MODE_IDLE     1	//空闲模式,该模式在系统空闲时停止 CPU 和部分时钟,任意事件或中断均可以唤醒
+#define LUAT_PM_SLEEP_MODE_LIGHT    2	//轻度睡眠模式,CPU 停止,多数时钟和外设停止,唤醒后需要进行时间补偿
+#define LUAT_PM_SLEEP_MODE_DEEP     3	//深度睡眠模式,CPU 停止,仅少数低功耗外设工作,可被特殊中断唤醒
+#define LUAT_PM_SLEEP_MODE_STANDBY	4	//待机模式,CPU 停止,设备上下文丢失(可保存至特殊外设),唤醒后通常复位
+//#define LUAT_PM_SLEEP_MODE_SHUTDOWN	5	//关断模式,比 Standby 模式功耗更低, 上下文通常不可恢复, 唤醒后复位
+
+int luat_pm_request(int mode);
+
+int luat_pm_release(int mode);
+
+int luat_pm_dtimer_start(int id, size_t timeout);
+
+int luat_pm_dtimer_stop(int id);
+
+void luat_pm_cb(int event, int arg, void* args);
+
+int luat_pm_last_state(void);
+
+int luat_pm_force(int mode);
+
+int luat_pm_check(void);
+

+ 128 - 0
luat/modules/luat_lib_ctiot.c

@@ -0,0 +1,128 @@
+/*
+@module  ctiot
+@summary coap数据处理
+@version 1.0
+@date    2020.06.30
+*/
+#include "luat_base.h"
+#include "luat_timer.h"
+#include "luat_malloc.h"
+#include "luat_msgbus.h"
+
+#define LUAT_LOG_TAG "luat.ctiot"
+#include "luat_log.h"
+//---------------------------
+#ifdef AIR302
+extern void luat_ctiot_init(void);
+/**
+ * @brief 初始化ctiot,在复位开机后使用一次
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_init(lua_State *L)
+{
+	luat_ctiot_init();
+	return 0;
+}
+
+/**
+ * @brief 设置和读取ctiot相关参数,有参数输入则设置,无论是否有参数输入,均输出当前参数
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_param(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 设置和读取ctiot相关模式,有模式输入则设置,无论是否有模式输入,均输出当前模式
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_mode(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 连接CTIOT,必须在设置完参数和模式后再使用
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_connect(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 断开ctiot
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_disconnect(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 发送数据给ctiot
+ *
+ * @param L
+ * @return int
+ */
+static int l_ctiot_write(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 读取已经接收到的数据
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_read(lua_State *L)
+{
+
+}
+
+/**
+ * @brief 发送更新注册信息给ctiot
+ * 
+ * @param L 
+ * @return int 
+ */
+static int l_ctiot_update(lua_State *L)
+{
+
+}
+#endif
+
+
+#include "rotable.h"
+static const rotable_Reg reg_ctiot[] =
+{
+#ifdef AIR302
+    { "init", l_ctiot_init, 0},
+    { "param", l_ctiot_param, 0},
+	{ "mode", l_ctiot_mode, 0},
+	{ "connect", l_ctiot_connect, 0},
+	{ "disconnect", l_ctiot_disconnect, 0},
+	{ "write", l_ctiot_write, 0},
+	{ "read", l_ctiot_read, 0},
+	{ "update", l_ctiot_update, 0},
+    // ----- 类型常量
+#endif
+	{ NULL, NULL , 0}
+};
+
+LUAMOD_API int luaopen_ctiot( lua_State *L ) {
+    rotable_newlib(L, reg_ctiot);
+    return 1;
+}