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主模式如何发送大容量数据?

Other Parts Discussed in Thread: CC2540

Hi, TI' experts:

最近在学习CC2540主模式的开发,目前master和slaver可以正常连接并且可以发送数据,但是数据包的大小仅仅限制在20bytes,我想知道对于大容量的数据(比如128bytes或者256bytes等)该怎么发送呢?我在论坛里看到有朋友说GATT_WriteLongCharValue()函数可以实现大数据的发送,而且该函数会自动分包,然后多次发送。我在我的代码中也调用了这个函数,但是slaver端并没有收到任何数据,我不知道问题出在哪里了?我调用GATT_WriteCharValue()函数来发送数据时,slaver是可以收到数据的。我的代码是以SimpleBLECentral为模板改的。

以下是我代码中发送的部分:希望各位专家们能帮我解答,谢谢!

if(simpleBLEDoWrite) //Do a write
{

      unsigned int dataLength = (unsigned int)sizeof(senddata);      //取得数据包的长度
      uint8 *ptr = senddata;

      gattPrepareWriteReq_t req;

      req.handle = simpleBLECharHdl;
      req.len = dataLength;
      req.offset = 0;
      req.pValue = (uint8 *)osal_mem_alloc(dataLength);  //locate space
      osal_memset(req.pValue, 0, dataLength);  //mem clear
      osal_memcpy(req.pValue, ptr, dataLength);  //memcpy

      status = GATT_WriteLongCharValue(simpleBLEConnHandle, &req, simpleBLETaskId);

}