分析:
-----------------------------------------------------------------------------simple_peripheral.c
//Set default values for Data Length Extension
{
//Set initial values to maximum, RX is set to max. by default(251 octets, 2120us)
#define APP_SUGGESTED_PDU_SIZE 251 //default is 27 octets(TX)
#define APP_SUGGESTED_TX_TIME 2120 //default is 328us(TX)
//This API is documented in hci.h
//See the LE Data Length Extension section in the BLE-Stack User's Guide for information on using this command:
//http://software-dl.ti.com/lprf/sdg-latest/html/cc2640/index.html
//HCI_LE_WriteSuggestedDefaultDataLenCmd(APP_SUGGESTED_PDU_SIZE, APP_SUGGESTED_TX_TIME);
}
-----------------------------------------------------------------------------ble_user_config.c
// Maximum number of BLE HCI PDUs. If the maximum number connections (above)
// is set to 0 then this number should also be set to 0.
#ifndef MAX_NUM_PDU
#define MAX_NUM_PDU 5
#endif
// Maximum size in bytes of the BLE HCI PDU. Valid range: 27 to 255
// The maximum ATT_MTU is MAX_PDU_SIZE - 4.
#ifndef MAX_PDU_SIZE
#if defined(BLE_V42_FEATURES) && (BLE_V42_FEATURES & SECURE_CONNS_CFG)
#define MAX_PDU_SIZE 69
#else
#define MAX_PDU_SIZE 27
#endif //(BLE_V42_FEATURES & SECURE_CONNS_CFG)
#endif
注意:蓝色为例子默认执行语句; MAX_PDU_SIZE≤251
-----------------------------------------------------------------------------ble_user_config.c
更改与测试:
1.调整APP_SUGGESTED_PDU_SIZE 宏值,打开 HCI_LE_WriteSuggestedDefaultDataLenCmd(APP_SUGGESTED_PDU_SIZE, APP_SUGGESTED_TX_TIME);
2.Preprocessor中定义宏“MAX_PDU_SIZE=251“。值自定义,必须大于等于APP_SUGGESTED_PDU_SIZE 设定的值。
3,测试代码
static void SimpleBLEPeripheral_performPeriodicTask(void) // event= SBP_PERIODIC_EVT period= SBP_PERIODIC_EVT_PERIOD
{
bStatus_t ret;
static uint8 Txbuf[300]= {0};
static uint8 TxLen = 183; // must <= 62 ATT_MTU-3=attribute Value (65-3=62) APP_SUGGESTED_PDU_SIZE
uint8 i = 0;
for(i = 0; i < 0xFF ;i++){
Txbuf[i] = i;
}
ret = CoolBan_SendNotiInd_Char4( Txbuf,TxLen);
if(ret == SUCCESS){
}else{
Display_printf(dispHandle, 5, 0, "send error\n");
}
}