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

Why 250 ms interval between subsequent reads?

I observe strange behavior while reading value for long characteristics.

I have characteristic 100 bytes long (read only). In GATT client I must read value with subsequent reads (sd_ble_gattc_read with proper offsets). Everything works fine with one exception. Subsequent packets are received at intervals of 250 ms. Why? Where is this "magic interval" set? With my characteristic 100 byte long I need spend 1 second to get full value (and keep connection!).

  • well what are your connection parameters set to for that connection? You get to choose the max and min intervals when you make the connection, what did you choose? If you chose 250ms then that's why you're getting 250ms

  • I set on both side the same connection parameters (with sd_ble_gap_ppcp_set):

    min:30,  
    max:100,  
    latency:0,  
    timeout:400
    

    and set on both side the same behavior strategy to BLE_CONN_BW_HIGH (6 Tx/Rx buffers in Central and 7 Tx on Peripheral) by this snippet:

    //-----------------
    ...
        if(role == 2)
        	conn_bw.role = BLE_GAP_ROLE_CENTRAL;
        else
        	conn_bw.role = BLE_GAP_ROLE_PERIPH;
        conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_HIGH;
        conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_HIGH;
        ble_opt.common_opt.conn_bw = conn_bw;
        sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &ble_opt)
    ...
    //-----------------
    

    I find only one place in SDK documentation where 250 ms interval is analysed. (SysTick driver settings, 24-bit counter on 64MHz clock overflows every ~250 ms).

  • It would be very helpful if you could upload a sniffer trace of the transaction.

  • Ok. Sender log:

      0:06:151 Setting BLE parameters err_code:0
      0:06:151 PA LNA setting: 0
      0:06:151 Prefered params(st:0): min:30 max:100 latency:0 timeout:400
      0:06:152 UART-Init bucket 1 chunks, 15 chars in queue. 0 in buffer 
      0:19:233 Connect: AdrType:1 Addr:49436555FAF8 ownAddr:B272939FDAD5
      0:19:233 Connection Callback (7 Tx buffers available)
      0:20:484 BLE-data (off=0, len=14) bodyLen:5
      0:20:484 FRAME sNode:1 seq:0 dNode:0 fType:1 bLen:5 bType:0
      0:20:484 FRAME body: 'info;'
      0:20:484 BLE-packet completed (ftype:1) btype:0, len:5
      0:20:485 BLE-Request 'info'
      0:20:486 BLE-Init bucket 1 chunks, 462 chars in queue. 0 in buffer 
      0:20:487 FRAME sNode:2 seq:0 dNode:0 fType:1 bLen:119 bType:0
      0:20:487 FRAME body: '?=========== System statistics ========='
      0:20:488 BLE-set response (2) 128 length. Status:0
      0:22:359 BLE-disconnection reason: 0x13
    
  • Receiver log. First half (comment limits:)

      0:36:428 UART-Request 'ble.send'
      0:36:429 Setting BLE parameters err_code:0
      0:36:429 PA LNA setting: 0
      0:36:429 Prefered params(st:0): min:30 max:100 latency:0 timeout:400
      0:36:430 UART-Init bucket 1 chunks, 5 chars in queue. 0 in buffer 
      0:36:966 Connection for device 0 status: 0  (state : 0)
      0:37:968 Connection Callback (6 Tx buffers available)
      0:39:095 Terminated SD for handle 0.
      0:39:095 Send command 'info;' for connection 0
      0:39:595 BLE-data (off=0, len=22) bodyLen:119
      0:39:595 FRAME sNode:2 seq:0 dNode:0 fType:1 bLen:119 bType:0
      0:39:595 FRAME body: '?=========== ?'
      0:39:595 Incomplete packet.Fragment: 22 != (119 + 9)
      0:39:596 Wait for bucket (off=22) st=0x0
      0:39:845 BLE-data (off=22, len=22) bodyLen:119
      0:39:845 Incomplete packet.Fragment: 44 != (119 + 9)
    
Related