Page 1 of 1

Problem with wifi mesh by sending message to external IP

Posted: Thu May 31, 2018 11:54 am
by ogrego
Hello, I'm currently trying to modify the mesh example: https://github.com/espressif/esp-idf/tr ... ransceiver to send a messsage to my server, without success.

I checked the API's esp_mesh_send part: http://esp-idf.readthedocs.io/en/latest ... esh_opt_ti
It says "if the packet is outgoing to external IP network such as an IP server address, translate IPv4:PORT known as “to”."
I tried to use MESH_PROTO_BIN, MESH_PROTO_JSON, MESH_PROTO_HTTP data types without any success.

The relevant part:

Code: Select all

mesh_addr_t serverAddr;
IP4_ADDR(&serverAddr.mip.ip4, 192,168,0,132); // 192.168.0.132 is my pc
serverAddr.mip.port = 8089; // I'm running running a python script to handle requests
esp_mesh_send(&serverAddr, &data, MESH_DATA_TODS, NULL , 0);
Full code:
https://pastebin.com/Y9nLayKa
Python socket script:
https://pastebin.com/yLjAftWc

Re: Problem with wifi mesh by sending message to external IP

Posted: Fri Jun 01, 2018 8:42 am
by ogrego
Meanwhile I switched from the python script to netcat:

Code: Select all

nc -l -k -p 8089
And got this error message after the third esp_mesh_send function call (at the first two, nothing happened):
W (17492) mesh: [esp_mesh_forward_packet,206] [ucast]err:0x4012, ucast discard, xseqno:4, len:1502, 30:ae:a4:75:5c:bc-->c0:a8:00:84:66:2f, xmitter[TA]30:ae:a4:75:5c:bc

Re: Problem with wifi mesh by sending message to external IP

Posted: Sun Aug 05, 2018 5:33 am
by sky.lei
Hello,
did you resolve this problem ? and how resolved? I have the same problem now

Re: Problem with wifi mesh by sending message to external IP

Posted: Mon Aug 06, 2018 10:34 am
by ogrego
I solved it with a workaround:
1. send from leaf node a message to root
2. receive with root
3. open a socket and send to server

1. esp_mesh_send(NULL, &data, 0, NULL, 0); // send message to root
2. err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0);
3. I used an lwip socket:

Code: Select all

// init
tcpServerAddr.sin_addr.s_addr = inet_addr(MESH_SERVER_IP);
tcpServerAddr.sin_family = AF_INET;
tcpServerAddr.sin_port = htons( MESH_PORT );
s = socket(AF_INET, SOCK_STREAM, 0);
connect(s, (struct sockaddr *)&tcpServerAddr, sizeof(tcpServerAddr))
write(s , message , strlen(message))

Re: Problem with wifi mesh by sending message to external IP

Posted: Tue Apr 14, 2020 2:45 pm
by surajsingh
Hello Sir,
how to send message directly to external IP as suggest in APIs using funciton esp_mesh_send and "translate IPv4:PORT known as “to”

sorry but i didn't succes.
any example would be great...

Thanks for your effort.