luat_lib_wlan.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. @module wlan
  3. @summary wifi操作
  4. @catalog 外设API
  5. @version 1.0
  6. @date 2022.09.30
  7. @demo wlan
  8. @tag LUAT_USE_WLAN
  9. @usage
  10. --[[
  11. 提醒:
  12. 对于仅支持wifiscan的模块, 仅 init/scan/scanResult 函数是可用的
  13. 例如: Air780E/Air600E/Air780EG等仅支持wifiscan
  14. ]]
  15. */
  16. #include "luat_base.h"
  17. #include "luat_wlan.h"
  18. #define LUAT_LOG_TAG "wlan"
  19. #include "luat_log.h"
  20. uint32_t ipaddr_addr(const char *cp);
  21. static inline void to_ipv4(const char* data, uint8_t* dst) {
  22. uint32_t tmpip = ipaddr_addr(data);
  23. dst[3] = (tmpip >> 24) & 0xFF;
  24. dst[2] = (tmpip >> 16) & 0xFF;
  25. dst[1] = (tmpip >> 8) & 0xFF;
  26. dst[0] = (tmpip >> 0) & 0xFF;
  27. }
  28. /*
  29. 初始化
  30. @api wlan.init()
  31. @return bool 成功返回true,否则返回false
  32. */
  33. static int l_wlan_init(lua_State* L){
  34. int ret = luat_wlan_init(NULL);
  35. lua_pushboolean(L, ret == 0 ? 1 : 0);
  36. return 1;
  37. }
  38. /*
  39. 设置wifi模式
  40. @api wlan.setMode(mode)
  41. @int wifi模式
  42. @return bool 成功返回true,否则返回false
  43. @usage
  44. -- 设置为AP模式, 广播ssid, 接收wifi客户端的链接
  45. wlan.setMode(wlan.AP)
  46. -- 设置为STATION模式, 也是初始化后的默认模式
  47. wlan.setMode(wlan.STATION)
  48. -- 混合模式, 做AP又做STATION
  49. wlan.setMode(wlan.APSTA)
  50. */
  51. static int l_wlan_mode(lua_State* L){
  52. int mode = LUAT_WLAN_MODE_STA;
  53. if (lua_isinteger(L, 1)) {
  54. mode = lua_tointeger(L, 1);
  55. }
  56. else if (lua_isinteger(L, 2)) {
  57. mode = lua_tointeger(L, 2);
  58. }
  59. if (mode <= LUAT_WLAN_MODE_NULL || mode >= LUAT_WLAN_MODE_MAX) {
  60. mode = LUAT_WLAN_MODE_STA;
  61. }
  62. // switch (mode)
  63. // {
  64. // case LUAT_WLAN_MODE_NULL:
  65. // LLOGD("wlan mode NULL");
  66. // break;
  67. // case LUAT_WLAN_MODE_STA:
  68. // LLOGD("wlan mode STATION");
  69. // break;
  70. // case LUAT_WLAN_MODE_AP:
  71. // LLOGD("wlan mode AP");
  72. // break;
  73. // case LUAT_WLAN_MODE_APSTA:
  74. // LLOGD("wlan mode AP-STATION");
  75. // break;
  76. // default:
  77. // break;
  78. // }
  79. luat_wlan_config_t conf = {
  80. .mode = mode
  81. };
  82. int ret = luat_wlan_mode(&conf);
  83. lua_pushboolean(L, ret == 0 ? 1 : 0);
  84. return 1;
  85. }
  86. /*
  87. 作为STATION时,是否已经连接上AP,且获取IP成功
  88. @api wlan.ready()
  89. @return bool 已经连接成功返回true,否则返回false
  90. */
  91. static int l_wlan_ready(lua_State* L){
  92. lua_pushboolean(L, luat_wlan_ready());
  93. return 1;
  94. }
  95. /*
  96. 作为STATION时,连接到指定AP
  97. @api wlan.connect(ssid, password, auto_reconnect)
  98. @string AP的ssid
  99. @string AP的password,可选
  100. @int 0关闭自动重连,1开启自动重连.当前强制开启自动重连
  101. @return bool 发起连接成功返回true,否则返回false.注意,不代表连接AP成功!!
  102. @usage
  103. -- 普通模式,带密码
  104. wlan.connect("myap", "12345678")
  105. -- 普通模式,不带密码
  106. wlan.connect("myap")
  107. -- 特殊模式, 重用之前的ssid和密码,本次直接连接
  108. -- 注意, 前提是本次上电后已经传过ssid和或password,否则必失败
  109. wlan.connect()
  110. */
  111. static int l_wlan_connect(lua_State* L){
  112. const char* ssid = luaL_optstring(L, 1, "");
  113. const char* password = luaL_optstring(L, 2, "");
  114. luat_wlan_conninfo_t info = {0};
  115. info.auto_reconnection = 1;
  116. memcpy(info.ssid, ssid, strlen(ssid));
  117. memcpy(info.password, password, strlen(password));
  118. int ret = luat_wlan_connect(&info);
  119. lua_pushboolean(L, ret == 0 ? 1 : 0);
  120. return 1;
  121. }
  122. /*
  123. 作为STATION时,断开AP
  124. @api wlan.disconnect()
  125. */
  126. static int l_wlan_disconnect(lua_State* L){
  127. (void)L;
  128. luat_wlan_disconnect();
  129. return 0;
  130. }
  131. /*
  132. 扫描wifi频段
  133. @api wlan.scan()
  134. @usage
  135. -- 注意, wlan.scan()是异步API,启动扫描后会马上返回
  136. -- wifi扫描成功后, 会有WLAN_SCAN_DONE消息, 读取即可
  137. sys.subscribe("WLAN_SCAN_DONE", function ()
  138. local results = wlan.scanResult()
  139. log.info("scan", "results", #results)
  140. for k,v in pairs(results) do
  141. log.info("scan", v["ssid"], v["rssi"], (v["bssid"]:toHex()))
  142. end
  143. end)
  144. -- 下面演示的是初始化wifi后定时扫描,请按实际业务需求修改
  145. sys.taskInit(function()
  146. sys.wait(1000)
  147. wlan.init()
  148. while 1 do
  149. wlan.scan()
  150. sys.wait(15000)
  151. end
  152. end)
  153. */
  154. static int l_wlan_scan(lua_State* L){
  155. (void)L;
  156. luat_wlan_scan();
  157. return 0;
  158. }
  159. /*
  160. 获取wifi扫描结果
  161. @api wlan.scanResult()
  162. @return table 扫描结果
  163. @usage
  164. -- 用法请查阅 wlan.scan() 函数
  165. */
  166. static int l_wlan_scan_result(lua_State* L) {
  167. int ap_limit = luaL_optinteger(L, 1, 20);
  168. if (ap_limit > 32)
  169. ap_limit = 32;
  170. else if (ap_limit < 8)
  171. ap_limit = 8;
  172. lua_newtable(L);
  173. luat_wlan_scan_result_t *results = luat_heap_malloc(sizeof(luat_wlan_scan_result_t) * ap_limit);
  174. if (results == NULL) {
  175. LLOGE("out of memory when malloc scan result");
  176. return 1;
  177. }
  178. memset(results, 0, sizeof(luat_wlan_scan_result_t) * ap_limit);
  179. int len = luat_wlan_scan_get_result(results, ap_limit);
  180. for (int i = 0; i < len; i++)
  181. {
  182. lua_newtable(L);
  183. lua_pushstring(L, (const char *)results[i].ssid);
  184. lua_setfield(L, -2, "ssid");
  185. // lua_pushfstring(L, "%02X%02X%02X%02X%02X%02X", results[i].bssid[0],
  186. // results[i].bssid[1],
  187. // results[i].bssid[2],
  188. // results[i].bssid[3],
  189. // results[i].bssid[4],
  190. // results[i].bssid[5]);
  191. lua_pushlstring(L, (const char *)results[i].bssid, 6);
  192. lua_setfield(L, -2, "bssid");
  193. lua_pushinteger(L, results[i].ch);
  194. lua_setfield(L, -2, "channel");
  195. lua_pushinteger(L, results[i].rssi);
  196. lua_setfield(L, -2, "rssi");
  197. lua_seti(L, -2, i + 1);
  198. }
  199. luat_heap_free(results);
  200. return 1;
  201. }
  202. /*
  203. 配网
  204. @api wlan.smartconfig(mode)
  205. @int 配网模式, 默认为esptouch, 若传0则主动停止配网
  206. @return bool 启动成功或停止成功, 返回true, 否则返回false
  207. @usage
  208. wlan.smartconfig()
  209. local ret, ssid, passwd = sys.waitUntil("SC_RESULT", 180*1000) -- 最多等3分钟
  210. log.info("sc", ret, ssid, passwd)
  211. -- 详细用法请查看demo
  212. */
  213. static int l_wlan_smartconfig(lua_State *L) {
  214. int tp = luaL_optinteger(L, 1, LUAT_SC_TYPE_ESPTOUCH);
  215. if (tp == LUAT_SC_TYPE_STOP) {
  216. luat_wlan_smartconfig_stop();
  217. lua_pushboolean(L, 1);
  218. }
  219. else {
  220. int ret = luat_wlan_smartconfig_start(tp);
  221. lua_pushboolean(L, ret == 0 ? 1 : 0);
  222. }
  223. return 1;
  224. }
  225. /*
  226. 获取mac
  227. @api wlan.getMac(tp, hexstr)
  228. @int 设置何种mac地址,对ESP32系列来说,只能设置STA的地址,即0,默认值也是0
  229. @bool 是否转HEX字符, 默认是true,即输出hex字符串
  230. @return string MAC地址,十六进制字符串形式 "AABBCCDDEEFF" 或原始数据
  231. log.info("wlan mac", wlan.getMac())
  232. */
  233. static int l_wlan_get_mac(lua_State* L){
  234. char tmp[6] = {0};
  235. char tmpbuff[16] = {0};
  236. luat_wlan_get_mac(luaL_optinteger(L, 1, 0), tmp);
  237. if (lua_isboolean(L, 2) && !lua_toboolean(L, 2)) {
  238. lua_pushlstring(L, tmp, 6);
  239. }
  240. else {
  241. sprintf_(tmpbuff, "%02X%02X%02X%02X%02X%02X", tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5]);
  242. lua_pushstring(L, tmpbuff);
  243. }
  244. return 1;
  245. }
  246. /*
  247. 设置mac
  248. @api wlan.setMac(tp, mac)
  249. @int 设置何种mac地址,对ESP32系列来说,只能设置STA的地址,即0
  250. @string 待设置的MAC地址,长度6字节
  251. @return bool 成功返回true,否则返回false
  252. @usage
  253. -- 设置MAC地址, 2023-03-01之后编译的固件可用
  254. local mac = string.fromHex("F01122334455")
  255. wlan.setMac(0, mac)
  256. -- 部分模块支持恢复默认MAC, 例如esp32系列
  257. -- 在2023-11-01 之后编译的固件可用
  258. local mac = string.fromHex("000000000000")
  259. wlan.setMac(0, mac)
  260. */
  261. static int l_wlan_set_mac(lua_State* L){
  262. // int id = luaL_optinteger(L, 1, 0);
  263. const char* mac = luaL_checkstring(L, 2);
  264. int ret = luat_wlan_set_mac(luaL_optinteger(L, 1, 0), mac);
  265. lua_pushboolean(L, ret == 0 ? 1 : 0);
  266. return 1;
  267. }
  268. /*
  269. 获取ip,仅STATION或APSTA模式下有意义
  270. @api wlan.getIP()
  271. @return string ip地址,当前仅返回ipv4地址,例如 "192.168.1.25"
  272. */
  273. static int l_wlan_get_ip(lua_State* L){
  274. char tmpbuff[16] = {0};
  275. luat_wlan_get_ip(luaL_optinteger(L, 1, 0), tmpbuff);
  276. lua_pushstring(L, tmpbuff);
  277. return 1;
  278. }
  279. /*
  280. 启动AP
  281. @api wlan.createAP(ssid, passwd, gateway, netmask, channel, opts)
  282. @string AP的SSID,必填
  283. @string AP的密码,可选
  284. @string AP的网关地址, 默认192.168.4.1
  285. @string AP的网关掩码, 默认255.255.255.0
  286. @int AP建立的通道, 默认6
  287. @table AP的配置选项, 可选
  288. @return bool 成功创建返回true,否则返回false
  289. @usage
  290. -- 注意, 调用本AP时,若wifi模式为STATION,会自动切换成 APSTA
  291. wlan.createAP("luatos1234", "12341234")
  292. -- 设置网关IP,掩码, 通道, 2023.7.13 新增, BSP未必支持
  293. -- wlan.createAP("luatos1234", "12341234", "192.168.4.1", "255.255.255.0", 6)
  294. -- opts更多配置项, 2024.3.5新增
  295. --[[
  296. {
  297. hidden = false, -- 是否隐藏SSID, 默认false,不隐藏
  298. max_conn = 4 -- 最大客户端数量, 默认4
  299. }
  300. ]]
  301. */
  302. #include "lwip/opt.h"
  303. #include "lwip/ip_addr.h"
  304. #include "lwip/netif.h"
  305. static int l_wlan_ap_start(lua_State *L) {
  306. size_t ssid_len = 0;
  307. size_t password_len = 0;
  308. luat_wlan_apinfo_t apinfo = {0};
  309. const char* ssid = luaL_checklstring(L, 1, &ssid_len);
  310. const char* password = luaL_optlstring(L, 2, "", &password_len);
  311. const char* gateway = luaL_optstring(L, 3, "192.168.4.1");
  312. const char* netmask = luaL_optstring(L, 4, "255.255.255.0");
  313. if (strlen(gateway) > 7) {
  314. to_ipv4(gateway, apinfo.gateway);
  315. }
  316. if (strlen(netmask) > 7) {
  317. to_ipv4(netmask, apinfo.netmask);
  318. }
  319. apinfo.channel = (uint8_t)luaL_optinteger(L, 5, 6);
  320. if (ssid_len < 1) {
  321. LLOGE("ssid MUST NOT EMTRY");
  322. return 0;
  323. }
  324. if (ssid_len > 32) {
  325. LLOGE("ssid too long [%s]", ssid);
  326. return 0;
  327. }
  328. if (password_len > 63) {
  329. LLOGE("password too long [%s]", password);
  330. return 0;
  331. }
  332. if (lua_istable(L, 6)) {
  333. lua_getfield(L, 6, "hidden");
  334. apinfo.hidden = lua_toboolean(L, -1);
  335. lua_pop(L, 1);
  336. lua_getfield(L, 6, "max_conn");
  337. apinfo.max_conn = lua_tonumber(L, -1);
  338. lua_pop(L, 1);
  339. }
  340. memcpy(apinfo.ssid, ssid, ssid_len);
  341. memcpy(apinfo.password, password, password_len);
  342. int ret = luat_wlan_ap_start(&apinfo);
  343. if (ret)
  344. LLOGD("apstart ret %d", ret);
  345. lua_pushboolean(L, ret == 0 ? 1 : 0);
  346. return 1;
  347. }
  348. /**
  349. 关闭AP功能
  350. @api wlan.stopAP()
  351. @return bool 成功创建返回true,否则返回false
  352. @usage
  353. wlan.stopAP()
  354. */
  355. static int l_wlan_ap_stop(lua_State *L) {
  356. int ret = luat_wlan_ap_stop();
  357. if (ret)
  358. LLOGD("apstop ret %d", ret);
  359. lua_pushboolean(L, ret == 0 ? 1 : 0);
  360. return 1;
  361. }
  362. /*
  363. 获取信息,如AP的bssid,信号强度, STA联网后可获取
  364. @api wlan.getInfo()
  365. @return table 详情,键值对形式
  366. @usage
  367. log.info("wlan", "info", json.encode(wlan.getInfo()))
  368. --[[
  369. 典型输出
  370. {
  371. "bssid" : "xxxxxx",
  372. "rssi" : -89,
  373. "gw" : "192.168.1.1"
  374. }
  375. ]]
  376. */
  377. static int l_wlan_get_info(lua_State *L) {
  378. char buff[48] = {0};
  379. char buff2[32] = {0};
  380. lua_newtable(L);
  381. luat_wlan_get_ap_bssid(buff);
  382. sprintf_(buff2, "%02X%02X%02X%02X%02X%02X", buff[0], buff[1], buff[2], buff[3], buff[4], buff[5]);
  383. lua_pushstring(L, buff2);
  384. lua_setfield(L, -2, "bssid");
  385. memset(buff, 0, 48);
  386. luat_wlan_get_ap_gateway(buff);
  387. lua_pushstring(L, buff);
  388. lua_setfield(L, -2, "gw");
  389. lua_pushinteger(L, luat_wlan_get_ap_rssi());
  390. lua_setfield(L, -2, "rssi");
  391. return 1;
  392. }
  393. /*
  394. 读取或设置省电模式
  395. @api wlan.powerSave(mode)
  396. @int 省电模式,可选, 传入就是设置, 例如wlan.PS_NONE
  397. @return int 当前省电模式/设置后的省电模式
  398. @usage
  399. -- 请查阅常量表 PS_NONE/PS_MIN_MODEM/PS_MAX_MODEM
  400. log.info("wlan", "PS", wlan.powerSave(wlan.PS_NONE))
  401. -- 本API于 2023.03.31 新增
  402. */
  403. static int l_wlan_powerSave(lua_State *L) {
  404. int mode = 0;
  405. if (lua_isinteger(L, 1)) {
  406. mode = luaL_checkinteger(L, 1);
  407. luat_wlan_set_ps(mode);
  408. }
  409. mode = luat_wlan_get_ps();
  410. lua_pushinteger(L, mode);
  411. return 1;
  412. }
  413. /*
  414. 读取或设置Hostname
  415. @api wlan.hostname(new_name)
  416. @string 新的hostname,可选, 传入就是设置
  417. @return string 当前的hostname或者设置后的hostname
  418. @usage
  419. -- 本API于 2023.07.23 新增
  420. -- 本函数应该在wlan.init之前设置好, 最晚应早于wlan.connect
  421. -- hostname的默认值是 "LUATOS_" + 设备的MAC值
  422. -- 例如: LUATOS_0022EECC2399
  423. wlan.hostname("我的wifi物联网设备")
  424. */
  425. static int l_wlan_get_set_hostname(lua_State *L) {
  426. if (lua_isstring(L, 1)) {
  427. size_t len = 0;
  428. const char* hostname = luaL_checklstring(L, 1, &len);
  429. if (len > 0) {
  430. if (len > 31) {
  431. LLOGE("hostname is too long");
  432. return 0;
  433. }
  434. luat_wlan_set_hostname(0, hostname);
  435. }
  436. }
  437. const char* tmp = luat_wlan_get_hostname(0);
  438. lua_pushstring(L, tmp);
  439. return 1;
  440. }
  441. /*
  442. 设置Station模式下的IP获取模式
  443. @api wlan.staIp(dhcp_enable, ip, netmask, gateway)
  444. @bool 是否启用DHCP,默认是true
  445. @string 本机IP地址,例如192.168.2.200, 禁用DHCP时必填
  446. @string 本机IP掩码,例如255.255.255.0, 禁用DHCP时必填
  447. @string 本机IP网关,例如192.168.2.1, 禁用DHCP时必填
  448. @return bool 成功返回true,否则返回false
  449. @usage
  450. -- 本API于 2023.10.06 新增
  451. -- 本函数需要在wlan.init之后才允许调用
  452. -- 启用DHCP, 默认也是启用DHCP,这里是演示API使用
  453. wlan.staIp(true)
  454. -- 禁用DHCP,自行设置IP/掩码/网关
  455. wlan.staIp(false, "192.168.2.200", "255.255.255.0", "192.168.2.1")
  456. */
  457. static int l_wlan_set_sta_ip(lua_State *L) {
  458. luat_wlan_station_info_t info = {
  459. .dhcp_enable = 1
  460. };
  461. const char *data = NULL;
  462. size_t len = 0;
  463. // 是否DHCP
  464. if (lua_isinteger(L, 1))
  465. info.dhcp_enable = luaL_optinteger(L, 1, 1);
  466. else if (lua_isboolean(L, 1))
  467. info.dhcp_enable = lua_toboolean(L, 1);
  468. // 本地IP
  469. data = luaL_optlstring(L, 2, "192.168.1.201", &len);
  470. to_ipv4(data, info.ipv4_addr);
  471. // 掩码
  472. data = luaL_optlstring(L, 3, "255.255.255.0", &len);
  473. to_ipv4(data, info.ipv4_netmask);
  474. // 网关
  475. data = luaL_optlstring(L, 4, "192.168.1.1", &len);
  476. to_ipv4(data, info.ipv4_gateway);
  477. int ret = luat_wlan_set_station_ip(&info);
  478. lua_pushboolean(L, ret == 0 ? 1 : 0);
  479. return 1;
  480. }
  481. #include "rotable2.h"
  482. static const rotable_Reg_t reg_wlan[] =
  483. {
  484. { "init", ROREG_FUNC(l_wlan_init)},
  485. { "scan", ROREG_FUNC(l_wlan_scan)},
  486. { "scanResult", ROREG_FUNC(l_wlan_scan_result)},
  487. #ifndef LUAT_USE_WLAN_SCANONLY
  488. { "mode", ROREG_FUNC(l_wlan_mode)},
  489. { "setMode", ROREG_FUNC(l_wlan_mode)},
  490. { "ready", ROREG_FUNC(l_wlan_ready)},
  491. { "connect", ROREG_FUNC(l_wlan_connect)},
  492. { "disconnect", ROREG_FUNC(l_wlan_disconnect)},
  493. // 配网相关
  494. { "smartconfig", ROREG_FUNC(l_wlan_smartconfig)},
  495. { "getIP", ROREG_FUNC(l_wlan_get_ip)},
  496. { "getInfo", ROREG_FUNC(l_wlan_get_info)},
  497. { "getMac", ROREG_FUNC(l_wlan_get_mac)},
  498. { "setMac", ROREG_FUNC(l_wlan_set_mac)},
  499. { "hostname", ROREG_FUNC(l_wlan_get_set_hostname)},
  500. { "powerSave", ROREG_FUNC(l_wlan_powerSave)},
  501. { "staIp", ROREG_FUNC(l_wlan_set_sta_ip)},
  502. // AP相关
  503. { "createAP", ROREG_FUNC(l_wlan_ap_start)},
  504. { "stopAP", ROREG_FUNC(l_wlan_ap_stop)},
  505. // wifi模式
  506. //@const NONE WLAN模式,停用
  507. {"NONE", ROREG_INT(LUAT_WLAN_MODE_NULL)},
  508. //@const STATION WLAN模式,STATION模式,主动连AP
  509. {"STATION", ROREG_INT(LUAT_WLAN_MODE_STA)},
  510. //@const AP WLAN模式,AP模式,接受STATION连接
  511. {"AP", ROREG_INT(LUAT_WLAN_MODE_AP)},
  512. //@const AP WLAN模式,混合模式
  513. {"STATIONAP", ROREG_INT(LUAT_WLAN_MODE_APSTA)},
  514. // 配网模式
  515. //@const STOP 停止配网
  516. {"STOP", ROREG_INT(LUAT_SC_TYPE_STOP)},
  517. //@const ESPTOUCH esptouch配网, V1
  518. {"ESPTOUCH", ROREG_INT(LUAT_SC_TYPE_ESPTOUCH)},
  519. //@const AIRKISS Airkiss配网, 微信常用
  520. {"AIRKISS", ROREG_INT(LUAT_SC_TYPE_AIRKISS)},
  521. //@const ESPTOUCH_AIRKISS esptouch和Airkiss混合配网
  522. {"ESPTOUCH_AIRKISS", ROREG_INT(LUAT_SC_TYPE_ESPTOUCH_AIRKISS)},
  523. //@const ESPTOUCH_V2 esptouch配网, V2, 未测试
  524. {"ESPTOUCH_V2", ROREG_INT(LUAT_SC_TYPE_ESPTOUCH_V2)},
  525. //@const PS_NONE 关闭省电模式
  526. {"PS_NONE", ROREG_INT(0)},
  527. //@const PS_MIN_MODEM 最小Modem省电模式
  528. {"PS_MIN_MODEM", ROREG_INT(1)},
  529. //@const PS_MAX_MODEM 最大Modem省电模式
  530. {"PS_MAX_MODEM", ROREG_INT(2)},
  531. #endif
  532. { NULL, ROREG_INT(0)}
  533. };
  534. LUAMOD_API int luaopen_wlan( lua_State *L ) {
  535. luat_newlib2(L, reg_wlan);
  536. return 1;
  537. }