This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Missing bytes in subsequent transfer.

Other Parts Discussed in Thread: CC2540

Hi all,

I have modified program in SimpleBLEProject. I am writing 20bytes data to characteristic4 and using counter to check if transmitted data is received in order at the central device and also if there is any missing bytes. Here is a my code for sending 20 bytes. send_File() is called every 100ms using timer.

static uint16 counter=0;  //globally declared and initialised

static void send_File(void )
{
    uint8 burstData[20] = {0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
    burstData[0] = (counter & 0xFF00)>>8;    //MSB of count
    burstData[1] = (counter & 0xFF);               //LSB of count
    counter++;
    attHandleValueNoti_t nData;
    nData.len = 20;
    nData.handle = 20;
    osal_memcpy( &nData.pValue, &burstData, 20 );
    SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4,SIMPLEPROFILE_CHAR4_LEN , &nData.pValue );
    if(counter >125)
    {
      counter = 0;
    }
}

First 2 bytes(bytes 0 and 1 of burstData[ ]) denotes the count value of the packet being transmitted. Next 18bytes are constant value from 1-18.

I have attached sniffer log for this. Please look into the packets starting from packet no 1506 where peripheral starts counting and sending 20 bytes. As it can be seen in sniffer log for count value starting from{ 0x00(MSB) & 0x00(LSB)} up to count {0x00(MSB) & 0x36(LSB)}, packets are getting transmitted correctly and count is increasing but after that count is not increasing in order. Later, for each 3 counts, count is increamented in order and then count is increamented by 8. this process repeats. Can anyone please confirm if there is problem in processing counter variable or it is due to failure in sending 8 consecutive bytes at constant interval(after each 3 bytes sent).

i am not using "counter" variable for any other process. I have even tried changing variable name.

Every time i reset peripheral, correct consecutive count increment changes.

If anyone can suggest me some other idea to test if there is loss in packet will be highly appreciated. count1.psd

Thanks

  • I think you timing is not 100ms. It seems to get much faster. Look at pack 1871 and 1873. The count goes from 0x20 to 0x21 in 2623us (2.6ms). Maybe the count becomes too fast on count 0x36.

    If data changes faster than the connection interval, the slave can not update the master in time. 

    It looks like your peripheral is counting faster then the packets are being shared. The master and slave share packets during a connection event. The period of a connection event is the connection interval. The master and the slave agree to exchange packets every connection interval. Multiple packets can be sent during each connection event. it looks like your slave and master send 3 packets back and forth every connection event, and your connection interval is 1 second.

    You should slow the counter down to 1 second, or speed your connection interval up. The connection interval cannot be faster than 20ms (I'm not 100% sure on this limit, check the documentation)

  • Hello,

    To follow on to Peter's suggestion, I recommend checking the return code to GATTServApp_ProcessCharCfg(). If you are sending too many packets too quickly, you'll see a non-success error code.

    Since you are using Notifications, you'll need to manage the flow control in your app, or switch to Indications or Reads.

    Best wishes
  • Hi Peter,
    Thanks for your valuable suggestion.
    I have set timer for calling send_File() every 100ms only. Don't know how this interval gets changed during the process.
    #define FILE_SENDING_INTERVAL 100
    #define SBP_SEND_FILE_EVT 0x0004
    if ( events & SBP_SEND_FILE_EVT )
    {
    send_File();
    osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_SEND_FILE_EVT, FILE_SENDING_INTERVAL );
    return (events ^ SBP_SEND_FILE_EVT);
    }

    Actually I need to read from flash through SPI and send around 1Kbytes in as less time as it can and hence i will try to reduce and adjust the connection interval to serve my purpose. I will look into software developer's guide for adjusting connection timing. I have gone through processors.wiki.ti.com/.../CC2540_Data_Throughput which tells to use connection interval of 10ms.
    "CC2540 Data Throughput
    This is example modification of CC2540 SimpleBLEPeripheral application to measure user data throughput. Initial testing shows we can reach 5.9K bytes per second. This is using a 10ms connection interval and 20 user data bytes sent in GATT notifications. 4 notifications are sent every 7ms, based on an OSAL timer. When sending the notifications, a check is made to see if a buffer is available. In all, 1000 notifications are sent. This is 20K bytes, which are sent over 3.35 seconds."

    I need to look in detail how they are able to send data at faster rate(5.9kbyte/sec).
    I will look into JXS suggestion also to verify the actual cause.
    Thanks again.
  • Hi JXS,
    Thanks for your reply,
    First I will look into how timer value for calling send_FIle() changes although i have set to 100ms. As you said i am trying to send too many packets too quickly then how TI has mentioned to send 80bytes every 7ms. processors.wiki.ti.com/.../CC2540_Data_Throughput. It may be that by "too quickly" you may mean to say 2.6ms interval is too quick to send packets as Peter has explained.

    Can you please refer me document other than software developers guide in which i can get in detail about flow control and other parameters for your suggestion about- "Since you are using Notifications, you'll need to manage the flow control in your app, or switch to Indications or Reads."? I will try to find solution for the same in software developers guide.
  • Hi,
    I had tried to check if GATTServApp_ProcessCharCfg() returns failure, i had revised with following lines in GATTServApp_ProcessCharCfg() just before return statement and placed breakpoint in line" b=0;". I found that breakpoint is hit at this line which means that its failure in transmitting the bytes.
    uint8 b=0;
    if(status != SUCCESS)
    {
    b = 0;
    }

    I had even reduced DEFAULT_DESIRED_MIN_CONN_INTERVAL = 12(15ms) then also same count was missing and following same pattern as the original issue.
    Can you please suggest some other solution to it?
    thanks

  • Hi all,

    Can anyone please clarify me what does " automatic parameter update request is enabled" refers to in following definitions?

    How can i check if this automatic parameter is enabled or not? Does it refer to notification enabled or not for different characteristic used?

    // Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled

    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL     80

    // Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled

    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL     800

    I want to confirm if the above values are set in my application or not.

  • Hi Kumar,

    It is one of the Gap Role parameter. You can configure is by setting using "GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enableUpdate );" function call. If this is enabled slave's connection parameters update is enabled.

    Thanks,

    Dhaval

  • Ya. i got it. its defined in SimpleBLEPeripheral_Init(). Thanks for your clarification.
  • Hi Peter,
    many many thanks for your suggestions and explanation about connection interval. Before i was using default values for DEFAULT_DESIRED_MIN_CONN_INTERVAL=80(100ms) and DEFAULT_DESIRED_MAX_CONN_INTERVAL=800(1sec) and since i was trying to send 20bytes every 100msec which may be less than actual connection interval assigned by BLE central device and hence data was missing. Now i have reduced these to 8(10msec) and 12(15msec) respectively. Now data packets are not missing except some 20 bytes are replicated or missing(counts once or two in 1min data transfer).
    Based on the firmware given in the link processors.wiki.ti.com/.../CC2540_Data_Throughput i had revised my code as stated above and this solved my problem.

    Only concern by using these low connection interval would be extra power consumption which i can adjust by changing the max and min connection interval during the process based on requirement as i don't need to use this low connection interval all the time and only need low connection interval while sending file.
  • The v1.4.1 stack only allows slaves to send one connection update request through the GAPRole profile. There might be an HCI function that can change the interval multiple time during a connection...

    You can use slave latency to reduce power consumption. Set it to the max number possible (4 I think?). This setting allows your slave to skip connection events when there is no new data to send.