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

Mesh Error 18 when calling proxy_start();

Hi,

First my setup:

Windows 10, Segger Emmbedded V4.50, nrf52840, custom board, Mesh SDK 4.0

The issue:

My device is meant to operate while plugged in to an AC power source but falls back to battery power so as to preserve the device time during a power outage. Before going to sleep, after a power outage, the device turns of proxy/mesh advertising using the below code:

if(m_device_provisioned){              
      err_code = proxy_stop();
      if (err_code == NRF_SUCCESS){
          proxy_disable();
          scanner_disable();
          err_code = nrf_mesh_disable();
          APP_ERROR_CHECK(err_code);
      }
}else{
    mesh_provisionee_prov_listen_stop();
}

When waking up the code is as follows:

if(m_device_provisioned){
              uint32_t retval = proxy_enable();

              if (retval == NRF_SUCCESS){
                  retval = proxy_start();
              }  
              if (retval == NRF_SUCCESS){
                  retval = nrf_mesh_enable();
              }
          }else{
              //Restart provisioning advertisements
              provisionee_start();
} 

This works fine if not connected to a proxy (my android phone). But if connected and a short, undetermined, length of time passes between going to sleep and awaking, an assert error is thrown when running proxy_start().

<t:     762522>, proxy.c,  862, active_connection_count = 0
<t:     762530>, app_error_weak.c,  115, Mesh error 18 at 0x0002933B (D:\NordicSemi\nRF5-SDK-for-Mesh/examples/common/src/mesh_adv.c:173)

I have looked at the area reported to cause the error "NRF_ERROR_CONN_COUNT < Maximum connection count exceeded" and I have confirmed, as shown in the logs above, that the active_connection_count = 0. As such, I am at a loss as to why I am getting this error.

Please help.

  • Hi,

    It seems like that the device is still in a connection when calling proxy_start(). There is a log of "   __LOG(LOG_SRC_BEARER, LOG_LEVEL_INFO, "Disconnected\n");" inside gatt_evt_handler() in MESH_GATT_EVT_TYPE_DISCONNECTED event. You can try turning this on to check if the link is actually disconnected.

    Also, the MESH_GATT_EVT_TYPE_DISCONNECTED event only come after a short period of time after calling proxy_stop(). Maybe you can try to wait until there is an event NRF_MESH_EVT_PROXY_STOPPED before enabling the proxy again.

  • Thanks for the response.

    I tried adding delays and while loops but waiting just didn't seem to work. In the end I added a if statement which prevented calling proxy_start(); if the MESH_GATT_EVT_TYPE_DISCONNECTED event was not triggered before waking the device.

    That worked out great. Thanks.

Related