From 1f94d64f04197d94df61d95eade87948cb7a814c Mon Sep 17 00:00:00 2001 From: meng Date: Sun, 24 Mar 2024 21:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32c3/script/main copy.lua | 98 ------------------------------------ 1 file changed, 98 deletions(-) delete mode 100644 esp32c3/script/main copy.lua diff --git a/esp32c3/script/main copy.lua b/esp32c3/script/main copy.lua deleted file mode 100644 index 0e68185..0000000 --- a/esp32c3/script/main copy.lua +++ /dev/null @@ -1,98 +0,0 @@ -PROJECT = "sms_forwarder_wifi" -VERSION = "1.0.0" - -local sys = require("sys") -local config = require("config") -local constants = require("constants") -local air780 = require("air780_helper") -local led_helper = require("led_helper") -local utils = require("utils") - -require("sysplus") -require("notification_helper") - -if wdt then - wdt.init(9000) - sys.timerLoopStart(wdt.feed, 3000) -end - -log.setLevel(config.log_level) -log.style(1) - -log.info("bsp", rtos.bsp()) -log.info("mem_sys", rtos.meminfo("sys")) -log.info("mem_lua", rtos.meminfo("lua")) - --- 每秒完整GC一次,防止内存不足问题 -sys.timerLoopStart(function() - collectgarbage("collect") -end, 1000) - -led_helper.blink_status_led(constants.led_blink_duration.initializing) - -sys.taskInit(function() - local logging_tag = "main - 初始化网络" - log.info(logging_tag, "正在连接无线网络"..config.wifi.ssid) - wlan.init() - wlan.setMode(wlan.STATION) - wlan.connect(config.wifi["ssid"], config.wifi.password) - sys.waitUntil("IP_READY") - local ip_address = wlan.getIP() - log.info(logging_tag, "无线网络连接成功,IP地址:"..ip_address) - - for index, value in ipairs(config.dns_servers) do - log.info(logging_tag, "配置第"..index.."个DNS服务器为"..value) - socket.setDNS(nil, index, value) - end - - log.info(logging_tag, "等待时间同步") - sys.waitUntil("NTP_UPDATE") - log.info(logging_tag, "时间同步完成") -end) - -sys.taskInit(function () - local logging_tag = "main - 初始化Air780" - local at_command_result - - - if config.disable_netled then - log.info(logging_tag, "正在关闭NET灯闪烁") - air780.send_at_command("AT+CNETLIGHT=0") - end - - log.info(logging_tag, "初始化完成,等待新短信...") - - -- 测试短信推送,解除注释可开机时自动模拟推送一条,用于模块独立测试 - -- sys.publish( - -- constants.air780_message_topic_new_notification_request, - -- '10086', - -- '测试短信内容') - - led_helper.light_status_led() -end) - --- 收到新消息派发推送 -sys.subscribe(constants.air780_message_topic_new_sms_received, -function(data) - led_helper.blink_working_led(constants.led_blink_duration.working) - sms_content = table.concat(data, "\n") - if sms_content then - log.info("main", "收到短信:"..sms_content) - sys.publish( - constants.air780_message_topic_new_notification_request, - sms_content) - led_helper.shut_working_led() - return - - else - log.info("main", "收到来自"..phone_number.."的短信,即将转发...") - sys.publish( - constants.air780_message_topic_new_notification_request, - sms_content) - led_helper.shut_working_led() - return - end -end) - - -sys.run()