Arm Mbed OS support forum

Example on changing BLE connection parameters

Hi
I am having some trouble changing BLE connection parameters (mainly due to the connection handle).
Is there any working example that I can refer to, which explains how to change the connection parameters or access the connectionHandle? (I am using nrf52 DK)

My code is the following: https://os.mbed.com/users/mreiscarneiro/code/BLE_HeartRate_copy_tttest/ if anyone can help me by looking at it…

thanks for the help.

What problems are you facing?
I was evaluating mbed OS5’s BLE and wrote the code below to request connection parameter updates. Not sure if this works for OS6. Soon after I wrote this, I switched to Nordic’s SDK and haven’t touched mbed’s BLE API since.

By the way, you can only “request” parameter updates. Central can ignore your requests.

// ...

#define GAP_CON_MIN_INTERVAL 7.5
#define GAP_CON_MAX_INTERVAL 15
#define GAP_CON_SLAVE_LATENCY 0

static Gap::ConnectionParams_t fast; // change parameters to increase throughput

void connectionCallback(const Gap::ConnectionCallbackParams_t *params) {
    BLE::Instance().gap().updateConnectionParams(params->handle, &fast);
}

void bleInitComplete(BLE::InitializationCompleteCallbackContext *params) {
    BLE& ble = params->ble;

    ble.gap().onConnection(connectionCallback);

    ble.gap().getPreferredConnectionParams(&fast);
    fast.minConnectionInterval = GAP_CON_MIN_INTERVAL;
    fast.maxConnectionInterval = GAP_CON_MAX_INTERVAL;
    fast.slaveLatency = GAP_CON_SLAVE_LATENCY;
    ble.gap().setPreferredConnectionParams(&fast);

    // ...
}

int main(void) {
    BLE &ble = BLE::Instance();
    ble.init(bleInitComplete);

    // ...
}