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

Resume BLE communication after a timeout

HI,

My application is based on on your example ble_perepherical/ble_app_uart.

I realised few modification.

Now, after a BLE timeout, the circuit doesn't sleep anymore.

So during the initialisations, I have this instructions.

    ble_StackInit();
    ble_GapParamsInit();
    ble_GattInit();
    Ble_ServicesInit();
    ble_AdvertisingInit();
    ble_ConnParamsInit();

Following initialization the communication woks. I disconnect my device. After the timeout. This fonction is called.

if I have a measurement in progress (GetMeasureStart()) I don't want to sleep

void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
    uint32_t err_code;

    switch (ble_adv_evt)
    {
    case BLE_ADV_EVT_FAST:
        err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
        APP_ERROR_CHECK(err_code);
        break;
    case BLE_ADV_EVT_IDLE:
        if(Environnement_GetMeasureStart() == false)
        {
            sleep_mode_enter();
        }
        else
        {
            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        }
        break;
    default:
        break;
    }
}

To restart the BLE I use an GPIO interruption,

void AccInteruptHandler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){
    uint8_t i;
    
    if (m_advertising.adv_mode_current == BLE_ADV_MODE_IDLE){


        ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
        bsp_indication_set(BSP_INDICATE_ADVERTISING);
    }
}

It is probably here that I have problems. But I do not know how to restart a correct BLE communication.

Thanks by advance, If you have some idea.

Best Regards

Guillaume

Parents Reply Children
No Data
Related