This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use Subnet in Mesh

I am looking for resources/documentations about implementing subnets in Mesh. The use-case I want to implement is:

1. Create two subnets: Subnet A and Subnet B.

2. Provision a node X (Let's say a temperature sensing node) which has network key of both Subnet A and Subnet B.

3. As a starting point Let's say Node X is connected to Subnet A and publish the temperature reading in Subnet A (using the Subnet A's network key)

4. I move the Node X from Subnet A to Subnet B. The Node X should be able to attach itself with Subnet B and start publishing the temperature reading using the Subnet B's network key.

Can someone point me to the relevant resources to implement the above use-case.

Parents
  • Hi,

    This involve 2 parts. First is to add several subnet keys when configuration and secondly is to use different netkey when communicate in different subnet. What you need to do is

    - Increase DSM_SUBNET_MAX in nrf_mesh_config_app.h

    - On the provisioner call config_client_netkey_add() to add additional subnet key .On the provisionee, packet with CONFIG_OPCODE_NETKEY_ADD opcode will be handled in handle_netkey_add_update()

    - On the provisioner add appkeys to the provisionee. Note that one appkey can only bind to one netkey (subnet key) . If you have two subnet, you would need 2 appkeys . Currently in the example we only use one NETKEY_INDEX when handling NODE_SETUP_CONFIG_APPKEY_ADD

    - On the provisionee, you may need 2 models to bind to the 2 appkeys you add. We don't support binding multiple appkeys to one model. 

    After that you can start to communicate in 2 subnet by using the 2 models you have. 

  • Hi,

    I have implemented the BLE Mesh subnet for the "LED switch-on" example using two different models and it is working as expected. But for my use case: a temperature node is a member of two subnets. This means there are 2 different models, one for each subnets. Now my question is:

    How would the temperature node will get to know which model to use? In other words, how does the temperature node auto-switch between the models based on the subnet it gets associated with?

  • Hi Ravi, 

    Each model will bind to different appkey. Each appkey will then bind to different network key (subnet key). When you send data from a model, it will only be transmitted in that subnet that it belong to. 

    When you receive a packet that your model subscribed to (which means inside that subnet your model working in) you will have the meta data pointing out which appkey used and which subnet used. You can find it in the access_message_rx_meta_t struct provided from access layer in your model opp code handler function.

  • Hi Hung,

    In my use-case the node is just broadcasting the temperature reading. Both the models (2 subnets => 2 models) for broadcasting the temperature reading is not subscribed to any topic. So, in this scenario how will the Subnet switching happen?

Reply Children
Related