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

Setup Mesh Server Over Serial API

Hi all,

I am working on an application where I have an application MCU and my idea was to use nRF52 as a 'modem' over serial API. The device I am making is supposed to be a server in a mesh network. So far I have managed to provision the device over serial API by responding to the requests from the provisioner, but I have a problem loading the models and elements through serial API.

I can see that the serial API has functions for initializing models. But what about adding elements? There are set functions for setting properties of existing elements but I can't seem to be able to figure out how to add more and fill them with models.

I am still new to nRF Mesh development so I might be missing something obvious here

Any help would be appreciated 

Thank you

Duv_FT

Parents
  • Hi Duv, 

     

    You are right, the element for now is hardcoded. You choose the number of element on your serial device by modifying ACCESS_ELEMENT_COUNT in nrf_mesh_config_app.h .

    Note that this value is also read by the interactive python. So the source code and the hex file running on the serial board have to be in sync. 

  • Hi Hung,

    Thanks for your replay.

    Can you check if I got right how the models work over serialAPI:

    1. In the code on nRF52 I have to define and initialize the models and set them up during startup

    2. add models to the serial list using serial_handler_models_register

    3. Start Serial API

    4. Call models init over serial to get the Handles

    5. Then use the model serial API using the handle

    Is this the right approach?

    Thanks in advance

Reply
  • Hi Hung,

    Thanks for your replay.

    Can you check if I got right how the models work over serialAPI:

    1. In the code on nRF52 I have to define and initialize the models and set them up during startup

    2. add models to the serial list using serial_handler_models_register

    3. Start Serial API

    4. Call models init over serial to get the Handles

    5. Then use the model serial API using the handle

    Is this the right approach?

    Thanks in advance

Children
  • Hi duv, 

    Yes, I think it's the right approach when you want to locate the model on the serial device and want to have control from the serial interface. 


    Another option is to have the model be initialized on the host (PC) and the serial interface act as purely connectivity chip. This approach you can find an example here, in "Blinking LEDs" section

    Depends on your application you can choose more relevant approach.

     

  • Hi Hung,

    I have tried the approach from the link but it I have run into a problem. When I run the serial example I can do the provisioning properly as described in the link. However when I  try to get the Composition data from the porvisioner I get the following error on the node 

    Is this an issue because there is no ConfigurationDevice Model implemented for pythonACI or is there something else a problem here?

    Thank you so much for all your help

    duv

  • Hi Duv, 

     

    Could you let me know about your setup ? Which device is provisioner which device running serial  ? 

    I don't think the PyACI has configuration server on it to response with composition data.You would need to implement one .

    The error I see in the screenshot I think it's when you receive a packet which has the element number outside of the number of elements on the node. This could be a bug that we don't have the correct number of elements as defined by ACCESS_ELEMENT_COUNT. COuld you check what was the self.elements value ? 

  • Hi Hung,

    The setup is as follows:

    Device 1 - provisioner - nRF52-DK running serial example connected to PC running pyACI

    Device 2 - node - nRF52-DK running serial example connected to PC running pyACI. The code is altered in a way that the following block is commented out in main.c

    // if (!m_device_provisioned)
    // {
    // static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
    // mesh_provisionee_start_params_t prov_start_params =
    // {
    // .p_static_data = static_auth_data,
    // .prov_complete_cb = NULL,
    // .p_device_uri = NULL
    // };
    // ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
    // }

    with this code in place it wouldn't provision. it would hang half way through. I think it is as there were two things attempting to provision the device, the serialAPI and the onboard handler. By commenting the code out the code would continue and finish provisioning. 

    I would setup the node device to be a provisionee and start listening. Then I would follow the example on how to provision the device using pyACI as described in the tutorial and the provisioning works fine. After that when I try to retrieve the composition data I get the error from pic on the node.

    In the example code #define ACCESS_ELEMENT_COUNT (1)  in the C code.

    In the python code in access.py 

    def __event_handler(self, event):
         if event._opcode == Event.MESH_MESSAGE_RECEIVED_UNICAST:
         message = AccessMessage(event)
         element_index = event._data["dst"] - self.elements[0].address

    the event._data["dst"] is 16 which is ok as the node was provisioned to 16

    self.elements[0].address = 1; shouldnt the address of the first element be the unicastAddress?

    it seems that the self.elements[0].address didnt't get updated after provisioning in the Event.PROV_COMPLETE

    DUV

  • Hei Duv, 

     

    Could you post the full log of what you do with pyAci on the provisioner and the provisionee ? Strange that self.elements[0].address was not updated. 

Related