rt-thread-packages / at_device Goto Github PK
View Code? Open in Web Editor NEWAT component porting or samples for different devices
License: Apache License 2.0
AT component porting or samples for different devices
License: Apache License 2.0
3月8号的版本,在遇到wifi热点突然关闭然后再打开的情况,程序是可以正常运行的。但现在更新到最新版本后(rt-thread也更到最新),当遇到这种情况,程序就会进入hard fault。
不过目前还不确定是rt-thread的问题,还是at_device的问题。
以下是进入hard fault前的记录:
[I/at.esp8266] ESP8266 WIFI is disconnect.
[E/onenet.edp] Received error.
[E/sal.skt] not find network interface device by protocol family(45).
[E/sal.skt] SAL socket protocol family input failed, return error -3.
[E/onenet.edp] socket create failed
[I/at.esp8266] ESP8266 WIFI is connected.
[E/at.clnt] execute command (AT+CIPDOMAIN="link.rt-thread.org") timeout (5000 ticks)!
psr: 0x61000000
r00: 0x00000000
r01: 0x6b726f77
r02: 0x200017b0
r03: 0xffffffff
r04: 0x2000206c
r05: 0x20003470
r06: 0x200020a8
r07: 0x00000000
r08: 0x0801e018
r09: 0x20003600
r10: 0x20003470
r11: 0x20003600
r12: 0x08018299
lr: 0x08009b8d
pc: 0x6b726f76
hard fault on thread: sys_work
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
onenet 25 suspend 0x00000098 0x00000500 57% 0x00000002 -95
tshell 20 suspend 0x00000138 0x00000800 25% 0x0000000a 000
at_clnt 9 suspend 0x000000ac 0x00000600 20% 0x00000004 000
sys_work 23 running 0x000001ac 0x00000800 27% 0x00000006 -02
tidle0 31 ready 0x00000040 0x00000100 31% 0x00000017 000
main 10 suspend 0x00000078 0x00000800 16% 0x00000007 000
bus fault:
SCB_CFSR_BFSR:0x01 IBUSERR
您好,感谢 at_device。
我在使用 ec200t 时遇到一个问题,模块 at 命令初始化之后一直打印 the power is off.,间隔为 EC200X_LINK_DELAY_TIME
。
static int ec200x_check_link_status(struct at_device *device)
{
at_response_t resp = RT_NULL;
struct at_device_ec200x *ec200x = RT_NULL;
int result = -RT_ERROR;
ec200x = (struct at_device_ec200x *)device->user_data;
if ( ! ec200x->power_status)//power off
{
LOG_D("the power is off.");
return(-RT_ERROR);
}
/* ... */
}
目前我是做了以下修改规避这个问题
--- a/class/ec200x/at_device_ec200x.c
+++ b/class/ec200x/at_device_ec200x.c
@@ -44,6 +44,7 @@ static int ec200x_power_on(struct at_device *device)
if (ec200x->power_pin == -1)//no power on pin
{
+ ec200x->power_status = RT_TRUE;
return(RT_EOK);
}
if (ec200x->power_status_pin != -1)//use power status pin
@@ -82,6 +83,7 @@ static int ec200x_power_off(struct at_device *device)
if (ec200x->power_pin == -1)//no power on pin
{
+ ec200x->power_status = RT_FALSE;
return(RT_EOK);
}
if (ec200x->power_status_pin != -1)//use power status pin
不知道这是 bug 还是我使用方式不对。
RT,只看到了socket,为什么没有BT/BLE呢?
首先肯定一下最新版AT DEVICE整体上精简了很多无用的代码,整体更加工整,最近调试发现的问题,因为加入了网卡设备管理的特性,(SIM7600)第一次开机初始化完成后总会去执行CDNSGIP,然后创建UDP连接(此处占用0号链路),而且这个UDP连接的IP还是空的,i并且还CIPSEND了一些东西出去,完成后就关闭0号链路,这些操作看起来好像也没什么问题。问题1:
但是当用户再次创建TCP时,分配的链路不再是0号,尽管此时检查到链路全是空的,链路序列号依然会递增到1号链路。
问题2:
在问题1的基础上,因为第一次开机先CDNSGIP,再创建UDP连接。而此时用户在网卡驱动初始化完成后需要打开webclient, POS一个URL,并等待HTTP Read FIFO的过程中。及其容易与正在创建的UDP+发送某些东西 ,这个步骤冲突而导致用户的网络应用错乱。而最后定位在了第一次开机后总会调用这个 “sim76xx_domain_resolve”,才会触发UDP。
尝试过规避这个现象
webclient_shard_position_function 函数里:
data_len = webclient_response(session, (void **)&buffer, &resp_len);
if(data_len > 0)
{
start_position += mem_size; //这里应该加data_len, 而不应该加mem_size;
http原始报文:
02:45:44 [281382] D/web: response header:
02:45:44 HTTP/1.1 206 Partial Content
02:45:44 [281483] D/web: Date: Fri, 21 Jan 2022 18:45:44 GMT
02:45:44 [281489] D/web: Server: Apache/2.4.7 (Ubuntu)
02:45:44 [281494] D/web: Last-Modified: Fri, 21 Jan 2022 10:45:18 GMT
02:45:44 [281501] D/web: ETag: "36dc0-5d61550953499"
02:45:44 [281505] D/web: Accept-Ranges: bytes
02:45:44 [281509] D/web: Content-Length: 51 // 请求的是512个字节,这儿返回的是51个字节。
02:45:44 [281513] D/web: Content-Range: bytes 71680-72191/224704
02:45:44 [281519] D/web: get position handle response(1).
我天, 我调了半夜, 终于找到http_ota下载大数据crc校验失败的原因了。。。。
packages\at_device-latest\at_socket_sim800c.c(36): error: #35: #error directive: "This RT-Thread version is older, please check and updata laster RT-Thread!"
#error "This RT-Thread version is older, please check and updata laster RT-Thread!"
rt_htread 4.0.0
问题描述:
在一个只有4g信号环境中,或者使用只开通4G的物联网卡的情况下,使用AT组件会初始化设备失败导致无法连接网络。
原因是AT组件中对AT+CREG和AT+CGRAG进行了判断。如果返回的不对就会直接退出初始化,CGREG是LTE这块业务的,CREG是2G这块业务的,如果遇到现场环境没有2G只有4G的实惠,CREG的返回就不会是0,1或者是0,5,程序会判断联网失败直接退出,所以后续即使有4G信号能通讯也是不行了。
如果直接屏蔽了CREG的判断和退出,那么就是可以正常是用4G的。
建议对AT+CREG和AT+CGRAG判断时,不要直接go exit
在at_socket_esp8266.c文件中,进行跟踪,每次正常连接后,就出现崩溃,通过跟踪,发现出现的崩溃的地方在下面这个函数:
/* parse response data, get the DHCP status */
if (at_resp_parse_line_args_by_kw(resp, "+CWDHCP_CUR:", "+CWDHCP_CUR:%d", &dhcp_stat) < 0)
{
LOG_E("%s device prase DHCP status error.", device->name);
goto __exit;
}
这里这么写感觉有点问题:
"+CWDHCP_CUR:%d", &dhcp_stat)
dhcp_stat的定义:
rt_uint8_t dhcp_stat = 0;
改成
if (at_resp_parse_line_args_by_kw(resp, "+CWDHCP_CUR:", "+CWDHCP_CUR:%d", dhcp_stat) < 0)
后一切正常。
'rt_thread_mdelay(2000);
/* check IMSI */
if (at_obj_exec_cmd(device->client, resp, "AT+CIMI") != RT_EOK)
{
result = -RT_ERROR;
LOG_E(">> AT+CIMI");
goto __exit;
}
目前在用STM32+ESP8266
在net_socket中实现了常用socket函数,然后依次调用sal_socket、at_socket、at_socket_esp8266中的对应函数实现
但是at_socket.c中的at_bind()函数没有真正被实现导致net_socket中的bind()不可用
同样sal_socket.c中的sal_accept()函数因sock->ops->accept指针没有指向有效的驱动函数位置导致net_socket中的accept()不可用
请问是否有现有的补丁?使用LWIP能否解决?手动补全这两个函数是否有可参考的代码?
谢谢
01-01 00:00:00 E/at.skt at_clnt: no memory for sim800c device(sim0) URC receive buffer (1348).
01-01 00:00:00 E/at.skt at_clnt: no memory for sim800c device(sim0) URC receive buffer (1460).
01-01 00:00:00 E/at.skt at_clnt: no memory for sim800c device(sim0) URC receive buffer (1460).
01-01 00:00:00 E/at.skt at_clnt: no memory for sim800c device(sim0) URC receive buffer (1124).
后面就一直不行了
目前,at_device组件,只使用了模块内部的tcp/ip协议栈,比方像bc26这样的,支持的协议栈比较全的,是不是思考一下比较好的支持方法?
请问有没有在适配美格系列的4G模块呢?
我已经成功移植了AT包和AT socket包,请问rtthread当前支持使用有人WH-LTE-7S4模块吗?
这个模块是工作在串口透传状态的,直接通过串口发数据到模块,然后模块将数据封装成TCP包发送給服务器。
我想基于这个模块在rtthread上使用MQTT协议,请问这个方案可行吗?
系统重启后无法链接,
在这一句后面直接返回了
at_device/class/esp32/at_device_esp32.c
Line 632 in 398efbc
用的是ESP32最新的AT 固件 2.1.0
请问什么时候开始支持air系列模块
想提交一个模块的支持至 at_device 中,请问 PR 是否有相关格式要求?
bc26在初始化时,会卡在获取dns这一步,我尝试手动发送"AT+QIDNSCFG=1"指令,经常会无法收到返回结果,或是要等很久才会返回.
我在这里看到了一样的情况,网友说是bc26不需要向运营商获取dns,内部自带dns,可以帮忙解决一下吗@qiyongzhong0
完成了M5311接入系统AT组件,目前在我的毕设上运行良好,
能够正常注册到网卡以及获取模块信息,但还没规范接入到env配置工具,
希望更多人加入完善此驱动。
https://github.com/LXGMAX/NB-IoT_M5311
请问出现下面报错信息,该如何解决呢?
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O0 -ffunction-sections -fdata-sections -Wall -g -gdwarf-2 -T "D:\RT-ThreadStudio\workspace\clock_v2\link.lds" -Xlinker --gc-sections -Wl,-Map,"rtthread.map" -Xlinker --cref --specs=nano.specs -o "rtthread.elf" ./rt-thread/src/clock.o ./rt-thread/src/components.o ./rt-thread/src/device.o ./rt-thread/src/idle.o ./rt-thread/src/ipc.o ./rt-thread/src/irq.o ./rt-thread/src/kservice.o ./rt-thread/src/mem.o ./rt-thread/src/mempool.o ./rt-thread/src/object.o ./rt-thread/src/scheduler.o ./rt-thread/src/signal.o ./rt-thread/src/thread.o ./rt-thread/src/timer.o ./rt-thread/libcpu/arm/cortex-m3/context_gcc.o ./rt-thread/libcpu/arm/cortex-m3/cpuport.o ./rt-thread/libcpu/arm/common/backtrace.o ./rt-thread/libcpu/arm/common/div0.o ./rt-thread/libcpu/arm/common/showmem.o ./rt-thread/components/net/sal_socket/src/sal_socket.o ./rt-thread/components/net/sal_socket/socket/net_netdb.o ./rt-thread/components/net/sal_socket/impl/af_inet_at.o ./rt-thread/components/net/netdev/src/netdev.o ./rt-thread/components/net/netdev/src/netdev_ipaddr.o ./rt-thread/components/net/at/src/at_cli.o ./rt-thread/components/net/at/src/at_client.o ./rt-thread/components/net/at/src/at_utils.o ./rt-thread/components/net/at/at_socket/at_socket.o ./rt-thread/components/libc/compilers/newlib/libc.o ./rt-thread/components/libc/compilers/newlib/libc_syms.o ./rt-thread/components/libc/compilers/newlib/stdio.o ./rt-thread/components/libc/compilers/newlib/syscalls.o ./rt-thread/components/libc/compilers/newlib/time.o ./rt-thread/components/finsh/cmd.o ./rt-thread/components/finsh/msh.o ./rt-thread/components/finsh/shell.o ./rt-thread/components/drivers/src/completion.o ./rt-thread/components/drivers/src/dataqueue.o ./rt-thread/components/drivers/src/pipe.o ./rt-thread/components/drivers/src/ringblk_buf.o ./rt-thread/components/drivers/src/ringbuffer.o ./rt-thread/components/drivers/src/waitqueue.o ./rt-thread/components/drivers/src/workqueue.o ./rt-thread/components/drivers/serial/serial.o ./rt-thread/components/drivers/sensors/sensor.o ./rt-thread/components/drivers/sensors/sensor_cmd.o ./rt-thread/components/drivers/misc/pin.o ./rt-thread/components/drivers/i2c/i2c-bit-ops.o ./rt-thread/components/drivers/i2c/i2c_core.o ./rt-thread/components/drivers/i2c/i2c_dev.o ./packages/dht11-latest/dht11_sample.o ./packages/dht11-latest/sensor_dallas_dht11.o ./packages/at_device-v2.0.1/src/at_device.o ./packages/at_device-v2.0.1/samples/at_sample_esp8266.o ./packages/at_device-v2.0.1/class/esp8266/at_device_esp8266.o ./packages/at_device-v2.0.1/class/esp8266/at_socket_esp8266.o ./libraries/STM32F1xx_HAL_Driver/Src/Legacy/stm32f1xx_hal_can.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cec.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dac.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dac_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_eth.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_hcd.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2s.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_irda.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_mmc.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_nand.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_nor.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pccard.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sd.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_smartcard.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_sram.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_usart.o ./libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_wwdg.o ./libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103xb.o ./libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.o ./drivers/board.o ./drivers/drv_common.o ./drivers/drv_gpio.o ./drivers/drv_soft_i2c.o ./drivers/drv_usart.o ./applications/main.o
d:/rt-threadstudio/platform/env_released/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: rtthread.elf section `.text' will not fit in region `ROM'
d:/rt-threadstudio/platform/env_released/env/tools/gnu_gcc/arm_gcc/mingw/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: region `ROM' overflowed by 42708 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:72: rtthread.elf] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.
15:59:06 Build Failed. 3 errors, 2 warnings. (took 23s.999ms)
同主题,希望加入RTT的WLAN框架,这样玩的话的更方便
Line 19 in 4d01865
Related to the change:
RT-Thread/packages#1168 (comment)
When the socket is disabling, the compiler cannot find this header. This header should be conditionally excluded.
for example
#ifdef AT_USING_SOCKET
#include <at_socket.h>
#endif
在调试移远EC600N模块时发现,at socket接收大量数据时,出现内存分配失败的现象,后面跟踪发现底层使用的直吐模式,有数据过来时mcu直接calloc缓存,当数据量大点时,比如下载几十KB或者更大的文件时,大量数据直接挤爆mcu的内存,导致出现因内存直接丢弃数据,建议使用模块的缓存模式和QIRD命令实现底层的at_socket,提高可靠性
例如ESP8266的AT+CWLAP指令都没有
在使用air720驱动air724 4G网卡时出现:
[2202632] E/at.skt: air720 device(air720) socket(0) connect failed, wait connect result timeout.
[2202642] E/mqtt: connect err!
[2203647] E/at.skt: air720 device(air720) socket(0) close failed, wait close OK timeout.
[2203656] E/mqtt: Net connect error(-2).
之后就无法再次链接。重启设备后恢复,一段时间后再次出现该问题。
PS:在100ms每次mqtt数据发送后会较快出现该问题,在1000ms每次mqtt数据发送后会在2小时左右出现该问题。
rt_delayed_work_init 似乎在master分支被移除了(RT-Thread/rt-thread@94ed55f)
但在这个软件包中仍有使用,例如:
at_device/class/esp8266/at_device_esp8266.c
Lines 614 to 615 in 2890692
/cc @mysterywolf
我使用AT_device通过http从网站上下载大文件时,发现每次数据都不正常,数据中总是夹杂着大量无用的数据,通过查找,发现at_socket.c这个文件中的
static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len)
中链表使用应该是存在问题的,修改后的代码如下:
static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len)
{
rt_slist_t *node = RT_NULL;
at_recv_pkt_t pkt = RT_NULL;
size_t content_pos = 0, page_pos = 0;
if (rt_slist_isempty(rlist))
{
return 0;
}
for (node = rt_slist_first(rlist); node; )
{
pkt = rt_slist_entry(node, struct at_recv_pkt, list);
page_pos = pkt->bfsz_totle - pkt->bfsz_index;
//rt_kprintf("at_recvpkt_get3:%d %d\n",pkt->bfsz_totle,pkt->bfsz_index);
if (page_pos >= len - content_pos)
{
memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, len - content_pos);
pkt->bfsz_index += len - content_pos;
if (pkt->bfsz_index == pkt->bfsz_totle)
{
at_recvpkt_node_delete(rlist, node);
}
content_pos = len - content_pos;
break;
}
else
{
memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, page_pos);
content_pos += page_pos;
pkt->bfsz_index += page_pos;
rt_slist_t *tmpnode = rt_slist_next(node);
at_recvpkt_node_delete(rlist, node);
node = tmpnode;
//node = rt_slist_next(node);
}
}
通过测试,现在下载数据一切正常。
这个At_device 组件。可以移植和RT_thread nano 版本一起使用吗?看了半天没看出来
在env中配置了esp8266后,在rt_config中生成的宏是AT_DEVICE_ESP8266,而SConscript脚本中天条件都是AT_DEVICE_USING_ESP8266,导致生成的工程中无at_device_esp8266.c等esp8266相关文件
使用rt-thread studio 生成n58示例程序,编译后烧录运行,卡在网络注册这一步,提示 mutex ==NULL,
请问是什么原因?
\ | /
[6331] I/at.dev:
[6334] I/at.dev: NEOWAY
[6337] I/at.dev: N58
[6340] I/at.dev: V004
[6349] I/at.dev: n58 device(n58) SIM card detection success.
[6356] I/at.dev: CCID: 89860434182180104341
[6861] I/at.dev: register network!
(mutex != RT_NULL) assertion failed at function:rt_mutex_take, line number:902
01-01 00:00:00 E/at.clnt at_clnt: AT Client receive failed, uart device get data error(-2)
01-01 00:00:00 E/at.skt.sim800 at_clnt: sim0 device receive size(2) data failed.
01-01 00:00:00 E/mqtt mqtt0: [1147090] wait Ping Response res: 0
for (i = 0; i < CPIN_RETRY; i++) { at_obj_exec_cmd(client, resp, "AT+CPIN?"); if (at_resp_get_line_by_kw(resp, "READY")) { LOG_D("%s device SIM card detection failed.", device->name); break; } LOG_I("\"AT+CPIN\" commands send retry..."); rt_thread_mdelay(1000); }
上面的代码中LOG_D部分的打印信息反了,这个逻辑应该是success,不是failed
AT socket esp8266
console用的uart2
at用的uart1
板子nucleo f401re
(f103我也试了同样的问题)
msh开机正常输出,提示AT client成功,然后理论上应该是uart1发送AT+RST,实际卡在这里,shell无法再输入任务东西
uart1连到串口,发现收不到任何东西
调试,发现一直在等uart1发送完成标志:如下图
AT socket esp8266串口发不出指令
https://www.rt-thread.org/qa/thread-10994-1-1.html
(出处: RT-Thread开发者社区)
RT
完成了M5311接入系统AT组件,目前在我的毕设上运行良好,
能够正常注册到网卡以及获取模块信息,但还没规范接入到env配置工具,
希望更多人加入完善此驱动。
https://github.com/LXGMAX/NB-IoT_M5311
esp8266 / esp32 的AT固件官方都使用新的IDF 接口了,能否增加对IDF接口的支持 ?
After excluded #include <at_socket.h> as mentioned in #171
Failed to compile with codes that related to pin driver.
For example:
at_device/class/sim800c/at_device_sim800c.c
Line 880 in 4d01865
will post errors and warnings that cannot find these functions and macros.
By adding #include <drivers/pin.h>
solve this problem.
Should you consider adding the pin header for all classes.
But this is now a dependency of the pin driver. Should this be added to the Kconfig?
If we don't want the dependency, should it provide an interface or a function pointer for users to customize their own power on/power off method? Because sometimes, people are not using a native pin to control the power instead using an I2C IO expansion chip.
这个问题出现了几天了,原本以为是ESP8266的问题,后来换了SIM800c也是一样的现象。
这里给出ESP8266的log,请熟悉的大佬帮我看看是啥问题。
平台是STM32L476,LPUART1,115200, RTT 4.0.3, AT Device是latest
LOG 里面第1332行开始,之后就不正常了。1332行本身也是有问题
esp8266.log
我分析的过程如下
1332 之后的,发送close socket,超时返回
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 43 4C 4F 53 45 3D 30 AT+CIPCLOSE=0
[D/AT] recvline: 0000-0020: 00 30 2C 43 4C 4F 53 45 44 0D 0A .0,CLOSED..
[D/AT] recvline: 0000-0020: 0D 0A ..
[614885] D/at.clnt: execute command (AT+CIPCLOSE=0) timeout (300 ticks)!
之后mqtt应该是在新建一个socket
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[619885] D/mqtt: inter mqtt_connect_callback!
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
这里IP请求了5次,全部返回了解析,但是下面没用上,解析不成功
从这里开始IP为0. 很奇怪没有用上上面解析得到的IP地址。
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 53 54 41 52 54 3D 30 2C 22 54 43 50 22 2C 22 30 2E 30 2E 30 2E 30 22 2C 31 31 AT+CIPSTART=0,"TCP","0.0.0.0",11
[D/AT] sendline: 0020-0040: 35 32 33 2C 36 30 523,60
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] recvline: 0000-0020: 45 52 52 4F 52 0D 0A ERROR..
再后面就一直报错了
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 53 45 4E 44 3D 30 2C 36 30 AT+CIPSEND=0,60
[D/AT] recvline: 0000-0020: 30 2C 43 4C 4F 53 45 44 0D 0A 0,CLOSED..
[D/AT] recvline: 0000-0020: 6C 69 6E 6B 20 69 73 20 6E 6F 74 20 76 61 6C 69 64 0D 0A link is not valid..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] sendline: 0000-0020: 10 3A 00 04 4D 51 54 54 04 CE 00 1E 00 08 51 69 6E 67 37 39 31 31 00 04 74 65 73 74 00 08 47 6F .:..MQTT......Qing7911..test..Go
[D/AT] sendline: 0020-0040: 6F 64 62 79 65 21 00 0B 71 69 6E 67 73 74 61 74 69 6F 6E 00 07 71 69 6E 67 31 32 33 odbye!..qingstation..qing123
[634248] E/at.skt.esp: esp0 device socket(0) wait connect result timeout.
[634248] E/mqtt: MQTT connect error(-1): UNKNOWN_ERROR.
[634248] D/mqtt: inter mqtt_offline_callback!
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[6393[D/AT] recvline: 0000-0020: 45 52 52 4F 52 0D 0A ERROR..
[D/AT] recvline: 0000-0020: 0D 0A ..
相关代码是这:
at_device/class/esp8266/at_socket_esp8266.c
Line 309 in 2878647
这个函数里面
static int esp8266_domain_resolve(const char *name, char ip[16])
单步调试,第一次断连的时候,这个地方是可以过的,链接成功恢复。传进来的是IP
第二次断链传进来的就单纯是OK而已
问题应该找到了,真正的IP是用URC发回来的,AT 设备已经考虑到了,但是没有实现这部分功能。不清楚其他模块是否也是这样?
/* parse the third line of response data, get the IP address */
if (at_resp_parse_line_args_by_kw(resp, "+CIPDOMAIN:", "+CIPDOMAIN:%s", recv_ip) < 0)
{
rt_thread_mdelay(100);
/* resolve failed, maybe receive an URC CRLF */
continue;
}
if (rt_strlen(recv_ip) < 8)
{
rt_thread_mdelay(100);
/* resolve failed, maybe receive an URC CRLF */
continue;
}
这是第一次的返回,先返回IP 再返回OK
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
这是往后数次的IP resolve,先返回OK,再返回IP
[D/AT] sendline: 0000-0020: 41 54 2B 43 49 50 44 4F 4D 41 49 4E 3D 22 71 62 65 32 36 62 34 36 2E 65 6E 2E 65 6D 71 78 2E 63 AT+CIPDOMAIN="qbe26b46.en.emqx.c
[D/AT] sendline: 0020-0040: 6C 6F 75 64 22 loud"
[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
[D/AT] recvline: 0000-0020: 2B 43 49 50 44 4F 4D 41 49 4E 3A 35 34 2E 31 36 36 2E 37 36 2E 31 37 38 0D 0A +CIPDOMAIN:54.166.76.178..
[D/AT] recvline: 0000-0020: 0D 0A ..
文件:at_device/class/esp32/at_device_esp32.c
行数:104~128:
if (at_obj_exec_cmd(device->client, resp, "AT+CIPDNS?") < 0)
{
LOG_W("please check and update %s device firmware to support the \"AT+CIPDNS?\" cmd.", device->name);
goto __exit;
}
if (at_resp_parse_line_args(resp, 1, resp_dns, dns_server1) <= 0 &&
at_resp_parse_line_args(resp, 2, resp_dns, dns_server2) <= 0)
{
LOG_E("%s device prase \"AT+CIPDNS?\" cmd error.", device->name);
goto __exit;
}
/* set primary DNS server address */
if (rt_strlen(dns_server1) > 0 &&
rt_strncmp(dns_server1, AT_ERR_DNS_SERVER, rt_strlen(AT_ERR_DNS_SERVER)) != 0)
{
inet_aton(dns_server1, &ip_addr);
netdev_low_level_set_dns_server(netdev, 0, &ip_addr);
}
else
{
inet_aton(AT_DEF_DNS_SERVER, &ip_addr);
esp32_netdev_set_dns_server(netdev, 0, &ip_addr);
}
现象:执行AT+CIPDNS指令后,响应:
+CIPDNS:<enable>[,<"DNS IP1">][,<"DNS IP2">][,<"DNS IP3">]
OK
该响应是逗号分隔的格式,无法通过函数at_resp_parse_line_args
里的vsscanf
得到DNS地址,而是得到dns_server1[AT_ADDR_LEN] = 0,"192.168.1.1","8.8.8.8"
这样的字符串。
接下来执行inet_aton(dns_server1, &ip_addr);
时,无法正确转换DNS格式,导致此处的ip_addr
为前一次的值。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.