Coder Social home page Coder Social logo

Comments (7)

goxofy avatar goxofy commented on August 15, 2024

似乎是一直连不上网络,看log能收到短信,但是http请求发不出去

但是把sim卡插到手机里一切正常,这可能是什么原因呢

from air780e-forwarder.

0wQ avatar 0wQ commented on August 15, 2024

是最新的代码吗?有没有打开低功耗模式

貌似一段时间没有网络请求的话,会出现能收到短信,但是需要重发10分钟左右才能发出去的情况。

之前更新了一下代码,每30分钟发一次请求同步时间,然后每重发5次会开关飞行模式。

from air780e-forwarder.

goxofy avatar goxofy commented on August 15, 2024

@0wQ 是最新版代码,没有启用低功耗,把 ipv6也 false 了,现在是无限重发失败,然后满五次之后自动重开飞行模式,继续无限重发失败

板子应该是没问题,我换了其他卡是能发出http 的

我现在怀疑是sim 卡和板子兼容性的问题,这张 sim卡插上之后一直卡 dns,似乎是直接没有连上互联网,但是收短信是没问题的,打电话也能听到炫铃

from air780e-forwarder.

goxofy avatar goxofy commented on August 15, 2024

刚开始我以为是 dns 解析的问题,我尝试了 1. 修改 dns 服务器,无果 2.自建了一个 api 接口,接收 post 请求,这个接口没有使用域名,直接通过 http+ip 的方式访问,还是无果

这时候意识到可能是没有连上网络。

我搜了一下相关 issue,发现这个人和我情况类似 #38

from air780e-forwarder.

0wQ avatar 0wQ commented on August 15, 2024

他的原因是当地网络问题,访问不了cloudflare。

日志貌似看不出来什么原因,只知道没网。可以将main.lua替换成下面代码,看一下能不能请求成功

PROJECT = "test"
VERSION = "1.0.0"
log.info("main", PROJECT, VERSION)

sys = require("sys")
require "sysplus"

-- 测试 http 请求
local function test_http()
    local url = "https://myip.ipip.net"

    local res_code, res_headers, res_body = http.request("GET", url, nil, nil, { timeout = 20000 }).wait()
    log.info("main", "http.request", "code:", res_code, "headers:", json.encode(res_headers), "body:", res_body)

    return res_code
end

-- 检查网络状态
local network_codes = {
    [0] = "网络未注册",
    [1] = "网络已注册",
    [2] = "网络搜索中",
    [3] = "网络注册被拒绝",
    [4] = "网络状态未知",
    [5] = "网络已注册,漫游",
    [6] = "网络已注册,仅SMS",
    [7] = "网络已注册,漫游,仅SMS",
    [8] = "网络已注册,紧急服务",
    [9] = "网络已注册,非主要服务",
    [10] = "网络已注册,非主要服务,漫游",
}
local function check_network()
    local code = mobile.status()
    log.info("main", "mobile.status", code, network_codes[code or 0] or "未知网络状态")
end

sys.taskInit(function()
    -- 等待网络连接成功
    sys.waitUntil("IP_READY")

    for i = 1, 20, 1 do
        log.info("main", string.rep("=", 30) .. i .. string.rep("=", 30))

        test_http()
        check_network()
        sys.wait(5000)
    end
end)

sys.run()

from air780e-forwarder.

goxofy avatar goxofy commented on August 15, 2024
[2024-04-28 23:38:03.601][000000001.263] D/mobile bearer act 0, result 0
[2024-04-28 23:38:03.604][000000001.263] D/mobile NETIF_LINK_ON -> IP_READY
[2024-04-28 23:38:03.611][000000001.265] I/user.main	==============================1==============================
[2024-04-28 23:38:04.574][000000002.273] I/DNS dns all done ,now stop
[2024-04-28 23:38:23.574][000000021.276] I/user.main	http.request	code:	-8	headers:		body:	nil
[2024-04-28 23:38:23.625][000000021.279] I/user.main	mobile.status	1	网络已注册
[2024-04-28 23:38:28.575][000000026.280] I/user.main	==============================2==============================
[2024-04-28 23:38:29.586][000000027.282] I/DNS dns all done ,now stop
[2024-04-28 23:38:48.590][000000046.284] I/user.main	http.request	code:	-8	headers:		body:	nil
[2024-04-28 23:38:48.625][000000046.288] I/user.main	mobile.status	1	网络已注册
[2024-04-28 23:38:53.591][000000051.289] I/user.main	==============================3==============================
[2024-04-28 23:38:54.592][000000052.291] I/DNS dns all done ,now stop
[2024-04-28 23:39:13.592][000000071.293] I/user.main	http.request	code:	-8	headers:		body:	nil
[2024-04-28 23:39:13.627][000000071.297] I/user.main	mobile.status	1	网络已注册
[2024-04-28 23:39:18.589][000000076.298] I/user.main	==============================4==============================

测试了一下似乎不太行,还是发不出去

from air780e-forwarder.

goxofy avatar goxofy commented on August 15, 2024

搞了一晚上实在搞不定,算了人麻了

暂时拿了一块esp32,把config改成serial + SLAVE 模式,然后通过esp32接收串口信息再发送通知了。。。先这么曲线救国吧,确实不太了解硬件开发

from air780e-forwarder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.