Merge branch '0wQ:main' into main

This commit is contained in:
机丸 2023-04-18 10:49:37 +08:00 committed by GitHub
commit af39f6004e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 73 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# Air780E 短信转发 # Air700E / Air780E / Air780EG 短信转发
## 保姆级教程https://kdocs.cn/l/coe1ozIlSX70 ## 保姆级教程https://kdocs.cn/l/coe1ozIlSX70
@ -13,6 +13,8 @@
- [x] [企业微信群机器人 WeCom](https://developer.work.weixin.qq.com/document/path/91770) - [x] [企业微信群机器人 WeCom](https://developer.work.weixin.qq.com/document/path/91770)
- [x] [Pushover](https://pushover.net/api) - [x] [Pushover](https://pushover.net/api)
- [x] [邮件 next-smtp-proxy](https://github.com/0wQ/next-smtp-proxy) - [x] [邮件 next-smtp-proxy](https://github.com/0wQ/next-smtp-proxy)
- [x] [Gotify](https://gotify.net)
- [x] [Inotify](https://github.com/xpnas/Inotify) / [合宙官方的推送服务](https://push.luatos.org)
- [x] 通过短信控制设备 - [x] 通过短信控制设备
- [x] 发短信, 格式: `SMS,10010,余额查询` - [x] 发短信, 格式: `SMS,10010,余额查询`
- [x] 定时基站定位 - [x] 定时基站定位
@ -29,7 +31,7 @@
### 2. 烧录脚本 ### 2. 烧录脚本
> 推荐使用 `core` 目录下的固件, 本项目可能会使用一些合宙官方固件还未更新的 API > 推荐使用 `core` 目录下的固件
> >
> `core` 目录下文件名中带有 `RNDIS` 的, 支持 RNDIS 网卡功能, 如果 SIM 卡流量不多请勿选择 > `core` 目录下文件名中带有 `RNDIS` 的, 支持 RNDIS 网卡功能, 如果 SIM 卡流量不多请勿选择

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
return { return {
-- 通知类型, 支持配置多个 -- 通知类型, 支持配置多个
-- NOTIFY_TYPE = {"telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "inotify", "next-smtp-proxy"}, -- NOTIFY_TYPE = {"telegram", "pushdeer", "bark", "dingtalk", "feishu", "wecom", "pushover", "inotify", "next-smtp-proxy", "gotify"},
NOTIFY_TYPE = "pushdeer", NOTIFY_TYPE = "pushdeer",
-- --
-- telegram 通知配置, https://github.com/0wQ/telegram-notify -- telegram 通知配置, https://github.com/0wQ/telegram-notify
@ -31,6 +31,7 @@ return {
-- --
-- inotify 通知配置, https://github.com/xpnas/Inotify 或者使用合宙提供的 https://push.luatos.org -- inotify 通知配置, https://github.com/xpnas/Inotify 或者使用合宙提供的 https://push.luatos.org
INOTIFY_API = "https://push.luatos.org/XXXXXX.send", INOTIFY_API = "https://push.luatos.org/XXXXXX.send",
--
-- next-smtp-proxy 通知配置, https://github.com/0wQ/next-smtp-proxy -- next-smtp-proxy 通知配置, https://github.com/0wQ/next-smtp-proxy
NEXT_SMTP_PROXY_API = "", NEXT_SMTP_PROXY_API = "",
NEXT_SMTP_PROXY_USER = "", NEXT_SMTP_PROXY_USER = "",
@ -41,11 +42,17 @@ return {
NEXT_SMTP_PROXY_TO_EMAIL = "", NEXT_SMTP_PROXY_TO_EMAIL = "",
NEXT_SMTP_PROXY_SUBJECT = "来自 Air780E 的通知", NEXT_SMTP_PROXY_SUBJECT = "来自 Air780E 的通知",
-- --
-- gotify 通知配置, https://gotify.net/
GOTIFY_API = "",
GOTIFY_TITLE = "Air780E",
GOTIFY_PRIORITY = 8,
GOTIFY_TOKEN = "",
--
-- 定时查询流量间隔, 单位毫秒, 设置为 0 关闭 (建议检查 util_mobile.lua 文件中运营商号码和查询代码是否正确, 以免发错短信导致扣费, 收到查询结果短信发送通知会消耗流量) -- 定时查询流量间隔, 单位毫秒, 设置为 0 关闭 (建议检查 util_mobile.lua 文件中运营商号码和查询代码是否正确, 以免发错短信导致扣费, 收到查询结果短信发送通知会消耗流量)
QUERY_TRAFFIC_INTERVAL = 1000 * 60 * 60 * 6, QUERY_TRAFFIC_INTERVAL = 0,
-- --
-- 定时基站定位间隔, 单位毫秒, 设置为 0 关闭 (定位成功后会追加到通知内容后面, 基站定位本身会消耗流量, 通知内容增加也会导致流量消耗增加) -- 定时基站定位间隔, 单位毫秒, 设置为 0 关闭 (定位成功后会追加到通知内容后面, 基站定位本身会消耗流量, 通知内容增加也会导致流量消耗增加)
LOCATION_INTERVAL = 1000 * 60 * 30, LOCATION_INTERVAL = 0,
-- --
-- 开机通知 (会消耗流量) -- 开机通知 (会消耗流量)
BOOT_NOTIFY = true, BOOT_NOTIFY = true,
@ -54,7 +61,7 @@ return {
NOTIFY_APPEND_MORE_INFO = true, NOTIFY_APPEND_MORE_INFO = true,
-- --
-- 通知最大重发次数 -- 通知最大重发次数
NOTIFY_RETRY_MAX = 100, NOTIFY_RETRY_MAX = 20,
-- --
-- 开启低功耗模式, USB 断开连接无法查看日志, RNDIS 网卡会断开 -- 开启低功耗模式, USB 断开连接无法查看日志, RNDIS 网卡会断开
LOW_POWER_MODE = false, LOW_POWER_MODE = false,

View File

@ -127,14 +127,13 @@ sys.taskInit(
sys.wait(1000 * 15) sys.wait(1000 * 15)
log.warn("main", "即将关闭 usb 电源, 如需查看日志请在配置中关闭低功耗模式") log.warn("main", "即将关闭 usb 电源, 如需查看日志请在配置中关闭低功耗模式")
sys.wait(1000 * 5) sys.wait(1000 * 5)
gpio.setup(23, nil)
-- 关闭 USB gpio.close(33)
pm.power(pm.USB, false) pm.power(pm.USB, false) -- 关闭 USB
pm.power(pm.GPS, false) pm.power(pm.GPS, false)
pm.power(pm.GPS_ANT, false) pm.power(pm.GPS_ANT, false)
pm.power(pm.DAC_EN, false) pm.power(pm.DAC_EN, false)
-- 休眠 pm.force(pm.LIGHT) -- 进入休眠
pm.force(pm.LIGHT)
end end
end end
) )

View File

@ -2,9 +2,19 @@ local util_mobile = {}
-- 运营商数据 -- 运营商数据
local oper_data = { local oper_data = {
-- 中国移动
["46000"] = {"CM", "中国移动", {"10086", "CXLL"}}, ["46000"] = {"CM", "中国移动", {"10086", "CXLL"}},
["46002"] = {"CM", "中国移动", {"10086", "CXLL"}},
["46007"] = {"CM", "中国移动", {"10086", "CXLL"}},
-- 中国联通
["46001"] = {"CU", "中国联通", {"10010", "2082"}}, ["46001"] = {"CU", "中国联通", {"10010", "2082"}},
["46011"] = {"CT", "中国电信"}, ["46006"] = {"CU", "中国联通", {"10010", "2082"}},
["46009"] = {"CU", "中国联通", {"10010", "2082"}},
-- 中国电信
["46003"] = {"CT", "中国电信", {"10001", "108"}},
["46005"] = {"CT", "中国电信", {"10001", "108"}},
["46011"] = {"CT", "中国电信", {"10001", "108"}},
-- 中国广电
["46015"] = {"CB", "中国广电"} ["46015"] = {"CB", "中国广电"}
} }

View File

@ -31,6 +31,32 @@ local notify = {
log.info("util_notify", "POST", config.TELEGRAM_PROXY_API) log.info("util_notify", "POST", config.TELEGRAM_PROXY_API)
return util_http.fetch(nil, "POST", config.TELEGRAM_PROXY_API, header, msg) return util_http.fetch(nil, "POST", config.TELEGRAM_PROXY_API, header, msg)
end, end,
-- 发送到 gotify
["gotify"] = function(msg)
if config.GOTIFY_API == nil or config.GOTIFY_API == "" then
log.error("util_notify", "未配置 `config.GOTIFY_API`")
return
end
if config.GOTIFY_TOKEN == nil or config.GOTIFY_TOKEN == "" then
log.error("util_notify", "未配置 `config.GOTIFY_TOKEN`")
return
end
local url = config.GOTIFY_API .. "/message?token=" .. config.GOTIFY_TOKEN
local header = {
["Content-Type"] = "application/json; charset=utf-8"
}
local body = {
title = config.GOTIFY_TITLE,
message = msg,
priority = config.GOTIFY_PRIORITY
}
local json_data = json.encode(body)
json_data = string.gsub(json_data, "\\b", "\\n")
log.info("util_notify", "POST", config.GOTIFY_API)
return util_http.fetch(nil, "POST", url, header, json_data)
end,
-- 发送到 pushdeer -- 发送到 pushdeer
["pushdeer"] = function(msg) ["pushdeer"] = function(msg)
if config.PUSHDEER_API == nil or config.PUSHDEER_API == "" then if config.PUSHDEER_API == nil or config.PUSHDEER_API == "" then
@ -275,6 +301,23 @@ local function append()
msg = msg .. "\n频段: B" .. band msg = msg .. "\n频段: B" .. band
end end
-- 流量统计
local uplinkGB, uplinkB, downlinkGB, downlinkB = mobile.dataTraffic()
uplinkB = uplinkGB * 1024 * 1024 * 1024 + uplinkB
downlinkB = downlinkGB * 1024 * 1024 * 1024 + downlinkB
local function formatBytes(bytes)
if bytes < 1024 then
return bytes .. "B"
elseif bytes < 1024 * 1024 then
return string.format("%.2fKB", bytes / 1024)
elseif bytes < 1024 * 1024 * 1024 then
return string.format("%.2fMB", bytes / 1024 / 1024)
else
return string.format("%.2fGB", bytes / 1024 / 1024 / 1024)
end
end
-- msg = msg .. "\n流量: ↑" .. formatBytes(uplinkB) .. " ↓" .. formatBytes(downlinkB)
-- 位置 -- 位置
local _, _, map_link = util_location.get() local _, _, map_link = util_location.get()
if map_link ~= "" then if map_link ~= "" then