Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPN not receiving any message from Friend node after LPN device reset #24311

Closed
rhardik opened this issue Apr 13, 2020 · 2 comments · Fixed by #24327
Closed

LPN not receiving any message from Friend node after LPN device reset #24311

rhardik opened this issue Apr 13, 2020 · 2 comments · Fixed by #24327
Assignees
Labels
area: Bluetooth Mesh bug The issue is a bug, or the PR is fixing a bug

Comments

@rhardik
Copy link

rhardik commented Apr 13, 2020

Describe the bug

I've added a Generic On-Off model in mesh_shell code to publish a message from Friend node to LPN node. it's working fine after provision and configuration

Now if I reset the LPN node then friendship get's established again but it doesn't receive any message from friend.

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/rhardik/reproduce-zephyr-issues.git
  2. cd lpn-node-reset
  3. comment the line zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL shell.c) from zephyr/subsys/bluetooth/mesh/CMakeLists.txt
  4. compile friend and lpn code and flash the code to device
  5. open serial terminal and press enter. you will see a shell with $uart
  6. Type command "mesh init" and then "mesh pb-gatt on" (for both device)
  7. Open nRF mesh android app. Provision and then
    - configure "generic on-off client" on Friend node with publish address 0xc000
    - configure "generic on-ff server: LPN node with subscribe address 0xc000
  8. Type command "mesh lpn on" in LPN terminal and "mesh friend on" in Friend terminal.
  9. Now type command "mesh hello" on Friend terminal
    • After few seconds you should see "HHHHEEELLLLOOOO" string on LPN terminal.
  10. Now reset LPN device then
    • type command "mesh init" and "mesh lpn on" in LPN terminal and
    • type "mesh hello" command in Friend terminal
      and now it should print "HHHHEEELLLLOOOO" string on LPN terminal but it won't.

Expected behavior
After device reset also it should work.

Impact
showstopper

Screenshots or console output
Message sent by Friend node (working)

```
:~$ mesh hello
[00:28:08.686,004] bt_mesh_friend.bt_mesh_friend_match: LPN 0x0003 matched address 0xc000
[00:28:08.686,035] bt_mesh_friend.bt_mesh_friend_enqueue_tx: net_idx 0x0000 dst 0xc000 src 0x0002
[00:28:08.686,065] bt_mesh_friend.friend_lpn_enqueue_tx: LPN 0x0003
[00:28:08.686,096] bt_mesh_friend.enqueue_friend_pdu: type 0
[00:28:08.686,096] bt_mesh_friend.friend_lpn_enqueue_tx: Queued message for LPN 0x0003
[00:28:09.059,539] bt_mesh_friend.bt_mesh_friend_match: LPN 0x0003 matched address 0xc000
[00:28:09.059,539] bt_mesh_friend.bt_mesh_friend_enqueue_tx: net_idx 0x0000 dst 0xc000 src 0x0002
[00:28:09.059,570] bt_mesh_friend.friend_lpn_enqueue_tx: LPN 0x0003
[00:28:09.059,600] bt_mesh_friend.enqueue_friend_pdu: type 0
[00:28:09.059,600] bt_mesh_friend.friend_lpn_enqueue_tx: Queued message for LPN 0x0003
```

Message received by LPN node

```
uart:~$
HHHHEEELLLLOOOO
[00:28:08.183,135] bt_mesh_lpn.lpn_timeout: state: established
[00:28:08.183,166] bt_mesh_lpn.send_friend_poll: lpn->sent_req 0x00
[00:28:08.184,356] bt_mesh_lpn.req_sent: req 0x01 duration 90 err 0 state established
[00:28:08.184,387] bt_mesh_lpn.lpn_set_state: established -> recv delay
[00:28:08.274,475] bt_mesh_lpn.lpn_timeout: state: recv delay
[00:28:08.276,123] bt_mesh_lpn.lpn_set_state: recv delay -> wait update
[00:28:08.358,062] bt_mesh_lpn.friend_response_received: lpn->sent_req 0x01
[00:28:08.358,367] bt_mesh_lpn.lpn_set_state: wait update -> established
[00:28:08.358,367] bt_mesh_lpn.bt_mesh_lpn_msg_received: Requesting more messages from Friend
[00:28:08.358,367] bt_mesh_lpn.send_friend_poll: lpn->sent_req 0x00
[00:28:08.359,619] bt_mesh_lpn.req_sent: req 0x01 duration 90 err 0 state established
[00:28:08.359,619] bt_mesh_lpn.lpn_set_state: established -> recv delay
```

Friend side logs when reset LPN

```
36:27.304,718] bt_mesh_friend.friend_timeout: lpn 0x0003 send_last 0 last 0x20006584
[00:36:27.304,748] bt_mesh_friend: Friendship lost with 0x0003
[00:36:27.304,748] bt_mesh_friend.friend_clear: LPN 0x0003
```

Friend logs when sending message to LPN (after LPN reboots)

```
uart:~$ mesh hello
[00:38:11.604,278] bt_mesh_friend.bt_mesh_friend_match: No matching LPN for address 0xc000
[00:38:11.977,630] bt_mesh_friend.bt_mesh_friend_match: No matching LPN for address 0xc000
[00:38:22.377,380] bt_mesh_friend.bt_mesh_friend_match: No matching LPN for address 0x0002
[00:38:22.384,185] bt_mesh_friend.bt_mesh_friend_find: net_idx 0x0000 lpn_addr 0x0003
[00:38:22.384,216] bt_mesh_friend.bt_mesh_friend_poll: msg->fsn 0 frnd->fsn 1
[00:38:22.384,216] bt_mesh_friend.friend_recv_delay: Waiting RecvDelay of 151 ms
[00:38:22.384,246] bt_mesh_friend.encode_update: lpn 0x0003 md 0x00
[00:38:22.384,246] bt_mesh_friend.encode_friend_ctl: LPN 0x0003
[00:38:22.384,307] bt_mesh_friend.bt_mesh_friend_poll: Enqueued Friend Update to empty queue
[00:38:22.535,278] bt_mesh_friend.friend_timeout: lpn 0x0003 send_last 0 last 0x00000000
[00:38:22.535,308] bt_mesh_friend.update_overwrite: Update Previous Friend Update MD 0x00 -> 0x00
[00:38:22.535,430] bt_mesh_friend.friend_timeout: Sending buf 0x20006584 from Friend Queue of LPN 0x0003
[00:38:22.537,567] bt_mesh_friend.buf_send_start: err 0
[00:38:22.598,693] bt_mesh_friend.buf_send_end: err 0
```

Environment (please complete the following information):

  • OS: Linux
  • Toolchain: Zephyr SDK
  • Commit SHA: a3fae2f
@rhardik rhardik added the bug The issue is a bug, or the PR is fixing a bug label Apr 13, 2020
@LingaoM
Copy link
Collaborator

LingaoM commented Apr 13, 2020

well, it’s not bug, but it should to do change in the future, if you read log from friend node side [00:38:11.604,278] bt_mesh_friend.bt_mesh_friend_match: No matching LPN for address 0xc000 , mean that lpn node not subscribe 0xc000 address. So lpn node not receive such message after reset.

Next: you should add cmd to subscribe 0xc000 use bt_mesh_lpn_group_add

@LingaoM
Copy link
Collaborator

LingaoM commented Apr 13, 2020

well, we should change currently implementation;

Firstly: call lpn group add (mod subscribe address )when recovered from flash.

static int mod_set_sub(struct bt_mesh_model *mod, size_t len_rd,
settings_read_cb read_cb, void *cb_arg)
{
ssize_t len;
/* Start with empty array regardless of cleared or set value */
(void)memset(mod->groups, 0, sizeof(mod->groups));
if (len_rd == 0) {
BT_DBG("Cleared subscriptions for model");
return 0;
}
len = read_cb(cb_arg, mod->groups, sizeof(mod->groups));
if (len < 0) {
BT_ERR("Failed to read value (err %zd)", len);
return len;
}
BT_DBG("Decoded %zu subscribed group addresses for model",
len / sizeof(mod->groups[0]));
return 0;
}

Secondly: call lpn group add 0xffff(#24009), when provisioned completely.

Lastly: Reinit lpn group when node reset .

int bt_mesh_lpn_init(void)
{
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
BT_DBG("");
k_delayed_work_init(&lpn->timer, lpn_timeout);

Can you submit pr to fix this issuer.

jhedberg pushed a commit that referenced this issue Apr 19, 2020
When low power node reset, should add group address to
friend subscription list.

Fixes: #24311

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
hakehuang pushed a commit to hakehuang/zephyr that referenced this issue Jun 20, 2020
When low power node reset, should add group address to
friend subscription list.

Fixes: zephyrproject-rtos#24311

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Mesh bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants