Notify Characteristics Issue


#1

Hi guys, I’m doing several tests with my new BLE Nano v2 board, but I found a problem with reading Notify Characteristics. In my case I have a streaming of values with 100Hz sample rate (every 10ms) from a BLE Device, in particular from Android Smartphone. But, using the BLE_CentralTest Example, I can not obtain the value with 100Hz frequency. I receive 3 values in 1.5ms (very fast) and the fourth value after 123ms (very very slow). In my opinion the problem is in a buffering technique, but i do not known how to solve it because I read the values every time the hvxCallBack function is recalled.
I have already tried to read the values with another BLE device and the frequency is correct.

Have you had similar issue, do you know how to solve it?

Thank you very much guys!


#2

Hi @fgaetani, Those three packet received every 1.5ms is within the same connection interval. Every BLE device support several packet per connection interval. To raise the speed to receive packets between connection interval, you have to decrease the connection interval by calling the update connection parameter API, though I don’t know what the exact name of the API is.

Best regards,
guohui


#3

Ok, thank you for your support. Can you tell me what the default connection interval is? Where can I find this value? But I can change the value in central mode?


#4

I don’t know the default connection interval. But you can call ble.updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) explicitly to set the connection interval after connection being established. Where the ConnectionParams_t is defined as:

/**
     * Structure containing GAP connection parameters. When in peripheral role
     * the connection parameters are suggestions. The choice of the connection
     * parameters is eventually up to the central.
     */
    typedef struct {
        uint16_t minConnectionInterval;        /**< Minimum Connection Interval in 1.25 ms units, see BLE_GAP_CP_LIMITS.*/
        uint16_t maxConnectionInterval;        /**< Maximum Connection Interval in 1.25 ms units, see BLE_GAP_CP_LIMITS.*/
        uint16_t slaveLatency;                 /**< Slave Latency in number of connection events, see BLE_GAP_CP_LIMITS.*/
        uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see BLE_GAP_CP_LIMITS.*/
    } ConnectionParams_t;

More details here:


#5

But I do not understand if I can recall updateConnectionParams function in Central role. This function should not be recalled in Peripheral role?


#6

I tried to update the connection parameter with this instructions:

Gap::ConnectionParams_t connectionParams;
  connectionParams.minConnectionInterval        = 6;
  connectionParams.maxConnectionInterval        = 12;
  connectionParams.slaveLatency                 = 0;
  connectionParams.connectionSupervisionTimeout = 500;
  if (ble.updateConnectionParams(params->handle, &connectionParams) != BLE_ERROR_NONE){
      Serial.println("failed to update connection parameter\r\n");
  }

The frequency is improved, up to about 120Hz. Now it is very good, but how can I improve even more the result? How do you advise me to choose the connection interval values? Thank you very much!


#7

@fgaetani It seams that you have set the connection interval that exceeds the minimal limit. Try setting both the minConnectionInterval and maxConnectionInterval to be 12.


#8

I have tried to set both values at 12, but the result is the same. I would like to understand how choose the values to optimize the connection speed.


#9

Actually, 120Hz (i.e. 8.3ms) should be the extremely minimal connection interval regarding BLE connection. There is barely room to improve the speed. That’s the limitation of the BLE technology.