Changing the connection intervals


#1

Hi,

I would like to change the BLE connection interval on my Nano v2.0 using Arduino IDE.

As i understand i should use the following functions
(code from BLE.h)

/**
     * Set the GAP peripheral's preferred connection parameters. These are the
     * defaults that the peripheral would like to have in a connection. The
     * choice of the connection parameters is eventually up to the central.
     *
     * @param[in] params
     *               The structure containing the desired parameters.
     *
     * @deprecated You should use the parallel API from Gap directly, refer to
     *             Gap::setPreferredConnectionParams(). A former call to
     *             ble.setPreferredConnectionParams() should be replaced with
     *             ble.gap().setPreferredConnectionParams().
     */    
ble_error_t setPreferredConnectionParams(const Gap::ConnectionParams_t *params) {
            return gap().setPreferredConnectionParams(params);
        }

and

        /**
     * Update the value of a characteristic on the local GattServer.
     *
     * @param[in] attributeHandle
     *              Handle for the value attribute of the characteristic.
     * @param[in] value
     *              A pointer to a buffer holding the new value.
     * @param[in] size
     *              Size of the new value (in bytes).
     * @param[in] localOnly
     *              Should this update be kept on the local
     *              GattServer regardless of the state of the
     *              notify/indicate flag in the CCCD for this
     *              characteristic? If set to true, no notification
     *              or indication is generated.
     *
     * @return BLE_ERROR_NONE if we have successfully set the value of the attribute.
     *
     * @deprecated You should use the parallel API from GattServer directly, refer to
     *             GattServer::write(GattAttribute::Handle_t,const uint8_t,uint16_t,bool).
     *             A former call to ble.updateCharacteristicValue() should be replaced with
     *             ble.gattServer().write().
     */
    ble_error_t updateCharacteristicValue(GattAttribute::Handle_t  attributeHandle,
                                          const uint8_t           *value,
                                          uint16_t                 size,
                                          bool                     localOnly = false) {
        return gattServer().write(attributeHandle, value, size, localOnly);
    }

but if we look further, those are seemingly not implemented yet

(code from Gap.h)

/**
     * Set the GAP peripheral preferred connection parameters. These are the
     * defaults that the peripheral would like to have in a connection. The
     * choice of the connection parameters is eventually up to the central.
     *
     * @param[in] params
     *               The structure containing the desired parameters.
     *
     * @return BLE_ERROR_NONE if the preferred connection params were set
     *         correctly.
     */
    virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) {
        /* Avoid compiler warnings about unused variables. */
        (void)params;

        return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
    }

and

/**
     * Update connection parameters. In the central role this will initiate a
     * Link Layer connection parameter update procedure. In the peripheral role,
     * this will send the corresponding L2CAP request and wait for the central
     * to perform the procedure.
     *
     * @param[in] handle
     *              Connection Handle.
     * @param[in] params
     *              Pointer to desired connection parameters. If NULL is provided on a peripheral role,
     *              the parameters in the PPCP characteristic of the GAP service will be used instead.
     *
     * @return BLE_ERROR_NONE if the connection parameters were updated correctly.
     */
    virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) {
        /* avoid compiler warnings about unused variables */
        (void)handle;
        (void)params;

        return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
    }

My main question is where can i modify the default values or what other option do i have to set the connection interval.


#2

Hi,

I found that these are “virtual” implementation and the real implementation should be in

Try to put some printout there to test it.


#3

Hi,

First i want to thank you @cheong, for your fast reply.

So i got my problem fixed up, it was a noobish mistake.

I tried to extend the BLE_Serial from BLE_Examples and the
timeout.attach_us(m_uart_rx_handle, 100000);
function bottlenecked the communication with it’s second input value, lowering that along with setting minConnectionInterval and maxConnectionInterval, / calling it directly solved my problem.


#4

@nova how do you changed your Connection interval? I always get an BLE_ERROR_PARAM_OUT_OF_RANGE error, but my interval is in the Limits between 7.5 ms and 4s. I`m using ble.gap().setPreferredConnectionParams()