[轉]Nordic Sending multiple packets at every interrupt interval

Create a function like this:

轉自
https://devzone.nordicsemi.com/f/nordic-q-a/53909/sending-multiple-packets-at-every-interrupt-interval

void conn_evt_len_ext_set(void)
{
    ret_code_t err_code;
    ble_opt_t  opt;

    memset(&opt, 0x00, sizeof(opt));
    opt.common_opt.conn_evt_ext.enable = 1;

    err_code = sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt);
    APP_ERROR_CHECK(err_code);
}

and call it after ble_stack_init(), snippet:

int main(void)
{
    bool erase_bonds;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    conn_evt_len_ext_set();
    gap_params_init();

the whole connection interval can be used to send packets if needed. But it’s fine to set it higher also. Connection intervals are ultimately set by the BLE central. For a connection with 1 peripheral link, I usually set NRF_SDH_BLE_GAP_EVENT_LENGTH to 320 (400ms connection interval).

發佈留言