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?

  • I don't get it. You have 2 model, each model use different appkey , each appkey bound to different netkey. When you want to transfer the data in a subnet, you use the corresponded model. There is no switching here. You simply use the model that is bound to the subnet that you want to send data. 

  • Let me try to rephrase my doubt: 
    1. I have two subnets ( which implies I have 2 models ad 2 appkeys and 2 netkeys ...All this is fine and understood)
    2. I have provisioned my temperature broadcasting node and have supply both the net keys during configuration.
    3. I installed the node in room 1 (Subnet 1) and it is broadcasting its temperature reading using model 1 (bind to Subnet 1)
    4. Now I only physically move the node from room 1 (subnet 1) to room 2(subnet 2). So how would the node understand that it has to broadcast using model 2 (bind to subnet 2) as the subnet 1 is not available?

    In other words how would the node switch the model on its own?

    Imp: The node is not subscribed to any topic. It is just broadcasting its temperature reading.

Reply
  • Let me try to rephrase my doubt: 
    1. I have two subnets ( which implies I have 2 models ad 2 appkeys and 2 netkeys ...All this is fine and understood)
    2. I have provisioned my temperature broadcasting node and have supply both the net keys during configuration.
    3. I installed the node in room 1 (Subnet 1) and it is broadcasting its temperature reading using model 1 (bind to Subnet 1)
    4. Now I only physically move the node from room 1 (subnet 1) to room 2(subnet 2). So how would the node understand that it has to broadcast using model 2 (bind to subnet 2) as the subnet 1 is not available?

    In other words how would the node switch the model on its own?

    Imp: The node is not subscribed to any topic. It is just broadcasting its temperature reading.

Children
Related