Chat freely about anything...

User avatar
By Shubham Jain
#31893 Hello,

I am trying to use mesh lib on eclipse.

Please go through my code and its output below. The code gets compiled and burned successfully. The ESP forms an AP. I connected a PC to it and a mobile to it and successfully pinged from PC to mobile. I am not getting the data at PC as TCP connection is not getting formed when I have statically assigned the IP 2.255.255.7 to the PC.

Now, when I burned another ESP with the code, I did not get any AP from it. How do I check whether my mesh is working correctly? Is my way of using mesh with TCP espconn correct?


----------------------------------------------
#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <gpio.h>
#include "driver/uart.h"
#include "mesh.h"

#define DELAY 1000 /* milliseconds */

#define REMOTE_PORT 8888
#define REMOTE_IP "2.255.255.7"

LOCAL os_timer_t hello_timer;
extern int ets_uart_printf(const char *fmt, ...);

struct espconn conn1;
esp_tcp tcp1;

void makeConnection() {
conn1.type = ESPCONN_TCP;
conn1.state = ESPCONN_NONE;
conn1.proto.tcp = &tcp1;
conn1.proto.tcp->remote_port = REMOTE_PORT;
*((uint32 *)conn1.proto.tcp->remote_ip) = ipaddr_addr(REMOTE_IP);

uint8_t pdata[3] = {4,5,6};
ets_uart_printf("We have asked for a mesh connection! Status: %d\n", espconn_mesh_connect(&conn1));
ets_uart_printf("espconn mesh get status after asking for connection: %d\n", espconn_mesh_get_status());
ets_uart_printf("espconn mesh sent status: %d\n", espconn_mesh_sent(&conn1, pdata, 3));
ets_uart_printf("espconn mesh get status after mesh sent: %d\n", espconn_mesh_get_status());
ets_uart_printf("We have closed a mesh connection! Status: %d\n", espconn_mesh_disconnect(&conn1));

}

void enable_cb()
{
ets_uart_printf("espconn mesh get status after mesh enable: %d\n", espconn_mesh_get_status());
makeConnection();
}

LOCAL void ICACHE_FLASH_ATTR hello_cb(void *arg)
{
ets_uart_printf("Hello World!\r\n");
makeConnection();
}

void init(void)
{
enum mesh_type type = MESH_ONLINE;
espconn_mesh_enable(enable_cb, type);
}

void user_rf_pre_init(void)
{
}

void user_init(void)
{
// Configure the UART
uart_init(BIT_RATE_115200, BIT_RATE_115200);

system_init_done_cb(init);

// Set up a timer to send the message
// os_timer_disarm(ETSTimer *ptimer)
os_timer_disarm(&hello_timer);
// os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg)
os_timer_setfn(&hello_timer, (os_timer_func_t *)hello_cb, (void *)0);
// void os_timer_arm(ETSTimer *ptimer,uint32_t milliseconds, bool repeat_flag)
os_timer_arm(&hello_timer, DELAY, 1);
}
----------------------------------------------
Output:
.
.
.
Hello World!
We have asked for a mesh connection! Status: 0
espconn mesh get status after asking for connection: 3
espconn mesh sent status: 0
espconn mesh get status after mesh sent: 3
We have closed a mesh connection! Status: 0
Hello World!
We have asked for a mesh connection! Status: 0
espconn mesh get status after asking for connection: 3
espconn mesh sent status: 0
espconn mesh get status after mesh sent: 3
We have closed a mesh connection! Status: 0
.
.
.
----------------------------------------------

Kindly, reply.

Thanking you,
Yours sincerely,
Shubham Jain
User avatar
By trendchaster
#31909 Hello Shubham Jain ,
We are on same page me too working on mesh.I want to communicate between 3 to 4 esp modules.I am trying the code using espnow api but in eclipse it gives me error.I am compiling the code from http://bbs.espressif.com/viewtopic.php? ... 9&start=10.
If you have any idea let me know.Meanwhile i will test your code hope something will get from it and I will let you know .
User avatar
By trendchaster
#32018 After compilation of your code it shows following error.Can you provide your whole project file so I can get an idea

mingw32-make.exe -f C:/Espressif/examples/esp_MESH1234/Makefile all
LD build/app.out
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x3b0): undefined reference to `user_init'
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_rf_pre_init':
(.irom0.text+0x5f4): undefined reference to `user_init'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [build/app.out] Error 1
C:/Espressif/examples/esp_MESH1234/Makefile:187: recipe for target 'build/app.out' failed
User avatar
By Shubham Jain
#32088 Hi trendchaster,

I could not understand why your compiler is not getting the header file or library with user_init(); but I can tell you the procedure I followed.

I followed the steps listed on pg. 135 onwards in the book at this link. http://neilkolban.com/tech/esp8266/

Also, I downloaded the latest SDK from espressif website which has the mesh lib not separate mesh sdk.

Then I went to C:/Espressif and renamed folder ESP8266_SDK as ESP8266_SDK_130 and then appropriately placed the contents from latest sdk (1.4) to ESP8266_SDK.

Then I faced one issue in compiling which was that it was unable to find the mesh library. So I added the entry mesh to the LIBS macro in Makefile of helloworld example which I adapted in eclipse.

Then it got compiled.

Thanking you,
Yours sincerely,
Shubham Jain