打印
[其他芯片]

CH573 Peripheral 修改MTU

[复制链接]
4760|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
aoyi|  楼主 | 2021-9-2 15:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
一、环境
使用CH573EVT_V1.4\EVT\EXAM\BLE\Peripheral

二、流程
例如我们要收发 200 字节数据

config.h里面设置 MTU大小 为207 !最后实际设置成功后,MTU=203 ,实际收发数据=203-3=200
#ifndef BLE_BUFF_MAX_LEN
#define BLE_BUFF_MAX_LEN                                                207//27



设置特征值长度,这里 CHAR1用于Write,CHAR4用于Notify
// Length of characteristic in bytes ( Default MTU is 23 )
#define SIMPLEPROFILE_CHAR1_LEN               200
#define SIMPLEPROFILE_CHAR2_LEN               1  
#define SIMPLEPROFILE_CHAR3_LEN               1  
#define SIMPLEPROFILE_CHAR4_LEN               200
#define SIMPLEPROFILE_CHAR5_LEN               5  



最好增加以下每个间隔可以发送的数据包
//BLE_TX_NUM_EVENT                                                        - 单个连接事件最多可以发多少个数据包( 默认:1 )
#ifndef BLE_TX_NUM_EVENT
#define BLE_TX_NUM_EVENT                                                3
#endif


加一下MTU设置成功的打印回调
uint16 Peripheral_ProcessEvent( uint8 task_id, uint16 events )
{

//  VOID task_id; // TMOS required parameter that isn't used in this function
  if ( events & SYS_EVENT_MSG ){
    uint8 *pMsg;

    if ( (pMsg = tmos_msg_receive( Peripheral_TaskID )) != NULL ){
      Peripheral_ProcessTMOSMsg( (tmos_event_hdr_t *)pMsg );
      // Release the TMOS message
      tmos_msg_deallocate( pMsg );
    }
    // return unprocessed events
    return (events ^ SYS_EVENT_MSG);
  }


----------------------------------------------
/*********************************************************************
* @fn      Peripheral_ProcessTMOSMsg
*
* @brief   Process an incoming task message.
*
* @param   pMsg - message to process
*
* @return  none
*/
static void Peripheral_ProcessTMOSMsg( tmos_event_hdr_t *pMsg )
{
  switch ( pMsg->event ){

    case GATT_MSG_EVENT:
    {
      centralProcessGATTMsg( (gattMsgEvent_t *) pMsg );
    }
    break;

    default:
      break;
  }
}




注意点,notify数据最好不超100字节,否则很容易发送失败。。。主设备Write设备倒是可以200字节


使用特权

评论回复
沙发
redone| | 2021-9-11 11:23 | 只看该作者
额~没看懂的走过

使用特权

评论回复
板凳
一刀一级| | 2021-9-13 17:01 | 只看该作者
学习学习

使用特权

评论回复
地板
guijial511| | 2021-9-13 20:24 | 只看该作者
什么不能超过200个字节?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

99

主题

3301

帖子

3

粉丝