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

Proxy and NUS in one application

Hi,

We are encountering a problem when we try to avail Nordic UART service (NUS) and Mesh service in one application. The problem statement is that after Provisioning, when we disconnect through the nRF Mesh application and go to nRF Connect application to use NUS, we can send only 20 Bytes of data.

But when we dump just the NUS code we availed the service of sending 244 Bytes of data. According to my knowledge there are two main functions in the main.c file of NUS, where the ATT packet size is set after the changes in sdk_config.h.

The first function is the

nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);

2nd function

nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);

 

When I added these functions to the main.c file, I could send 244 Bytes of data, but the nRF Mesh application does not even initialize the connection with the DK and throws an app_error_weak.c.

 

Hence we are not in a position to provision the node and after disconnecting we cannot push 240 Bytes of data via the nRF Connect application.

We are using nRF52840 DK, on SES platform.

Mesh 2.2V along with 15.0.0.

Kind Regards,

Shrinidhi Bhat

  • Hi Hung,

    I have solved that problem and I am able to send 240 bytes of data. The Process for acquiring the NUS is as follows:

    1) I connect from nRF Mesh application and do the entire Provisioning process.

    2) I open nRF Connect app and cannot see the node because its running in nRF Mesh & hence I disconnect from nRF Mesh app.

    3) I now go to nRF Connect and connect and see 4 services, but the NUS is not yet Proxy service because it is not running on the Mesh app. Hence I disconnect it in nRF Connect application but still keep the tab open.

    4) I connect via nRF Mesh app and go to nRF Connect application. Here the connection is already established because of the action of the nRF Mesh app, hence no need to voluntarily connect application.

    5) Now we can push 240 bytes of data.

    The problem now is since we plan on creating a custom application, we need nRF Mesh and nRF Connect. But since nRF Connect is not open source we have to use nRF Toolbox.

    nRF Toolbox now does not even connect with the node because of it waiting for a mesh_gatt event right? How should the flow be for our custom use? How is the nRF Connect apps connect button so dynamic that it connects with any Nordic device/service.

    In this application we have switch between nRF Connect and nRF Mesh. After Provisioning we have an extra service added too.

    King Regards,

    Shrinidhi Bhat

  • I don't understand your #3. 
    What is " NUS is not yet Proxy service because it is not running on the Mesh app" ? 

    For your application, unless it has special requirement, my suggestion is to trigger a reset after your finish with  configuration. You usually only do provisioning+configuration once in the product  lifetime, so I don't see the problem trigger a reset after you finish with configuration. 

    So what you do is to initiate the NUS service at the booting up, in main. 

    After you have NUS, you can use nRFToolbox UART profile to connect to it. 

  • Hi Hung,

    My 3rd point does not do the reset part of it.

    my suggestion is to trigger a reset after your finish with  configuration

    Could you please help me out here?

    Currently I haven't called NUS is the main.c file. It is present inside the proxy_init() function itself which is called during the second part of provisioning.

    Should I just add the same inside the initialiaze() function in the main function?

    2 further questions:

    1) Currently I am not able to connect via nRF Toolbox. I have a feeling it is because of the services which do not match. During connection also it hits inside the proxy.c file because of the Mesh_GATT event handler. Am I correct here? Please do let me know where I have gone wrong

    2) But if I want to use the Mesh service again, do we require a reset all over again? Because we cannot have two services parallel right? It can work one after the other.

    How do I go about this?

    I thought that we need send different advertising packets from the node for it to connect via the nRF Toolbox app. Please correct me if I am wrong.

    Kind Regards,

    Shrinidhi Bhat

  • I would suggest you to study BLE and how the softdevice works a little bit more. Try playing with the NUS example.

    Please test using nRF Connect, to check what service you have inside the attribute table. What did you observe when you can't connect using nRFToolbox, do you see the devices in the list ? NRFToolbox should connect to any device, and if it check there is no NUS service it will disconnect. 

    There shouldn't be any problem having multiple services in the GATT table. 

    To trigger a reset you call NVIC_SystemReset()

  • When I open the nRF Connect app, we can see 4 services which include UART_service (Only after Provisioning. Before Provisioning we cannot see the NUS)

    When I try to connect via nRF Toolbox, it disconnects automatically after connection. Checking the log there, I have come to an understanding that:

    The node is giving out Mesh proxy service first. Hence the services do not match and it disconnects. Therefore I cant think of a method to have both the services placed on the same priority level. Meaning, if I want the to avail NUS, it would be ideal to have the Node provisioned first. But I should not be able to use NUS without provisioning.

    Hence after connecting via Mesh_proxy service we are able to use NUS. Now since the services do not match via the nRF Toolbox app, it is disconnecting.

    I'm assuming by your reply that the only way to do this is to Reset the node right?

    I will take a look at it.

    King Regards,

    Shrinidhi Bhat

Related