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

Nrf52832 stopped advertising after disconnect

Hi,

Am using nrf52832 for my BLE project with SDK 15.02. I found sometimes device is not showing after disconnect, I have to reset the device manually to show the MAC ID back.

Am advertising after device disconnect manually and removed sleep function when it goes to idle state. Still, it exists, can someone give solution for this?

Parents Reply Children
  • I have to reset nrf52832 device to advertise back,

    MAC for nrf CA43E77D23DF

    MAC for redmi : 65E0BC5D21C0

    This issue happens in other phones too but not every time.

  • I used ble_app_uart for my project and removed UART for reducing current consumption. Below are init code:
    
    #define APP_ADV_INTERVAL 1600 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
    
    #define APP_ADV_DURATION 18000 /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
    
    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS) /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
    #define SLAVE_LATENCY 0 /**< Slave latency. */
    #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(20000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
    #define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(100) /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
    #define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(500) /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
    #define MAX_CONN_PARAMS_UPDATE_COUNT 7 /**< Number of attempts before giving up the connection parameter negotiation. */
    
    static void gap_params_init(void)
    {
    uint32_t err_code;
    ble_gap_conn_params_t gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;
    
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    
    err_code = sd_ble_gap_device_name_set(&sec_mode,
    (const uint8_t *) DEVICE_NAME,
    strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);
    
    memset(&gap_conn_params, 0, sizeof(gap_conn_params));
    
    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;
    
    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
    APP_ERROR_CHECK(err_code);
    
    // Update security parameters for connection reply
    gst_secparams.bond = SEC_PARAM_BOND;
    gst_secparams.mitm = SEC_PARAM_MITM;
    gst_secparams.io_caps = SEC_PARAM_IO_CAPABILITIES;
    gst_secparams.oob = SEC_PARAM_OOB;
    gst_secparams.min_key_size = SEC_PARAM_MIN_KEY_SIZE;
    gst_secparams.max_key_size = SEC_PARAM_MAX_KEY_SIZE;
    }
    
    static void advertising_init(void)
    {
    uint32_t err_code;
    ble_advertising_init_t init;
    
    memset(&init, 0, sizeof(init));
    
    init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance = false;
    init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
    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.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);
    }
    
    static void conn_params_init(void)
    {
    uint32_t err_code;
    ble_conn_params_init_t cp_init;
    
    memset(&cp_init, 0, sizeof(cp_init));
    
    cp_init.p_conn_params = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail = false;
    // cp_init.evt_handler = on_conn_params_evt;
    cp_init.error_handler = conn_params_error_handler;
    
    cp_init.p_conn_params->min_conn_interval = MIN_CONN_INTERVAL;
    cp_init.p_conn_params->max_conn_interval = MAX_CONN_INTERVAL;
    cp_init.p_conn_params->slave_latency = SLAVE_LATENCY;
    cp_init.p_conn_params->conn_sup_timeout = CONN_SUP_TIMEOUT;
    
    err_code = ble_conn_params_init(&cp_init);
    APP_ERROR_CHECK(err_code);
    }
    
    Reduced tx power level for 10m approx
    
    static void advertising_start(void)
    {
    printf("\r\n Adv start");
    uint32_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, TX_POWER_LEVEL);
    APP_ERROR_CHECK(err_code);
    }

  • May I know what further information you need to reply back for this issue?

  • I can't see where in the sniffer trace where the device with address CA43E77D23DF stops using it's address. 

Related