0wQ / air780e-forwarder

合宙Air780系列4G模组,短信转发,来电通知,Air724在这里 -> https://github.com/0wQ/air724ug-forwarder
MIT License
313 stars 66 forks source link

大佬,得空是否可以考虑下国外同学的场景 #42

Closed kzh1980 closed 8 months ago

kzh1980 commented 8 months ago

我在国外测试这个项目,插入当地运营商的卡,出现了异常情况

  1. 刷的是 LuatOS-SoC_V1105_EC618.soc 的底包 + 转发的脚本。 用另外一台手机发短息到测试手机,可以看到 Luatool 的日志里,能看到这个短信,不过会提示:“当前设备处于漫游状态只使用 Serial 通信方式”

大佬不一定能重现这个场景,所以我把日志贴出来(已匿名化处理):

[2023-12-26 02:50:00.860][000000000.247] I/user.main 开机原因 0 0 3 [2023-12-26 02:50:00.863][000000000.411] self_info 125:model Air780E_A16 imei 86XXXXXXXXXXXXX [2023-12-26 02:50:00.866][000000000.423] I/user.util_location.refreshCellInfo start [2023-12-26 02:50:00.953][000000000.600] I/user.util_location.refreshCellInfo end [2023-12-26 02:50:00.960][000000000.602] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 02:50:01.213][000000000.865] D/mobile CSCON 1 [2023-12-26 02:50:02.837][000000002.480] D/mobile cid1, state0 [2023-12-26 02:50:02.840][000000002.484] D/mobile bearer act 0, result 0 [2023-12-26 02:50:02.842][000000002.485] D/mobile NETIF_LINK_ON -> IP_READY [2023-12-26 02:50:02.849][000000002.513] D/mobile TIME_SYNC 0 [2023-12-26 02:50:07.841][000000007.492] D/user.util_location.getMapLink
[2023-12-26 02:50:07.844][000000007.494] D/user.util_notify.add 添加到消息队列, 当前队列长度: 1 [2023-12-26 02:50:07.847][000000007.495] D/user.util_notify.add 添加到消息队列的内容: #BOOT\n\n本机号码: +65XXXXXXXX\n开机时长: 00:00:07\n运营商: XXXXX\n信号: -100dBm\n频段: B41 6 [2023-12-26 02:50:07.899][000000007.504] D/user.util_notify.poll 轮询消息队列中, 当前队列长度: 1 [2023-12-26 02:50:07.902][000000007.505] D/user.util_notify.poll 当前设备处于漫游状态只使用 Serial 通信方式 [2023-12-26 02:50:07.905][000000007.506] I/user.util_notify.send 发送通知 serial [2023-12-26 02:50:07.908][000000007.506] Uart_TxTaskSafe 1213:uart1,br 0, tx len 101 [2023-12-26 02:50:07.915][000000007.507] I/user.util_notify serial 消息已转发到串口 [2023-12-26 02:50:08.854][000000008.508] I/user.util_notify.send 发送通知成功 code: 200 body: nil [2023-12-26 02:50:12.237][000000011.898] D/mobile CSCON 0 [2023-12-26 02:53:57.026][000000236.681] D/mobile CSCON 1 [2023-12-26 02:53:57.134][000000236.781] luat_sms_nw_report_urc 1039:[DIO 1039]: The recv msg: phone: +65XXXXXXXX [2023-12-26 02:53:57.136][000000236.781] luat_sms_nw_report_urc 1044:[DIO 1044]: The recv msg: dcs: 0 | 0 | 165 | 0 [2023-12-26 02:53:57.140][000000236.781] luat_sms_nw_report_urc 1049:[DIO 1049]: The recv msg: sca: [+65YYYYYYYY] [2023-12-26 02:53:57.143][000000236.782] luat_sms_nw_report_urc 1062:[DIO 1062]: The recv msg: time: ["23/12/26,01:53:53 +28"] [2023-12-26 02:53:57.146][000000236.782] luat_sms_nw_report_urc 1076:[DIO 1076]: The recv msg: pdu: [18 | 41 | 25 | Wish u a Merry Christmas ] [2023-12-26 02:53:57.148][000000236.782] luat_sms_nw_report_urc 1082:[DIO 1082]: The recv msg: ieData 0 0 0 [2023-12-26 02:53:57.151][000000236.782] luat_sms_nw_report_urc 1084:[DIO 1084]: The recv msg: 41[079166390831C0DAA83C2A0032E6F87E7398F90058219D202162103533110F52408797A4066592ECF8B9161629667F4866] [2023-12-26 02:53:57.153][000000236.783] luat_sms_nw_report_urc 1085:[DIO 1085]: The recv msg: [079166390831C0DAA83C2A0032E6F87E7398F90058219D202162103533110F52408797A4066592ECF8B9161629667F4866] [2023-12-26 02:53:57.156][000000236.785] luat_sms_proc 1144:[DIO 1144]: CMI_SMS_NEW_MSG_IND is in [2023-12-26 02:53:57.160][000000236.786] D/sms dcs 0 | 0 | 0 | 0 [2023-12-26 02:53:57.163][000000236.788] I/user.smsCallback 2023/12/26 01:53:53 +65WWWWWWWW Wish u a Merry Christmas [2023-12-26 02:53:57.165][000000236.793] D/user.util_location.getMapLink
[2023-12-26 02:53:57.168][000000236.795] D/user.util_notify.add 添加到消息队列, 当前队列长度: 1 [2023-12-26 02:53:57.171][000000236.797] D/user.util_notify.add 添加到消息队列的内容: Wish u a Merry Christmas \n\n发件号码: +65WWWWWWWW\n发件时间: 2023/12/26 01:53:53\n#SMS\n\n本机号码: +65XXXXXXXX\n开机时长: 00:03:56\n运营商: XXXXX\n信号: -96dBm\n频段: B41 10 [2023-12-26 02:53:57.227][000000236.807] D/user.util_notify.poll 轮询消息队列中, 当前队列长度: 1 [2023-12-26 02:53:57.230][000000236.808] D/user.util_notify.poll 当前设备处于漫游状态只使用 Serial 通信方式 [2023-12-26 02:53:57.233][000000236.809] I/user.util_notify.send 发送通知 serial [2023-12-26 02:53:57.236][000000236.810] Uart_TxTaskSafe 1213:uart1,br 0, tx len 187 [2023-12-26 02:53:57.239][000000236.810] I/user.util_notify serial 消息已转发到串口 [2023-12-26 02:53:58.161][000000237.812] I/user.util_notify.send 发送通知成功 code: 200 body: nil [2023-12-26 02:54:06.967][000000246.628] D/mobile CSCON 0 [2023-12-26 02:56:20.474][000000380.140] D/mobile CSCON 1 [2023-12-26 02:56:20.565][000000380.210] D/mobile TIME_SYNC 0 [2023-12-26 02:56:20.615][000000380.280] D/mobile CSCON 0 [2023-12-26 03:02:11.213][000000730.871] D/mobile CSCON 1 [2023-12-26 03:02:11.291][000000730.947] D/mobile TIME_SYNC 0 [2023-12-26 03:02:11.353][000000731.009] D/mobile CSCON 0

  1. 由于不知道是底包做了判断还是脚本做了判断,所以换了一个底包再试下。
  2. 这次换了 LuatOS-SoC_V1105_EC618_FULL.soc 这个底包。这次提示好像变了,没有了“漫游”的提示。不过看上去,好像队列一直没有发出去。

[2023-12-26 03:21:16.690][000000000.351] I/pm poweron: Power/Reset [2023-12-26 03:21:16.692][000000000.352] I/main LuatOS@EC618 base 22.12 bsp V1105 32bit [2023-12-26 03:21:16.694][000000000.352] I/main ROM Build: Mar 14 2023 17:22:07 [2023-12-26 03:21:16.697][000000000.359] D/main loadlibs luavm 204792 14112 14112 [2023-12-26 03:21:16.700][000000000.359] D/main loadlibs sys 342544 54136 80400 [2023-12-26 03:21:16.703][000000000.373] I/user.main air780e_forwarder 1.0.0 [2023-12-26 03:21:16.705][000000000.374] I/user.main 开机原因 0 0 3 [2023-12-26 03:21:16.723][000000000.528] self_info 115:model Air780E imei 86SSSSSSSSSSSS [2023-12-26 03:21:17.194][000000001.018] D/mobile CSCON 1 [2023-12-26 03:21:19.176][000000002.985] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 03:21:19.180][000000002.986] D/mobile NETIF_LINK_ON -> IP_READY [2023-12-26 03:21:19.182][000000002.993] D/user.util_notify.add 添加到消息队列, 当前队列长度: 1 [2023-12-26 03:21:19.189][000000003.013] D/mobile TIME_SYNC 0 [2023-12-26 03:21:29.257][000000013.072] D/mobile CSCON 0 [2023-12-26 03:21:32.196][000000016.009] D/mobile CSCON 1 [2023-12-26 03:21:32.241][000000016.054] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 03:21:32.271][000000016.077] D/mobile TIME_SYNC 0 [2023-12-26 03:21:32.335][000000016.155] D/mobile CSCON 0 [2023-12-26 03:21:34.737][000000018.553] D/mobile CSCON 1 [2023-12-26 03:21:34.798][000000018.607] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 03:21:34.805][000000018.627] D/mobile TIME_SYNC 0 [2023-12-26 03:21:34.877][000000018.700] D/mobile CSCON 0 [2023-12-26 03:22:39.896][000000083.714] D/mobile CSCON 1 [2023-12-26 03:22:39.973][000000083.782] luat_sms_nw_report_urc 1039:[DIO 1039]: The recv msg: phone: +65YYYYYYYY [2023-12-26 03:22:39.976][000000083.782] luat_sms_nw_report_urc 1044:[DIO 1044]: The recv msg: dcs: 0 | 0 | 165 | 0 [2023-12-26 03:22:39.978][000000083.782] luat_sms_nw_report_urc 1049:[DIO 1049]: The recv msg: sca: [+33HHHHHHHHH] [2023-12-26 03:22:39.981][000000083.782] luat_sms_nw_report_urc 1062:[DIO 1062]: The recv msg: time: ["23/12/26,02:22:38 +28"] [2023-12-26 03:22:39.983][000000083.783] luat_sms_nw_report_urc 1076:[DIO 1076]: The recv msg: pdu: [18 | 37 | 20 | & happy new years...] [2023-12-26 03:22:39.987][000000083.783] luat_sms_nw_report_urc 1082:[DIO 1082]: The recv msg: ieData 0 0 0 [2023-12-26 03:22:39.991][000000083.783] luat_sms_nw_report_urc 1084:[DIO 1084]: The recv msg: 37[07913397C240B9160096B056103A0C3F87E57866398F900048410110F3221622283821424232217E741EEF21D9] [2023-12-26 03:22:39.993][000000083.783] luat_sms_nw_report_urc 1085:[DIO 1085]: The recv msg: [07913397C240B9160096B056103A0C3F87E57866398F900048410110F3221622283821424232217E741EEF21D9] [2023-12-26 03:22:39.996][000000083.785] luat_sms_proc 1144:[DIO 1144]: CMI_SMS_NEW_MSG_IND is in [2023-12-26 03:22:39.998][000000083.786] D/sms dcs 0 | 0 | 0 | 0 [2023-12-26 03:22:40.001][000000083.789] I/user.smsCallback 2023/12/26 02:22:38 +65YYYYYYYY & happy new years... [2023-12-26 03:22:40.004][000000083.792] D/user.util_notify.add 添加到消息队列, 当前队列长度: 2 [2023-12-26 03:22:49.852][000000093.677] D/mobile CSCON 0 [2023-12-26 03:22:52.844][000000096.661] D/mobile CSCON 1 [2023-12-26 03:22:52.909][000000096.720] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 03:22:52.934][000000096.743] D/mobile TIME_SYNC 0 [2023-12-26 03:22:53.109][000000096.927] D/mobile CSCON 0 [2023-12-26 03:36:23.505][000000907.331] D/mobile CSCON 1 [2023-12-26 03:36:23.552][000000907.358] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 03:36:23.559][000000907.381] D/mobile TIME_SYNC 0 [2023-12-26 03:36:23.626][000000907.445] D/mobile CSCON 0 [2023-12-26 03:57:27.635][000002171.456] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 04:24:30.818][000003794.655] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 04:36:23.634][000004507.475] D/mobile CSCON 1 [2023-12-26 04:36:23.681][000004507.525] D/mobile TIME_SYNC 0 [2023-12-26 04:36:23.743][000004507.578] D/mobile CSCON 0

0wQ commented 8 months ago

修改一下这部分代码,试试可以吗

https://github.com/0wQ/air780e-forwarder/blob/107c1f2fad66721ed080e79ab3f76ffea26d5262/script/util_notify.lua#L418-L456

修改为:

local function poll()
    local item, result
    local codes = {
        [0] = "网络未注册",
        [1] = "网络已注册",
        [2] = "网络搜索中",
        [3] = "网络注册被拒绝",
        [4] = "网络状态未知",
        [5] = "网络已注册,漫游",
        [6] = "网络已注册,仅SMS",
        [7] = "网络已注册,漫游,仅SMS",
        [8] = "网络已注册,紧急服务",
        [9] = "网络已注册,非主要服务",
        [10] = "网络已注册,非主要服务,漫游",
    }
    while true do
        -- 消息队列非空, 且网络已注册
        log.debug("mobile.status:", codes[mobile.status() or 0] or "未知网络状态")
        if next(msg_queue) ~= nil and (mobile.status() == 1 or mobile.status() == 5) then
            log.debug("util_notify.poll", "轮询消息队列中, 当前队列长度:", #msg_queue)

            item = msg_queue[1]
            table.remove(msg_queue, 1)

            if item.retry > (config.NOTIFY_RETRY_MAX or 100) then
                log.error("util_notify.poll", "超过最大重发次数", "msg:", item.msg)
            else
                result = util_notify.send(item.msg, item.channel)
                item.retry = item.retry + 1

                if not result then
                    -- 发送失败, 移到队尾
                    table.insert(msg_queue, item)
                    sys.wait(5000)
                end
            end
            sys.wait(50)
        else
            sys.waitUntil("NEW_MSG", 1000 * 10)
        end
    end
end
kzh1980 commented 8 months ago

感谢大佬,没想到这么快就反馈了,比心

经过测试,现在工作是正常的:

这次我用的是 LuatOS-SoC_V1105_EC618.soc 这个底包 + 修改过后的 util_notify.lua 文件,成功了。

唯一有一点疑惑就是,我确定我的卡是没有漫游的,但是我看提示显示是漫游。不过这个还好,目前看是不影响使用。改天带他去另一个国家试试看,真的漫游的时候会发生什么...

设备日志如下,仅供您参考:

[2023-12-26 16:02:58.324][000000000.273] I/user.main air780e_forwarder 1.0.0 [2023-12-26 16:02:58.327][000000000.273] I/user.main 开机原因 0 0 3 [2023-12-26 16:02:58.331][000000000.457] self_info 115:model Air780E imei 86XXXXXXXXXXXXX [2023-12-26 16:02:58.333][000000000.459] D/user.mobile.status: 网络未注册 [2023-12-26 16:02:58.606][000000000.817] D/mobile CSCON 1 [2023-12-26 16:03:00.137][000000002.334] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 16:03:00.140][000000002.334] D/mobile NETIF_LINK_ON -> IP_READY [2023-12-26 16:03:00.151][000000002.339] D/user.util_notify.add 添加到消息队列, 当前队列长度: 1 [2023-12-26 16:03:00.278][000000002.483] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:00.283][000000002.485] D/user.util_notify.poll 轮询消息队列中, 当前队列长度: 1 [2023-12-26 16:03:00.286][000000002.486] I/user.util_notify.send 发送通知 pushover [2023-12-26 16:03:00.290][000000002.490] D/user.util_location.getMapLink
[2023-12-26 16:03:00.293][000000002.492] I/user.util_notify POST https://api.pushover.net/1/messages.json [2023-12-26 16:03:00.302][000000002.493] D/user.EVENT.NET_LED_UPDATE 50 50 nil [2023-12-26 16:03:00.305][000000002.494] D/user.util_http.fetch 开始请求 id: http_1 [2023-12-26 16:03:00.317][000000002.502] D/DNS api.pushover.net state 0 id 1 ipv6 0 use dns server0, try 0 [2023-12-26 16:03:00.320][000000002.506] D/mobile TIME_SYNC 0 [2023-12-26 16:03:00.655][000000002.861] D/DNS ipv4 result0,104.20.42.236 [2023-12-26 16:03:00.658][000000002.861] D/DNS ipv4 result1,104.20.43.236 [2023-12-26 16:03:00.661][000000002.862] I/DNS dns all done ,now stop [2023-12-26 16:03:02.830][000000005.037] D/user.util_http.fetch 请求结束 id: http_1 code: 200 [2023-12-26 16:03:02.834][000000005.038] D/user.EVENT.NET_LED_UPDATE nil nil nil [2023-12-26 16:03:02.836][000000005.040] I/user.util_notify.send 发送通知成功 code: 200 body: {"status":1,"request":"【8-4-4-4-12 格式的ID】"} 【这时PUSHOVER的绑定设备这里,就收到了PUSH,应该是设备上线报告】 [2023-12-26 16:03:02.877][000000005.092] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:12.881][000000015.094] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:13.674][000000015.888] D/mobile CSCON 0 [2023-12-26 16:03:16.963][000000019.172] D/mobile CSCON 1 [2023-12-26 16:03:17.053][000000019.255] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 16:03:17.085][000000019.285] D/mobile TIME_SYNC 0 [2023-12-26 16:03:17.147][000000019.358] D/mobile CSCON 0 [2023-12-26 16:03:19.635][000000021.848] D/mobile CSCON 1 [2023-12-26 16:03:19.714][000000021.911] D/user.EVENT.CELL_INFO_UPDATE [2023-12-26 16:03:19.745][000000021.961] D/mobile TIME_SYNC 0 [2023-12-26 16:03:19.824][000000022.033] D/mobile CSCON 0 [2023-12-26 16:03:22.880][000000025.096] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:32.214][000000034.427] D/mobile CSCON 1 [2023-12-26 16:03:32.892][000000035.098] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:42.410][000000044.618] D/mobile CSCON 0 [2023-12-26 16:03:42.893][000000045.100] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:03:52.888][000000055.102] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:02.897][000000065.104] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:12.890][000000075.106] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:22.894][000000085.108] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:32.341][000000094.559] D/mobile CSCON 1 [2023-12-26 16:04:32.451][000000094.650] luat_sms_nw_report_urc 1039:[DIO 1039]: The recv msg: phone: +65XXXXXXXX【发信人】 [2023-12-26 16:04:32.454][000000094.650] luat_sms_nw_report_urc 1044:[DIO 1044]: The recv msg: dcs: 0 | 0 | 165 | 0 [2023-12-26 16:04:32.456][000000094.650] luat_sms_nw_report_urc 1049:[DIO 1049]: The recv msg: sca: [+65YYYYYYYY] 【收信人】 [2023-12-26 16:04:32.458][000000094.651] luat_sms_nw_report_urc 1062:[DIO 1062]: The recv msg: time: ["23/12/26,15:04:28 +28"] [2023-12-26 16:04:32.461][000000094.651] luat_sms_nw_report_urc 1076:[DIO 1076]: The recv msg: pdu: [18 | 29 | 11 | Any update?] [2023-12-26 16:04:32.464][000000094.652] luat_sms_nw_report_urc 1082:[DIO 1082]: The recv msg: ieData 0 0 0 [2023-12-26 16:04:32.467][000000094.652] luat_sms_nw_report_urc 1084:[DIO 1084]: The recv msg: 29[0791625183100F40828916120B417F09071E54816639820B900793524032636296C3F4F20F] [2023-12-26 16:04:32.470][000000094.652] luat_sms_nw_report_urc 1085:[DIO 1085]: The recv msg: [0791625183100F40828916120B417F09071E54816639820B900793524032636296C3F4F20F] [2023-12-26 16:04:32.472][000000094.654] luat_sms_proc 1144:[DIO 1144]: CMI_SMS_NEW_MSG_IND is in [2023-12-26 16:04:32.475][000000094.655] D/sms dcs 0 | 0 | 0 | 0 [2023-12-26 16:04:32.478][000000094.657] I/user.smsCallback 2023/12/26 15:04:28 +65YYYYYYYY Any update? [2023-12-26 16:04:32.483][000000094.660] D/user.util_notify.add 添加到消息队列, 当前队列长度: 1 [2023-12-26 16:04:32.486][000000094.663] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:32.492][000000094.665] D/user.util_notify.poll 轮询消息队列中, 当前队列长度: 1 [2023-12-26 16:04:32.496][000000094.667] I/user.util_notify.send 发送通知 pushover [2023-12-26 16:04:32.500][000000094.671] D/user.util_location.getMapLink
[2023-12-26 16:04:32.503][000000094.673] I/user.util_notify POST https://api.pushover.net/1/messages.json [2023-12-26 16:04:32.505][000000094.674] D/user.EVENT.NET_LED_UPDATE 50 50 nil [2023-12-26 16:04:32.508][000000094.675] D/user.util_http.fetch 开始请求 id: http_2 [2023-12-26 16:04:32.511][000000094.678] D/DNS api.pushover.net state 0 id 2 ipv6 0 use dns server0, try 0 [2023-12-26 16:04:32.544][000000094.757] D/DNS ipv4 result0,104.20.42.236 【这个是PUSHOVER的IP,用CF做了优化】 [2023-12-26 16:04:32.546][000000094.757] D/DNS ipv4 result1,104.20.43.236 [2023-12-26 16:04:32.550][000000094.757] I/DNS dns all done ,now stop [2023-12-26 16:04:34.599][000000096.803] D/user.util_http.fetch 请求结束 id: http_2 code: 200 [2023-12-26 16:04:34.602][000000096.804] D/user.EVENT.NET_LED_UPDATE nil nil nil [2023-12-26 16:04:34.604][000000096.805] I/user.util_notify.send 发送通知成功 code: 200 body: {"status":1,"request":"【另一个8-4-4-4-12格式的ID】"} [2023-12-26 16:04:34.646][000000096.857] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:44.650][000000106.859] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:45.441][000000107.657] D/mobile CSCON 0 [2023-12-26 16:04:54.661][000000116.861] D/user.mobile.status: 网络已注册,漫游 [2023-12-26 16:04:54.721] 工具提示: diag com USB has disconnected. COM6 CommError,[WinError 22] The device does not recognize the command. 【断电】

感谢大佬!