Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp_mesh_send 发送失败,如何清除包内容? (IDFGH-13673) #14549

Open
3 tasks done
Leadrive opened this issue Sep 11, 2024 · 3 comments
Open
3 tasks done

esp_mesh_send 发送失败,如何清除包内容? (IDFGH-13673) #14549

Leadrive opened this issue Sep 11, 2024 · 3 comments
Assignees
Labels
Status: In Progress Work is in progress Type: Bug bugs in IDF

Comments

@Leadrive
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v4.4.6

Espressif SoC revision.

ESP32-S3

Operating System used.

Linux

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-S3

Power Supply used.

USB

What is the expected behavior?

调用 esp_mesh_send 后,能清除发送内容,而不是失败后累积起来

What is the actual behavior?

static esp_err_t mesh_netif_transmit_from_node_sta(void *h, void *buffer, size_t len)
{
    if (len>=CONFIG_LWIP_TCP_MSS) {
        MDF_LOGE("Sending to root, dest addr: " MACSTR ", size: %d" ,MAC2STR((uint8_t*)buffer), len);
        return ESP_ERR_MESH_ARGUMENT;
    }
    mesh_data_t data;
    data.data = buffer;
    data.size = len;
    data.proto = MESH_PROTO_AP; // Node's station transmits data to root's AP
//    data.tos = MESH_TOS_DEF;
    data.tos = MESH_TOS_P2P;
    esp_err_t err = esp_mesh_send(NULL, &data, MESH_DATA_TODS, NULL, 0);
    if (err != ESP_OK) {
        MDF_LOGI("Sending to root, dest addr: " MACSTR ", size: %d" ,MAC2STR((uint8_t*)buffer), len);
        MDF_LOGW("%s, err=<%s>, 内部堆=%u, 外部堆=%u", __func__, mdf_err_to_name(err), esp_get_free_internal_heap_size(), esp_get_free_heap_size());
        if (err==ESP_ERR_MESH_ARGUMENT) {
            MDF_LOGI("%.*s", len, (char*)buffer);
        }
    }
    return err;
}

此时,如果连不上ROOT,发送失败,发送的内容,并没有清除,而是累积起来,最终导致长度超过1440而报错。
如果参数改成
data.tos = MESH_TOS_DEF;
则会时不时报
ESP_ERR_MESH_ARGUMENT

Steps to reproduce.

用自带的 ip_internal_network
再修改一下,不断发一个什么 包内容。
连上ROOT后,一切运行正常。
此时手工断开ROOT,观察NODE节点,就会发现esp_mesh_send发送的包,大小不断变大。

Debug Logs.

观察日志中的 size: 177,不断增加。直到超过1440报错。
`
I (1726062215) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 177
W (1726062215) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_XMIT>, 内部堆=57815, 外部堆=2009367
W (1230133) wifi:(->sleep)busy, waked:1, dream:0, sleep:0
W (1230748) wifi:(->sleep)busy, waked:1, dream:0, sleep:0
I (1726062216) [prj_init, 707]: 内部堆=52851, 外部堆=2004055, MeshConnected:1, DirectNetConnected:1, GotIp:1, ConnectMqttStep:3, ConnectMqttCounter:1, DeviceLogin:7, serviceOk:1, TimeSynced:1
I (1726062216) [prj_init, 738]: MainTimerHandle, ConnectMqttCounter:2
W (1231362) wifi:(->sleep)busy, waked:1, dream:0, sleep:0
E (1231689) TIMER: CheckOnlineTimer:11>=11
E (1726062217) [func, 44]: Offline...now:1726062217, from:Timer1Interrupt
W (1231977) wifi:(->sleep)busy, waked:1, dream:0, sleep:0
I (1232561) wifi:bcn_timeout,ap_probe_send_start
I (1232561) wifi:pm stop, total sleep time: 0 us / 1215759687 us

I (1232562) wifi:(mesh)pm stop, sleep:0 secs, total:1159 secs, current active set:10, running:0.00
I (1235038) mesh: [tx-wifi]tx_state:2, src exceed
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 300
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_XMIT>, 内部堆=57499, 外部堆=2008627
I (1235074) wifi:ap_probe_send over, resett wifi status to disassoc
I (1235075) wifi:state: run -> init (c800)
I (1235075) wifi:<ba-del>idx
I (1235076) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1235084) mesh: [wifi]disconnected reason:200(beacon timeout), continuous:1/max:12, non-root, vote(,)<><>
I (1726062221) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1235094) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1235105) wifi:state: init -> auth (b0)
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 423
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57619, 外部堆=2008751
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 546
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57783, 外部堆=2008915
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 564
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57527, 外部堆=2008963
I (1726062221) [mqtt, 76]: mqttUnsubscribe
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 583
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57423, 外部堆=2008859
I (1726062221) [mqtt, 89]: MqttSubscribeDevice successful, msg_id=14521, topic:1147387348/#
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 583
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=52107, 外部堆=2003459
I (1726062221) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 583
W (1726062221) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
I (1726062221) [prj_init, 707]: 内部堆=57023, 外部堆=2008747, MeshConnected:0, DirectNetConnected:0, GotIp:1, ConnectMqttStep:2, ConnectMqttCounter:0, DeviceLogin:7, serviceOk:0, TimeSynced:1
I (1726062222) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 706
W (1726062222) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57223, 外部堆=2008947
I (1726062222) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 706
W (1726062222) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
I (1236609) wifi:state: auth -> init (200)
I (1236610) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1726062222) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1236611) mesh: [wifi]disconnected reason:2(auth expire), continuous:2/max:12, non-root, vote(,)<><>
I (1236626) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1236631) wifi:state: init -> auth (b0)
W (1726062222) [net, 169]: SimpleService fail, maybe mqtt disconnected or mesh disconnected
W (1236932) mesh: [mesh_schedule.c,3131] [WND-RX]max_wnd:9, 1800 ms timeout, seqno:0, xseqno:1281, no_wnd_count:0, timeout_count:0
I (1726062223) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 829
W (1726062223) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57223, 外部堆=2008947
I (1726062223) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 829
W (1726062223) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
I (1238135) wifi:state: auth -> init (200)
I (1238136) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1238138) mesh: [wifi]disconnected reason:2(auth expire), continuous:3/max:12, non-root, vote(,)<><>
I (1726062224) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1238147) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1238157) wifi:state: init -> auth (b0)
I (1726062224) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 952
W (1726062224) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57003, 外部堆=2008727
I (1726062224) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 952
W (1726062224) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
W (1238733) mesh: [mesh_schedule.c,3131] [WND-RX]max_wnd:9, 1800 ms timeout, seqno:0, xseqno:1281, no_wnd_count:0, timeout_count:1
I (1726062224) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 952
W (1726062224) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
I (1726062225) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1075
W (1726062225) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57223, 外部堆=2008947
I (1726062225) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1075
W (1726062225) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57055, 外部堆=2008779
I (1239661) wifi:state: auth -> init (200)
I (1239662) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1239664) mesh: [wifi]disconnected reason:2(auth expire), continuous:4/max:12, non-root, vote(,)<><>
I (1726062225) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1239673) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1239683) wifi:state: init -> auth (b0)
W (1726062225) [net, 169]: SimpleService fail, maybe mqtt disconnected or mesh disconnected
I (1726062226) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1198
W (1726062226) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=57079, 外部堆=2008803
I (1726062226) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1198
W (1726062226) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=56911, 外部堆=2008635
W (1240534) mesh: [mesh_schedule.c,3131] [WND-RX]max_wnd:9, 1800 ms timeout, seqno:0, xseqno:1281, no_wnd_count:0, timeout_count:2
W (1726062226) [mesh_internal, 46]: MeshSendData, err=<ESP_ERR_MESH_TIMEOUT>, size:91, 内部堆=56955, 外部堆=2009163
E (1726062226) [mesh_node, 163]: <ESP_ERR_MESH_TIMEOUT> nodeWriteTask, msgId:698, cmdId:29, 内部堆=57067, 外部堆=2009275
E (1726062226) [handle_message, 286]: HandleDeviceHeartbeatContent, code=0, message:WRITE_FAIL, content:
E (1726062226) [func, 44]: Offline...now:1726062226, from:HandleDeviceHeartbeatContent
I (1726062226) [prj_init, 707]: 内部堆=56911, 外部堆=2009531, MeshConnected:0, DirectNetConnected:0, GotIp:1, ConnectMqttStep:2, ConnectMqttCounter:0, DeviceLogin:7, serviceOk:0, TimeSynced:1
I (1241187) wifi:state: auth -> init (200)
I (1241188) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1726062227) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1241191) mesh: [wifi]disconnected reason:2(auth expire), continuous:5/max:12, non-root, vote(,)<><>
I (1241204) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1241209) wifi:state: init -> auth (b0)
I (1726062227) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1321
W (1726062227) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=56891, 外部堆=2009511
I (1726062227) [mesh_netif, 234]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1321
W (1726062227) [mesh_netif, 235]: mesh_netif_transmit_from_node_sta, err=<ESP_ERR_MESH_DISCONNECTED>, 内部堆=56943, 外部堆=2009563
E (1726062228) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1444
E (1726062228) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1444
W (1726062228) [net, 169]: SimpleService fail, maybe mqtt disconnected or mesh disconnected
I (1242713) wifi:state: auth -> init (200)
I (1242715) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1242723) mesh: [wifi]disconnected reason:2(auth expire), continuous:6/max:12, non-root, vote(,)<><>
I (1726062228) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1242733) wifi:new:<1,1>, old:<1,0>, ap:<1,1>, sta:<1,1>, prof:1
I (1242744) wifi:state: init -> auth (b0)
E (1726062229) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
E (1726062229) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
E (1726062230) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
I (1244248) wifi:state: auth -> init (200)
I (1244249) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (1244251) mesh: [wifi]disconnected reason:2(auth expire), continuous:0/max:12, non-root, vote(,)<><>
I (1726062230) [prj_init, 817]: SetNetworkConnected, DirectNetConnected=0
I (1244261) mesh: [auth expire]looking for a new parent, [L:2]try layer:1
I (1726062230) [mesh_base, 301]: Network state: root_less
E (1726062230) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
I (1244527) mesh: [SCAN][ch:1]AP:8, other(ID:0, RD:0), MAP:0, idle:0, candidate:0, root:0, topMAP:0[c:2,i:1][00:00:00:00:00:00][FIXED-ROOT]<>
I (1244529) mesh: [FAIL][1]root:0, fail:1, normal:0

I (1244776) mesh: [SCAN][ch:1]AP:7, other(ID:0, RD:0), MAP:0, idle:0, candidate:0, root:0, topMAP:0[c:2,i:1][00:00:00:00:00:00][FIXED-ROOT]<>
I (1244777) mesh: [FAIL][2]root:0, fail:2, normal:0

E (1726062230) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
I (1245024) mesh: [SCAN][ch:1]AP:7, other(ID:0, RD:0), MAP:0, idle:0, candidate:0, root:0, topMAP:0[c:2,i:1][00:00:00:00:00:00][FIXED-ROOT]<>
I (1245026) mesh: [FAIL][3]root:0, fail:3, normal:0

E (1726062231) [mesh_netif, 223]: Sending to root, dest addr: e0:5a:1b:15:0a:39, size: 1478
I (1245273) mesh: [SCAN][ch:1]AP:8, other(ID:0, RD:0), MAP:0, idle:0, candidate:0, root:0, topMAP:0[c:2,i:1][00:00:00:00:00:00][FIXED-ROOT]<>
I (1245275) mesh: [FAIL][4]root:0, fail:4, normal:0


### More Information.

_No response_
@Leadrive Leadrive added the Type: Bug bugs in IDF label Sep 11, 2024
@github-actions github-actions bot changed the title esp_mesh_send 发送失败,如何清除包内容? esp_mesh_send 发送失败,如何清除包内容? (IDFGH-13673) Sep 11, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Sep 11, 2024
@zhangyanjiaoesp
Copy link
Collaborator

@Leadrive
For the configuration of the esp_mesh_send() function parameters, please read the document carefully.

* - If the packet is to the root ("to" parameter isn't NULL) or to external IP network, MESH_DATA_TODS should be set.

For the other issue, I will check it .

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Oct 29, 2024
@zhangyanjiaoesp
Copy link
Collaborator

Steps to reproduce.

用自带的 ip_internal_network 再修改一下,不断发一个什么 包内容。
连上ROOT后,一切运行正常。
此时手工断开ROOT,观察NODE节点,就会发现esp_mesh_send发送的包,大小不断变大。

@Leadrive 我用ip_internal_network 测试,添加了你上面提到的 log,但是我没有复现你的问题。我的测试log如下:
请你提供一个可以复现问题的demo, 谢谢。

>>>Sending to root, dest addr: 34:85:18:a5:b1:81, size: 93

>>>mesh_netif_transmit_from_node_sta, 内部堆=208184, 外部堆=215688
I (34063) wifi:state: init -> auth (0xb0)
E (34063) mesh_netif: Send with err code 16395 ESP_ERR_MESH_DISCONNECTED
I (34063) mesh_mqtt: sent publish returned msg_id=38955
>>>Sending to root, dest addr: 34:85:18:a5:b1:81, size: 93
>>>mesh_netif_transmit_from_node_sta, 内部堆=207948, 外部堆=215452
E (34093) mesh_netif: Send with err code 16395 ESP_ERR_MESH_DISCONNECTED
>>>Sending to root, dest addr: 34:85:18:a5:b1:81, size: 350
>>>mesh_netif_transmit_from_node_sta, 内部堆=207724, 外部堆=215228
E (34113) mesh_netif: Send with err code 16395 ESP_ERR_MESH_DISCONNECTED
>>>Sending to root, dest addr: 34:85:18:a5:b1:81, size: 54
>>>mesh_netif_transmit_from_node_sta, 内部堆=208772, 外部堆=216276
E (34133) transport_base: poll_read select error 113, errno = Software caused connection abort, fd = 54
E (34143) mqtt_client: Poll read error: 119, aborting connection
I (34143) mesh_mqtt: MQTT_EVENT_DISCONNECTED
I (35283) wifi:state: auth -> init (0x200)

@zhangyanjiaoesp
Copy link
Collaborator

@Leadrive 这个问题还存在吗?是否可以关闭?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Work is in progress Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants