Problem with wifi mesh by sending message to external IP

ogrego
Posts: 5
Joined: Thu May 31, 2018 8:46 am

Problem with wifi mesh by sending message to external IP

Postby ogrego » Thu May 31, 2018 11:54 am

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

ogrego
Posts: 5
Joined: Thu May 31, 2018 8:46 am

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

Postby ogrego » Fri Jun 01, 2018 8:42 am

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

sky.lei
Posts: 1
Joined: Sun Feb 25, 2018 11:09 am

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

Postby sky.lei » Sun Aug 05, 2018 5:33 am

Hello,
did you resolve this problem ? and how resolved? I have the same problem now

ogrego
Posts: 5
Joined: Thu May 31, 2018 8:46 am

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

Postby ogrego » Mon Aug 06, 2018 10:34 am

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))

surajsingh
Posts: 1
Joined: Tue Apr 14, 2020 2:36 pm

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

Postby surajsingh » Tue Apr 14, 2020 2:45 pm

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.

Who is online

Users browsing this forum: No registered users and 189 guests