BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby leenowell » Sun Feb 03, 2019 3:14 pm

Hi All,

Related to my post about Mesh and Smart Config. As part of my debugging I removed all the smart config calls and tried manually setting the router info using esp_mesh_set_router once the mesh has triggered the "no parent" event (as I deliberately started the mesh with incorrect SSID). The code is as follows (I have obviously changed the actual SSID and Password :) )

Code: Select all

    mesh_router_t newinfo;
    strcpy((char*)newinfo.ssid, "MySSID");
    strcpy((char*)newinfo.password,"password" );
    newinfo.ssid_len = strlen((char*) newinfo.ssid);
    newinfo.allow_router_switch = true;
    ESP_LOGI(HOMEIOT_TAG, "About to call set router org ssid[%s] password[%s] len[%d]", newinfo.ssid, newinfo.password, newinfo.ssid_len);

    ESP_ERROR_CHECK( esp_mesh_set_router(&newinfo));

The log shows the following

Code: Select all


I (16591) mesh_node: MeshNodeEvent: <MESH_EVENT_NO_PARENT_FOUND>scan times:60
I (16601) HomeIoT: About to call set router org ssid[MySSID] password[password] len[6]
I (16611) mesh: <MESH_NWK_LOOK_FOR_NETWORK>router<cfg:0d:fd:3f:0c:00:00> is allowed to switch, find routers with SSID:MySSID
I (16941) mesh: [FIND][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:0, root:0[00:00:00:00:00:00]
I (16941) wifi_node: WIFINodeEvent: Unknown event [1]
I (16941) mesh: [FIND:61]fail to find a network, channel:0, cfg<channel:1, router:MySSID, 0d:fd:3f:0c:00:00>

I (16951) mesh: <MESH_NWK_LOOK_FOR_NETWORK>need_scan:0x3, need_scan_router:0x1, look_for_nwk_count:62
I (17081) mesh: [FIND][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:0, root:0[00:00:00:00:00:00]<scan router>
I (17081) wifi_node: WIFINodeEvent: Unknown event [1]
I (17081) mesh: [FIND:62]fail to find a network, channel:0, cfg<channel:1, router:MySSID, 0d:fd:3f:0c:00:00>

The last 4 lines then repeat as it retries until it eventually triggers a "No parent" event and the whole process starts again.

Looking at the log, it would appear that it is looking on channel 0 instead of channel 1 shown in the "cfg" section. The mesh was originally started using channel 1 and the parameter to esp_mesh_set_router doesn't take channel as an option.

Anyone have any ideas? Does this look like a bug?

thanks

Lee.
Last edited by leenowell on Mon Feb 11, 2019 9:07 pm, edited 1 time in total.

ESP_yudong
Posts: 68
Joined: Wed May 16, 2018 12:31 pm

Re: esp_mesh_set_router doesn't seem to work

Postby ESP_yudong » Mon Feb 11, 2019 10:14 am

Hi leenowell,
Thanks, I agree with you.
This API can never switch channels. We will have a discussion on this API.

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: esp_mesh_set_router doesn't seem to work

Postby leenowell » Mon Feb 11, 2019 11:35 am

Hi

Thanks very much for your reply. As it happens, my example was changing the ssid only. The channel and password were the same as before.

Thanks

Lee.

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby leenowell » Mon Feb 11, 2019 9:22 pm

Hi,

It looks like this is a bug in v3.3 beta ("git describe" says it is version - v3.3-beta1-223-ga62cbfe) as it works fine in v3.1.2 with or without the call to "esp_mesh_set_self_organized(true,true)" after the call to esp_mesh_set_router. The code which does the switch is

Code: Select all

    mesh_router_t newinfo;
    strcpy((char*)newinfo.ssid, "XXXXXXX");
    strcpy((char*)newinfo.password,"YYYYYY" );
    newinfo.ssid_len = strlen((char*) newinfo.ssid); 
    
    ESP_LOGI(HOMEIOT_TAG, "About to call set router org ssid[%s] password[%s] len[%d]", newinfo.ssid, newinfo.password, newinfo.ssid_len);

    esp_err_t err = esp_mesh_set_router(&newinfo);
    ESP_LOGI(HOMEIOT_TAG, "Finished set router err [%d = %s]", err, esp_err_to_name(err));
    err = esp_mesh_set_self_organized(true,true);
    ESP_LOGI(HOMEIOT_TAG, "Finished set self organised [%d = %s]", err, esp_err_to_name(err));

the logs for this code segment using v3.3 beta are as follows

with the call to esp_mesh_set_self_organized

Code: Select all

[0;32mI (22368) mesh_node: MeshNodeEvent: <MESH_EVENT_NO_PARENT_FOUND>scan times:60[0m

[0;32mI (22378) HomeIoT: About to call set router org ssid[XXXXXX] password[YYYYYY] len[6][0m

[0;32mI (22388) HomeIoT: Finished set router err [0 = ESP_OK][0m

I (22388) mesh: [IO]enable self-organizing, search parent<adaptive>

[0;32mI (22398) HomeIoT: Finished set self organised [0 = ESP_OK][0m

D (22408) event: SYSTEM_EVENT_SCAN_DONE, status:1, number:0[0m

I (22408) mesh: <SYSTEM_EVENT_SCAN_DONE>status:fail, num:0, id:188

[0;32mI (22418) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (22408) mesh: <MESH_NWK_SCAN_REQ_PASSIVE>unexpected, stop previous scan by parent selection

I (22428) mesh: <MESH_NWK_SCAN_DONE>unexpected, flush scan results, request a new scan by MESH_NWK_LOOK_FOR_NETWORK

D (26648) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:2[0m

I (26648) mesh: [FIND][ch:0]AP:2, otherID:0, MAP:0, idle:0, candidate:0, root:0[0e:fd:3f:0c:00:00]

[0;32mI (26648) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (26648) mesh: [FIND:61]fail to find a network, channel:0, cfg<channel:1, router:XXXXXX, 0e:fd:3f:0c:00:00>

without the call to esp_mesh_set_self_organized

Code: Select all

[0;32mI (22498) mesh_node: MeshNodeEvent: <MESH_EVENT_NO_PARENT_FOUND>scan times:60[0m

[0;32mI (22508) HomeIoT: About to call set router org ssid[XXXXXX] password[YYYYYY] len[6][0m

[0;32mI (22518) HomeIoT: Finished set router err [0 = ESP_OK][0m

[0;32mI (22528) HomeIoT: Finished set self organised [0 = ESP_OK][0m

D (22828) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:1[0m

I (22828) mesh: [FIND][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:0, root:0[20:fd:3f:0c:00:00]

[0;32mI (22828) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (22838) mesh: [FIND:61]fail to find a network, channel:0, cfg<channel:1, router:XXXXXX, 20:fd:3f:0c:00:00>



I (22848) mesh: <MESH_NWK_LOOK_FOR_NETWORK>need_scan:0x3, need_scan_router:0x1, look_for_nwk_count:62

I (22978) mesh: [FIND][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:0, root:0[20:fd:3f:0c:00:00]<scan router>

D (22978) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:1[0m

I (22978) mesh: [FIND:62]fail to find a network, channel:0, cfg<channel:1, router:XXXXXX, 20:fd:3f:0c:00:00>

Now the same logs for v3.1.2

with the call to esp_mesh_set_self_organized

Code: Select all

[0;32mI (45306) mesh_node: MeshNodeEvent: <MESH_EVENT_NO_PARENT_FOUND>scan times:0[0m

[0;32mI (45306) HomeIoT: About to call set router org ssid[XXXXXX] password[YYYYYY] len[6][0m

[0;32mI (45316) HomeIoT: Finished set router err [0 = ESP_OK][0m

I (45326) mesh: [IO]enable self-organizing, search parent<adaptive>

[0;32mI (45326) HomeIoT: Finished set self organised [0 = ESP_OK][0m

I (45336) mesh: <MESH_NWK_PARENT_SELECTION>scan_from_yield:0, connected_layer:0

D (45346) event: SYSTEM_EVENT_SCAN_DONE, status:1, number:0[0m

W (45346) wifi: scan number 0



[0;32mI (45346) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (45356) mesh: [SCAN][ch:1]AP:0, otherID:0, MAP:0, idle:0, candidate:0, root:0, topMAP:0[c:0,i:0]<>

I (45366) mesh: [FAIL][121]root:0, fail:121, normal:0, <pre>backoff:0



D (45676) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:1[0m

I (45676) mesh: [SCAN][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:1, root:0, topMAP:0[c:0,i:0]router found<>

[0;32mI (45676) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (45676) mesh: 1232[SCAN]init rc[24:0a:c4:82:6f:1d,-48], mine:0, voter:0

I (45686) mesh: 1270, vote myself, router rssi:-48 > voted rc_rssi:-120

I (45696) mesh: [SCAN:1/10]rc[128][24:0a:c4:82:6f:1d,-48], self[24:0a:c4:82:6f:1c,-48,reason:0,votes:1,idle][mine:1,voter:1(1.00)percent:1.00][128,1,24:0a:c4:82:6f:1d]

without the call to esp_mesh_set_self_organized

Code: Select all

[0;32mI (45126) mesh_node: MeshNodeEvent: <MESH_EVENT_NO_PARENT_FOUND>scan times:0[0m

[0;32mI (45136) HomeIoT: About to call set router org ssid[XXXXXX] password[YYYYYY] len[6][0m

[0;32mI (45146) HomeIoT: Finished set router err [0 = ESP_OK][0m

[0;32mI (45146) HomeIoT: Finished set self organised [0 = ESP_OK][0m

I (45156) mesh: <MESH_NWK_PARENT_SELECTION>scan_from_yield:0, connected_layer:0

D (45466) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:1[0m

I (45466) mesh: [SCAN][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:1, root:0, topMAP:0[c:0,i:0]router found<>

[0;32mI (45466) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (45466) mesh: 1232[SCAN]init rc[24:0a:c4:82:6f:1d,-41], mine:0, voter:0

I (45486) mesh: 1270, vote myself, router rssi:-41 > voted rc_rssi:-120

I (45486) mesh: [SCAN:1/10]rc[128][24:0a:c4:82:6f:1d,-41], self[24:0a:c4:82:6f:1c,-41,reason:0,votes:1,idle][mine:1,voter:1(1.00)percent:1.00][128,1,24:0a:c4:82:6f:1d]



D (45806) event: SYSTEM_EVENT_SCAN_DONE, status:0, number:1[0m

I (45806) mesh: [SCAN][ch:1]AP:1, otherID:0, MAP:0, idle:0, candidate:1, root:0, topMAP:0[c:0,i:1]router found<>

[0;32mI (45806) wifi_node: WIFINodeEvent: Unknown event [1][0m

I (45806) mesh: 1232[SCAN]init rc[24:0a:c4:82:6f:1d,-40], mine:0, voter:0

I (45826) mesh: [SCAN:2/10]rc[128][24:0a:c4:82:6f:1d,-40], self[24:0a:c4:82:6f:1c,-40,reason:0,votes:1,idle][mine:1,voter:1(1.00)percent:1.00][128,1,24:0a:c4:82:6f:1d]


leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby leenowell » Tue Feb 12, 2019 8:02 pm

Hi All,

I have now raised this as a bug on git

https://github.com/espressif/esp-idf/issues/3047

thanks

Lee.

ESP_yudong
Posts: 68
Joined: Wed May 16, 2018 12:31 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby ESP_yudong » Wed Feb 13, 2019 7:15 am

Hi Lee,

I can successfully change router using esp_mesh_set_router if the channel is not set or the channel is right.

Would you like try again using example?Is there something wrong with my operation?

I use the internal_communication example and here's my code in NO_PARENT_FOUND handler:

Code: Select all

IDF v3.3-beta1 [646D36C7], main/mesh_main.c
+       {
+           mesh_router_t new_router = {0};
+           strcpy((char*)new_router.ssid, "XXXX");
+           new_router.ssid_len = strlen("XXXX");
+           strcpy((char*)new_router.password, "yyyyyyyy");
+           uint8_t router_bssid[6] = {0x10,0xda,0x43,0x83,0xf3,0x8d};
+           memcpy(new_router.bssid, router_bssid, 6);
+           new_router.allow_router_switch = true;
+           ESP_ERROR_CHECK(esp_mesh_set_router(&new_router));
+           ESP_LOGI(MESH_TAG, "set_router:%s,%s", new_router.ssid, new_router.password); 
+       }
LOGs:

Code: Select all

I (256319) mesh_main: <MESH_EVENT_NO_PARENT_FOUND>scan times:60
I (256329) mesh_main: set_router:XXXX,yyyyyyyy
I (256329) mesh: <MESH_NWK_LOOK_FOR_NETWORK>router<cfg:10:da:43:83:f3:8d> is allowed to switch, find routers with SSID:NETGEAR46
I (256359) mesh: <MESH_NWK_LOOK_FOR_NETWORK>channel<cfg:0> is allowed to switch, do a full channel scan
I (260569) mesh: [S23]XXXX, 10:da:43:83:f3:8d, channel:6, rssi:-44
I (260569) mesh: find router:[ssid_len:9]NETGEAR46, rssi:-44, 10:da:43:83:f3:8d, new channel:6, old channel:0
I (260579) mesh: [FIND][ch:0]AP:48, otherID:0, MAP:0, idle:0, candidate:0, root:0[10:da:43:83:f3:8d]router found
I (260589) mesh: [FIND:61]find a network, channel:6, cfg<channel:0, router:XXXX, 10:da:43:83:f3:8d>

I (260599) mesh_main: <MESH_EVENT_FIND_NETWORK>new channel:6, router BSSID:00:00:00:00:00:00
I (260599) wifi: mode : sta (30:ae:a4:06:73:a0) + softAP (30:ae:a4:06:73:a1)
I (260929) mesh: [SCAN][ch:6]AP:4, otherID:0, MAP:0, idle:0, candidate:1, root:0, topMAP:0[c:0,i:0][10:da:43:83:f3:8d]router found<>
I (260929) mesh: 1206[SCAN]init rc[30:ae:a4:06:73:a1,-41], mine:0, voter:0
I (260939) mesh: 1244, vote myself, router rssi:-41 > voted rc_rssi:-120
I (260949) mesh: [SCAN:1/10]rc[128][30:ae:a4:06:73:a1,-41], self[30:ae:a4:06:73:a0,-41,reason:0,votes:1,idle][mine:1,voter:1(1.00)percent:1.00][128,1,30:ae:a4:06:73:a1] 

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby leenowell » Wed Feb 13, 2019 7:33 am

Thanks very much for your reply. Have you previously started the mesh with the wrong ssid and then this code is what is run when parent not found is triggered?

Also, I noticed you have set the bsid but in my case I wouldn't know what that was. Could you try running it without setting bssid place.

Finally the numbers after "beta" in your version number differs from mine. Not sure if this is significant?

Thanks

Lee.

ESP_yudong
Posts: 68
Joined: Wed May 16, 2018 12:31 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby ESP_yudong » Fri Feb 15, 2019 8:13 am

Hi Lee,
Have you previously started the mesh with the wrong ssid and then this code is what is run when parent not found is triggered?
Also, I noticed you have set the bsid but in my case I wouldn't know what that was. Could you try running it without setting bssid place.
Yes, that's what I did. It also works without setting bssid in my test.

Can you provide the version number you are using now and have another test on my version?

Code: Select all

git log -1
commit 646d36c7287d8e447b5bd76ec11071b739299887
Merge: 6c868c4 8b7b582
Author: Ivan Grokhotkov <ivan@espressif.com>
Date:   Fri Dec 7 14:32:04 2018 +0800

    Merge branch 'feature/nmea-parser' into 'master' 
Thanks

leenowell
Posts: 92
Joined: Tue Jan 15, 2019 1:50 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby leenowell » Fri Feb 15, 2019 9:42 am

Thanks for your reply. I think I am closer to getting the bottom of the issue. Using this code

Code: Select all

    mesh_router_t newinfo = {0};
    strcpy((char*)newinfo.ssid, "XXXXXX");
    strcpy((char*)newinfo.password,"YYYYYY" );
    newinfo.ssid_len = strlen((char*) newinfo.ssid);
    memset(newinfo.bssid, '\0', 6);
    newinfo.allow_router_switch = true;
    ESP_LOGI(HOMEIOT_TAG, "About to call set router org ssid[%s] password[%s] len[%d]", newinfo.ssid, newinfo.password, newinfo.ssid_len);

    esp_err_t err = esp_mesh_set_router(&newinfo);
    ESP_LOGI(HOMEIOT_TAG, "Finished set router err [%d = %s]", err, esp_err_to_name(err));

Line 1 is setting all items in mesh_router_t to '\0' and then after doing this I am setting all attributes to the correct values. This seems to work fine. If I remove the " = {0} ", it fails in v3.3. but not in v3.1.2. TBH - given I am setting all values of the struct (I believe correctly) before calling esp_mesh_set_router, I don't see why the "= {0}" makes a difference. Also why v3.1.2 seems to work fine?

On the bssid front, if the bssid is set, does this have any benefit (e.g. connection time) over providing SSID? Also for the mesh, if only 1 of the SSID/ bssid is correct and the other isn't (e.g. second router with same SSID but different bssid) will the mesh still connect?

ESP_yudong
Posts: 68
Joined: Wed May 16, 2018 12:31 pm

Re: BUG - v3..3 beta : esp_mesh_set_router doesn't seem to work

Postby ESP_yudong » Fri Feb 15, 2019 1:17 pm

Hi Lee,
Yeah, if you remove " = {0} ", items in mesh_router_t are going to have random value. This makes the behavior uncertainty.
Settiing the channel could reduce the connection time. The bssid is usually used when there are more than one router with same ssid.
The device will try to connect another BSSID router when the next "NO_PARENT_FOUND" event appears in case `allow_router_switch` is true.
Thanks.
Last edited by ESP_yudong on Thu Jun 27, 2019 3:11 am, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 25 guests