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.

CC2540蓝牙协议栈V1.4.1比V1.3数据吐出量小很多??



最近试了一下V1.4.1.43908b协议栈,发现数据最大吞吐量仅600字节/s,比V1.3协议栈差太多了。

不知道是我的测试方法不对还是V1.4.1协议栈本身就是这样的。

#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL (6) 
#define DEFAULT_DESIRED_SLAVE_LATENCY 1

unsigned long g_send_dat_cnt=1;
void send_test()
{
uint16 len;
// uint8 i;
bStatus_t status;

g_nData.pValue = (uint8 *)GATT_bm_alloc( 0, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len );
//for(i=1;i<20;i++) g_noti.pValue[i] = 0xaa;
g_nData.pValue[0]=g_send_dat_cnt&0xff;
g_nData.pValue[1]=(g_send_dat_cnt>>8)&0xff;
g_nData.pValue[2]=(g_send_dat_cnt>>16)&0xff;
g_nData.pValue[3]=(g_send_dat_cnt>>24)&0xff;
g_send_dat_cnt++;

status=GATT_Notification(0, &g_nData, FALSE);

if ( status != SUCCESS ) { GATT_bm_free( (gattMsg_t *)&g_nData, ATT_HANDLE_VALUE_NOTI ); }
}

//---------------------------

if ( events & SBP_PERIODIC_EVT )
{
osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, 5 );
send_test();
// send_test();
//send_test();
// send_test();
// osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SEND_PACK_PERIOD ); // Restart timer

//-------------------------------------------------------------------------

return (events ^ SBP_PERIODIC_EVT);//levivi临时

  • Liao Wei,

    应该是一样的。

    你有没有把试过把DEFAULT_ENABLE_UPDATE_REQUEST 设置成FALSE?

  • 1. 你是基于官方如下例子改的吗?

    http://processors.wiki.ti.com/index.php/SerialBLEbridge_V_1.4.1

    2. 如果你就是定时然后发,那你的定时任务又是5ms,不就是5ms才发一个notificaiton,20个字节(一个连接事件是可以发多个notificaiton的,上面例子就是一个循环),还得看你的连接间隔是多少,那数据量肯定小。

    最大throughput的就是我上面Link的例子,你可以去掉串口收数的部分。

  • 感谢你的回复

    1. 是基于这个例程改的,

    C:\Texas Instruments\BLE-CC254x-1.4.1.43908b\Projects\ble\SimpleBLEPeripheral

    我试试你说的那个串口例程

    2. 多种情况都试过,始终无法提高吞吐量

    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6
    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL (6) //
    #define DEFAULT_DESIRED_SLAVE_LATENCY 0

    #define DEFAULT_ENABLE_UPDATE_REQUEST         0//TRUE

    osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, 20 ); // 20ms 80字节,理论4000/s,但是只有600/S
    send_test();
    send_test();
    send_test();
    send_test();

  • 你那个发送程序我觉得有些问题,你参考下我说的那个例子的写法。

    max throughput 不是我说出来的,是R&D做出来的。

    static uint8 sendData( uint16 diff )
    {
    //can send max 4 packets per connection interval
    uint8 packets_sent = 0;
    //ensure queue of notification is successful
    bool send_error = FALSE;
    //return value to update tail and send ack to msp
    uint8 bytes_sent = 0;

    attHandleValueNoti_t noti;
    uint16 len;
    //dummy handle
    noti.handle = 0x2E;

    //counter
    uint8 i;

    while ((packets_sent < 4) && (diff >= 20) && (send_error == FALSE))
    {
    //send 20 bytes
    noti.len = 20;
    noti.pValue = (uint8 *)GATT_bm_alloc( 0, ATT_HANDLE_VALUE_NOTI,
    GATT_MAX_MTU, &len );
    if ( noti.pValue != NULL )
    {
    for (i = 0; i < 20; i++)
    {
    noti.pValue[i] = serialBuffer[circular_add(buffer_tail , bytes_sent+i)];
    }
    //connection handle currently hardcoded
    if (!(GATT_Notification(0, &noti, FALSE))) //if sucessful
    {
    bytes_sent += 20;
    diff -= 20;
    packets_sent++;
    }
    else
    {
    send_error = TRUE;
    GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
    }
    }
    }
    //send remaining bytes
    if ((packets_sent < 4) && (diff > 0) && (send_error == FALSE))
    {
    noti.len = diff;
    noti.pValue = (uint8 *)GATT_bm_alloc( 0, ATT_HANDLE_VALUE_NOTI,
    GATT_MAX_MTU, &len );
    if ( noti.pValue != NULL )
    {
    for (i = 0; i < diff; i++)
    {
    noti.pValue[i] = serialBuffer[circular_add(buffer_tail, bytes_sent + i)];
    }
    //connection handle currently hardcoded
    if (!(GATT_Notification(0, &noti, FALSE))) //if sucessful
    {
    bytes_sent += i;
    diff -= i;//amount of data sent
    }
    else
    {
    send_error = TRUE;
    GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
    }
    }
    }
    return bytes_sent;
    }

  • 我刚才试了,用BLE_Bridge我的硬件最大可以做到3700bytes/s。再加大就会丢包了。

  • 你这个统计方法怎么搞的,可以分享下哦:)

    1. 把默认的最小连接间隔进一步再调小一点,比如从8调到6。

    2. 用2640吧,

  • PC端写了一个小程序,计算总共收到的数据个数,耗时,错误序号(我的前4个字节是+1计数的)

    //----------显示出错信息&采样率---------------------------

    pU32Dat=(unsigned int*)pdata;
    cur_dat=pU32Dat[0];

    if(time_start==0 )
    {
    time_start = GetTickCount();

    last_dat=cur_dat-1;

    m_datpack_cnt=0;
    DataPakCnt=0;
    start_cnt=0;
    }

    if((cur_dat-last_dat) != 1) err_cnt++;
    last_dat=cur_dat;

    DataPakCnt++;

    time_elapse = (GetTickCount()-time_start);
    if(time_elapse==0) time_elapse=1;
    str.Format("total=%u, fre=%d byte/s, pak_err=%d ",DataPakCnt*20,DataPakCnt*20*1000/time_elapse,err_cnt);
    dc.TextOut(55,120,str);

  • 刚才试了一下,下面的参数设置对于我的硬件似乎是最优的,可以做到4800bytes/s.

    #define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6

    #define DEFAULT_DESIRED_MAX_CONN_INTERVAL 9

    #define DEFAULT_DESIRED_SLAVE_LATENCY         0

    osal_start_timerEx( BLE_Bridge_TaskID, SBP_SEND_EVT, 8 );
    send_test();
    send_test();
    //send_test();
    //send_test();
    return (events ^ SBP_SEND_EVT);

  • 找到原因了,先前那个不行是INT_HEAP_LEN被我改得太小造成的。