CC2640R2 每一包传输数据大小?
Hi:
我在simple_profile协议基础上修改添加一个自定义的特征值,其特征值的大小是140,属性是GATT_PROP_INDICATE, 定义完了之后,在应用程序中,使用该特征值,最大可传输的数据长度不到60字节,和我定义的140不相符。
程序设计如下:
simple_profile.c 修改如下:
// Characteristic 5 Value
static uint8 simpleProfileChar5[140];
// Simple Profile Characteristic 5 Properties
static uint8 simpleProfileChar5Props = GATT_PROP_INDICATE;
static gattCharCfg_t *simpleProfileChar5Config;
// Simple Profile Characteristic 5 User Description
static uint8 simpleProfileChar5UserDesp[17] = "Data-Out.";
static gattAttribute_t simpleProfileAttrTbl[] =
{
// Characteristic 5 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar5Props
},
// Characteristic Value 5
{
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
GATT_PERMIT_AUTHEN_READ,
0,
simpleProfileChar5
},
// Characteristic 5 configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)&simpleProfileChar5Config
},
// Characteristic 5 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar5UserDesp
},
}
/*----------------------------------------------------------------------------*
* NAME
* ClifeProfile_SendInd
* DESCRIPTION
* PARAMETERS
*
* RETURNS
*---------------------------------------------------------------------------*/
bStatus_t ClifeProfile_SendInd( uint16 connHandle, attHandleValueInd_t *pNoti, uint8 taskId )
{
uint16 value = GATTServApp_ReadCharCfg( connHandle, simpleProfileChar5Config );
// If indications enabled
if( value & GATT_CLIENT_CFG_INDICATE )
{
// Set the handle
pNoti->handle = simpleProfileAttrTbl[ATTRTBL_CHAR5_CCC_IDX - 1].handle;
// PrintStr("\r\nclife profile\r\rn");
// Send the Indication
return GATT_Indication( connHandle, pNoti, FALSE, taskId );
}
return bleIncorrectMode;
}
simple_peripheral.c 修改如下:
static void SimplePeripheral_init(void)
{
// Set default values for Data Length Extension
// This should be included only if Extended Data Length Feature is enabled
// in build_config.opt in stack project.
{
//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 BLE5-Stack User's Guide for information on using this command:
// http://software-dl.ti.com/lprf/ble5stack-docs-latest/html/ble-stack/data-length-extensions.html
HCI_LE_WriteSuggestedDefaultDataLenCmd(APP_SUGGESTED_PDU_SIZE, APP_SUGGESTED_TX_TIME);
}
}
是一次传完140字节,但是分成数包发送,还是只能传输不到60字节?
如果是前者那就没问题,因为每包数据长度由PDU决定,而且PDU数值是由通信双方决定的。如果接收方PDU比较小,会根据小的一方来传输
Hi Viki:
一次性传输140个字节, 但是发送不成功,而且程序会跑飞,只能一次发送不到60个字节,手机使用的是带有蓝牙5.0功能, 使用相同的手机,测试别家的蓝牙5.0 IC,是可以传输140个字节的。
还是要看PDU的设置,具体可参考这边: http://blog.csdn.net/zaoyuzang6112/article/details/76570683