How parent node detects new child node join?

jamesbong
Posts: 8
Joined: Sat May 16, 2015 11:17 pm

How parent node detects new child node join?

Postby jamesbong » Wed Jun 29, 2016 12:56 am

How parent node detects new child node join?
I have tried espconn_mesh_regist_conn_ready_cb but espconn_mesh_connect always error
and I have tried espconn_mesh_regist_usr_cb but it cause the root never connect to server

Is there any simple to detects a new child node join?

ESP_Alen

Re: How parent node detects new child node join?

Postby ESP_Alen » Wed Jun 29, 2016 6:26 pm

jamesbong wrote:How parent node detects new child node join?
I have tried espconn_mesh_regist_conn_ready_cb but espconn_mesh_connect always error
and I have tried espconn_mesh_regist_usr_cb but it cause the root never connect to server

Is there any simple to detects a new child node join?


1. espconn_mesh_regist_usr_cb
when new child node joins, the system will call the user_callbak;

jamesbong
Posts: 8
Joined: Sat May 16, 2015 11:17 pm

Re: How parent node detects new child node join?

Postby jamesbong » Wed Jun 29, 2016 8:09 pm

I have tried espconn_mesh_regist_usr_cb but it cause the root never connect to server.
If I remove this call, the connection is OK
Do you have a mesh_demo that root can connect to server after added espconn_mesh_regist_usr_cb.
My test is as follows:
void ICACHE_FLASH_ATTR test_mesh_usr_callback(void *arg){
MESH_DEMO_PRINT("test_mesh_usr_callback\n");
}
void ICACHE_FLASH_ATTR test_mesh_conn_ready_cb(void *arg){
MESH_DEMO_PRINT("test_mesh_conn_ready_cb\n");
}
void ICACHE_FLASH_ATTR mesh_enable_cb(int8_t res){
if (res == MESH_OP_FAILURE) {
MESH_DEMO_PRINT("mesh_enable_cb = enable mesh fail\n");
espconn_mesh_enable(mesh_enable_cb, MESH_LOCAL);
return;
}
/*
* try to estable user virtual connect
* user can to use the virtual connect to sent packet to any node, server or mobile.
* if you want to sent packet to one node in mesh, please build p2p packet
* if you want to sent packet to server/mobile, please build normal packet (uincast packet)
* if you want to sent bcast/mcast packet, please build bcast/mcast packet
*/
MESH_DEMO_MEMSET(&g_ser_conn, 0 ,sizeof(g_ser_conn));
MESH_DEMO_MEMSET(&ser_tcp, 0, sizeof(ser_tcp));

MESH_DEMO_MEMCPY(ser_tcp.remote_ip, server_ip, sizeof(server_ip));
ser_tcp.remote_port = server_port;
ser_tcp.local_port = espconn_port();
g_ser_conn.proto.tcp = &ser_tcp;

toHex(ser_tcp.local_ip, 4, "local_ip");
MESH_DEMO_PRINT("mesh_enable_cb = %d", ser_tcp.local_port);
if (espconn_regist_connectcb(&g_ser_conn, esp_server_con_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb\n");
if (espconn_regist_recvcb(&g_ser_conn, esp_recv_entrance)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb\n");
if (espconn_mesh_regist_usr_cb(test_mesh_usr_callback)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb\n");
if (espconn_mesh_regist_conn_ready_cb(test_mesh_conn_ready_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb\n");
//regist the other callback here :: sent_cb, reconnect_cb, disconnect_cb
if (espconn_mesh_connect(&g_ser_conn)) {
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect\n");
}

ESP_Alen

Re: How parent node detects new child node join?

Postby ESP_Alen » Tue Jul 05, 2016 3:52 pm

jamesbong wrote:I have tried espconn_mesh_regist_usr_cb but it cause the root never connect to server.
If I remove this call, the connection is OK
Do you have a mesh_demo that root can connect to server after added espconn_mesh_regist_usr_cb.
My test is as follows:
void ICACHE_FLASH_ATTR test_mesh_usr_callback(void *arg){
MESH_DEMO_PRINT("test_mesh_usr_callback\n");
}
void ICACHE_FLASH_ATTR test_mesh_conn_ready_cb(void *arg){
MESH_DEMO_PRINT("test_mesh_conn_ready_cb\n");
}
void ICACHE_FLASH_ATTR mesh_enable_cb(int8_t res){
if (res == MESH_OP_FAILURE) {
MESH_DEMO_PRINT("mesh_enable_cb = enable mesh fail\n");
espconn_mesh_enable(mesh_enable_cb, MESH_LOCAL);
return;
}
/*
* try to estable user virtual connect
* user can to use the virtual connect to sent packet to any node, server or mobile.
* if you want to sent packet to one node in mesh, please build p2p packet
* if you want to sent packet to server/mobile, please build normal packet (uincast packet)
* if you want to sent bcast/mcast packet, please build bcast/mcast packet
*/
MESH_DEMO_MEMSET(&g_ser_conn, 0 ,sizeof(g_ser_conn));
MESH_DEMO_MEMSET(&ser_tcp, 0, sizeof(ser_tcp));

MESH_DEMO_MEMCPY(ser_tcp.remote_ip, server_ip, sizeof(server_ip));
ser_tcp.remote_port = server_port;
ser_tcp.local_port = espconn_port();
g_ser_conn.proto.tcp = &ser_tcp;

toHex(ser_tcp.local_ip, 4, "local_ip");
MESH_DEMO_PRINT("mesh_enable_cb = %d", ser_tcp.local_port);
if (espconn_regist_connectcb(&g_ser_conn, esp_server_con_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb\n");
if (espconn_regist_recvcb(&g_ser_conn, esp_recv_entrance)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb\n");
if (espconn_mesh_regist_usr_cb(test_mesh_usr_callback)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb\n");
if (espconn_mesh_regist_conn_ready_cb(test_mesh_conn_ready_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb\n");
//regist the other callback here :: sent_cb, reconnect_cb, disconnect_cb
if (espconn_mesh_connect(&g_ser_conn)) {
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect\n");
}


I shall post the demo on github soon.

ESP_Alen

Re: How parent node detects new child node join?

Postby ESP_Alen » Tue Jul 05, 2016 5:42 pm

Alen wrote:
jamesbong wrote:I have tried espconn_mesh_regist_usr_cb but it cause the root never connect to server.
If I remove this call, the connection is OK
Do you have a mesh_demo that root can connect to server after added espconn_mesh_regist_usr_cb.
My test is as follows:
void ICACHE_FLASH_ATTR test_mesh_usr_callback(void *arg){
MESH_DEMO_PRINT("test_mesh_usr_callback\n");
}
void ICACHE_FLASH_ATTR test_mesh_conn_ready_cb(void *arg){
MESH_DEMO_PRINT("test_mesh_conn_ready_cb\n");
}
void ICACHE_FLASH_ATTR mesh_enable_cb(int8_t res){
if (res == MESH_OP_FAILURE) {
MESH_DEMO_PRINT("mesh_enable_cb = enable mesh fail\n");
espconn_mesh_enable(mesh_enable_cb, MESH_LOCAL);
return;
}
/*
* try to estable user virtual connect
* user can to use the virtual connect to sent packet to any node, server or mobile.
* if you want to sent packet to one node in mesh, please build p2p packet
* if you want to sent packet to server/mobile, please build normal packet (uincast packet)
* if you want to sent bcast/mcast packet, please build bcast/mcast packet
*/
MESH_DEMO_MEMSET(&g_ser_conn, 0 ,sizeof(g_ser_conn));
MESH_DEMO_MEMSET(&ser_tcp, 0, sizeof(ser_tcp));

MESH_DEMO_MEMCPY(ser_tcp.remote_ip, server_ip, sizeof(server_ip));
ser_tcp.remote_port = server_port;
ser_tcp.local_port = espconn_port();
g_ser_conn.proto.tcp = &ser_tcp;

toHex(ser_tcp.local_ip, 4, "local_ip");
MESH_DEMO_PRINT("mesh_enable_cb = %d", ser_tcp.local_port);
if (espconn_regist_connectcb(&g_ser_conn, esp_server_con_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_connectcb\n");
if (espconn_regist_recvcb(&g_ser_conn, esp_recv_entrance)) {
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = regist_recvcb\n");
if (espconn_mesh_regist_usr_cb(test_mesh_usr_callback)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_usr_cb\n");
if (espconn_mesh_regist_conn_ready_cb(test_mesh_conn_ready_cb)) {
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = espconn_mesh_regist_conn_ready_cb\n");
//regist the other callback here :: sent_cb, reconnect_cb, disconnect_cb
if (espconn_mesh_connect(&g_ser_conn)) {
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect err\n");
espconn_mesh_disable(NULL);
return;
}
MESH_DEMO_PRINT("mesh_enable_cb = mesh_connect\n");
}


I shall post the demo on github soon.


We have post the demo to detect new child joins mesh.
esp_mesh_new_child_notify();

Who is online

Users browsing this forum: No registered users and 15 guests