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

Multi advertising non connectable and connectable are blocking CPU on nrf52840

Hello,

In our project there is a problem that we encountered is happening when the Nordic BLE mesh advertising and connectable advertising for GATT connections are enabled in the same time. This problem is behaving by blocking the access to CPU for maximum of 15.3 ms, which is huge. As you can see in the attached images, these blocking issues are sporadic without having a period of happening. This is not happening if there only Nordic Mesh is available or only the GATT advertising is started. We are thinking of using the Radio timeslots but we suppose this will resolve only the transmission part since the reception is asynchronous from a third party device.  

      We are using the TIMER1 interrupt for toggling an GPIO (in project it used to have the clock on the line). The Softdevice used is S140 6.1.0 and nRF5 SDK v.15.0

 

   How can we handle this worst 15.3ms latency? Who needs so much CPU time?

Thank you,

 Catalin

Parents
  • Hi Martin,

       I have tried a few advertising connectable solutions, even the one from the proxy. In the attachment you can see the lastest inspired from the coexist examples available in NRF Mesh SDK 2.1.1,

    /*
     * advert.c
     *
     *  Created on: Aug 24, 2018
     *      Author: Cata
     */
    
    //#include "ble_advdata.h"
    #include "ble_advertising.h"
    #include "mesh_adv.h"
    #include "timer_scheduler.h"
    #include "gatt_util.h"
    #include "dara.h"
    #include "utils.h"
    
    #include "nrf_sdh_ble.h"
    #include "nrf_sdh_soc.h"
    
    #include "log.h"
    
    #define MESH_ADV_ADV_TYPE 					BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED
    #define MESH_ADV_DATA_SIZE_MAX 				BLE_GAP_ADV_SET_DATA_SIZE_MAX
    #define ADV_NETWORK_ITERATE_INTERVAL_US     SEC_TO_US(10)
    
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(500, UNIT_1_25_MS)        /**< Minimum acceptable connection interval (0.5 seconds).  */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(1000, UNIT_1_25_MS)       /**< Maximum acceptable connection interval (1 second). */
    #define SLAVE_LATENCY                   0                                       /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)         /**< Connection supervisory timeout (4 seconds). */
    
    #define APP_ADV_INTERVAL                800                                     /**< The advertising interval (in units of 0.625 ms. This value corresponds to 500 ms). */
    #define APP_ADV_DURATION                BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< Disable advertising timeout. */
    
    //#define APP_ADV_INTERVAL                	391                                     /**< The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */
    //#define APP_ADV_DURATION                	BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< The advertising time-out (in units of seconds). When set to 0, we will never time out. */
    
    extern st_Dara_t g_stDara;
    extern ble_util_t m_util;
    
    BLE_ADVERTISING_DEF(m_advertising);                     /**< Advertising module instance. */
    
    /**@brief Function for handling advertising events.
     *
     * @param[in] ble_adv_evt  Advertising event.
     */
    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
        ret_code_t err_code;
    
        switch (ble_adv_evt)
        {
            case BLE_ADV_EVT_FAST:
                break; // BLE_ADV_EVT_FAST
    
            case BLE_ADV_EVT_IDLE:
                break; // BLE_ADV_EVT_IDLE
    
            default:
                break;
        }
    }
    
    void advertising_init(void)
    {
    	ret_code_t             err_code;
    	ble_advertising_init_t init;
        ble_advdata_t srdata;
        ble_advdata_manuf_data_t manufdata;
        ble_gap_addr_t addr;
    
        uint8_t mandata[6] = {0, 0, 0, 0, 0, 0};
        ble_uuid_t m_adv_uuids[] = {{UTIL_UUID_SERVICE, m_util.uuid_type}};
    
    	memset(&init, 0, sizeof(init));
    
     	memset(&init.srdata, 0, sizeof(init.srdata));
     	init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
     	init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
    	init.advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
    	init.advdata.short_name_len     = 4;
    
    	//init.advdata.include_appearance      = false;
    	//init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    	//init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    	//init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
    	init.advdata.p_manuf_specific_data = &manufdata;
    
        manufdata.company_identifier = ACCESS_COMPANY_ID_DARA;
        manufdata.data.size = 6;
    
    	g_stDara.m_uiNodeid = (uint16_t)((*(uint32_t*) &NRF_FICR->DEVICEID[0]) & 0x3FFF);
        mandata[4] = g_stDara.m_uiNodeid;
        mandata[5] = (uint8_t)(g_stDara.m_uiNodeid >> 8);
    
    	manufdata.data.p_data =  mandata;
    
    	init.config.ble_adv_fast_enabled  = true;
    	init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    	init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    
    	init.evt_handler = on_adv_evt;
    
    	err_code = ble_advertising_init(&m_advertising, &init);
    	APP_ERROR_CHECK(err_code);
    
    	ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    
    /**@brief Function for starting advertising.
     */
    void advertising_start(bool erase_bonds)
    {
        uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    }
    

Reply
  • Hi Martin,

       I have tried a few advertising connectable solutions, even the one from the proxy. In the attachment you can see the lastest inspired from the coexist examples available in NRF Mesh SDK 2.1.1,

    /*
     * advert.c
     *
     *  Created on: Aug 24, 2018
     *      Author: Cata
     */
    
    //#include "ble_advdata.h"
    #include "ble_advertising.h"
    #include "mesh_adv.h"
    #include "timer_scheduler.h"
    #include "gatt_util.h"
    #include "dara.h"
    #include "utils.h"
    
    #include "nrf_sdh_ble.h"
    #include "nrf_sdh_soc.h"
    
    #include "log.h"
    
    #define MESH_ADV_ADV_TYPE 					BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED
    #define MESH_ADV_DATA_SIZE_MAX 				BLE_GAP_ADV_SET_DATA_SIZE_MAX
    #define ADV_NETWORK_ITERATE_INTERVAL_US     SEC_TO_US(10)
    
    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(500, UNIT_1_25_MS)        /**< Minimum acceptable connection interval (0.5 seconds).  */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(1000, UNIT_1_25_MS)       /**< Maximum acceptable connection interval (1 second). */
    #define SLAVE_LATENCY                   0                                       /**< Slave latency. */
    #define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)         /**< Connection supervisory timeout (4 seconds). */
    
    #define APP_ADV_INTERVAL                800                                     /**< The advertising interval (in units of 0.625 ms. This value corresponds to 500 ms). */
    #define APP_ADV_DURATION                BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< Disable advertising timeout. */
    
    //#define APP_ADV_INTERVAL                	391                                     /**< The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */
    //#define APP_ADV_DURATION                	BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED   /**< The advertising time-out (in units of seconds). When set to 0, we will never time out. */
    
    extern st_Dara_t g_stDara;
    extern ble_util_t m_util;
    
    BLE_ADVERTISING_DEF(m_advertising);                     /**< Advertising module instance. */
    
    /**@brief Function for handling advertising events.
     *
     * @param[in] ble_adv_evt  Advertising event.
     */
    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
        ret_code_t err_code;
    
        switch (ble_adv_evt)
        {
            case BLE_ADV_EVT_FAST:
                break; // BLE_ADV_EVT_FAST
    
            case BLE_ADV_EVT_IDLE:
                break; // BLE_ADV_EVT_IDLE
    
            default:
                break;
        }
    }
    
    void advertising_init(void)
    {
    	ret_code_t             err_code;
    	ble_advertising_init_t init;
        ble_advdata_t srdata;
        ble_advdata_manuf_data_t manufdata;
        ble_gap_addr_t addr;
    
        uint8_t mandata[6] = {0, 0, 0, 0, 0, 0};
        ble_uuid_t m_adv_uuids[] = {{UTIL_UUID_SERVICE, m_util.uuid_type}};
    
    	memset(&init, 0, sizeof(init));
    
     	memset(&init.srdata, 0, sizeof(init.srdata));
     	init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
     	init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
    	init.advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
    	init.advdata.short_name_len     = 4;
    
    	//init.advdata.include_appearance      = false;
    	//init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    	//init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    	//init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
    	init.advdata.p_manuf_specific_data = &manufdata;
    
        manufdata.company_identifier = ACCESS_COMPANY_ID_DARA;
        manufdata.data.size = 6;
    
    	g_stDara.m_uiNodeid = (uint16_t)((*(uint32_t*) &NRF_FICR->DEVICEID[0]) & 0x3FFF);
        mandata[4] = g_stDara.m_uiNodeid;
        mandata[5] = (uint8_t)(g_stDara.m_uiNodeid >> 8);
    
    	manufdata.data.p_data =  mandata;
    
    	init.config.ble_adv_fast_enabled  = true;
    	init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    	init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    
    	init.evt_handler = on_adv_evt;
    
    	err_code = ble_advertising_init(&m_advertising, &init);
    	APP_ERROR_CHECK(err_code);
    
    	ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }
    
    /**@brief Function for starting advertising.
     */
    void advertising_start(bool erase_bonds)
    {
        uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    }
    

Children
No Data
Related