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

ble_app_gzll & freeRTOS & peer manager

Hi

I am running some thing similar to the multiprotocol ble_app_gzll example but using freeRTOS and peer manager. Effectively the the main in ble_app_gzll example is a freeRTOS task.

  1. The first issue I came across was reinitialising ble. (ie this is the second time the ble is started) The conn_params_init()->ble_conn_params_init() failed with the error NRF_ERROR_INVALID_STATE It looks like the timer cannot be reinitialized.

Do I have to some how delete the timer when stopping the ble task. This would mean it would behave differently to the non freeRTOS version.

I have commented out the APP_CHECK error so it continues to run. I am assuming this timer never gets destroyed which is why the osHandle is not NULL

I can now stop and start the ble module. Is there a better way of doing this?

  1. However on the 3rd time of initialising there is now a problem with the peer manager. It fails in pm_init -> gcm_init() All the flags are BLE_CONN_STATE_USER_FLAG_INVALID

Any suggestions?

Parents
  • Ok So here are the fixes for running peer manager when you need to stop and restart the Ble app

    Note: my project is based on the ble_app_hrs_freertos which has been modified to behave like the ble_app_gzll project so that the ble stack can be stoped and started

    1. ble_conn_state_init(); needs to be run on the initialization of the ble. Before the peer manager in initialised. This clears all the flags other wise the pm_init()->gcm_init() can not acquire them.

    ble_app_hrs_freertos: (tested)

    1. Add ble_conn_state_init(); to the static void ble_init(void) function

    ble_app_gzll project: (not tested)

    1. ble_app_gzll_hr.c -> Add ble_conn_state_init(); to the void ble_stack_start(void)function
    • Non urgent as I can fix this myself as it is not part of an SDK library/component.

    2)m_n_registrants needs to be reset to 0 on initialisation. This clears the event handlers and allows new ones to be registered using the pm_register(pm_evt_handler). Other wise each time the peer_manager_init() is run it will register the event again and fill up the buffer.

    Please can a fix\ patch be put in for this. I need a way of setting m_n_registrants to 0. Urgent as it requires a change to the peer manager which is a SDK library/component.

    This could either be done in ret_code_t pm_init(void) or by making a new function to clear events. Im not fussed.

    3)There is now a third issue with the fds module. It is the same scenario as in the peer manager.

    at no point is m_users set to 0! This could be a bug if the memory location at m_users is not 0 on start up!

    in my opinion this should be set to 0 when initialized and in the fds_init() function.

  • m_users is a static variable and is zero-initialized by the startup routines when the program starts.

Reply Children
No Data
Related