CC2640R2F MTU大小更改

分析:

-----------------------------------------------------------------------------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");
  }
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值