找回密码
 立即注册

使用微信账号登录

只需一步,快速开始

查看: 2499|回复: 1

[CSR8系列] CSR8670底层是如何实现多个字节数据的接受

[复制链接]
连续签到天数:4天
签到总天数:652天
签到总奖励:8180金币
发表于 2018-12-3 11:27:22 | 显示全部楼层 |阅读模式

马上注册,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册  

×
最近用CSR8670的BLE进行数据传输,移植的使用的HRS的Srever库。HRS里的数据接受好像是2个字节长度的,如果我现在需要通过手机向这个服务发送一个长达20个字节的数据,CSR8670这端是如何实现的呢,请教一下
这段代码是处理手机端发过来的数据的

  1. static void hrServerClientConfigAccess(GHRS_T *hr_sensor, const GATT_MANAGER_SERVER_ACCESS_IND_T *access_ind)
  2. {
  3.     if (access_ind->flags & ATT_ACCESS_READ)
  4.     {
  5.         /* On a Read, ask the app for current client config value */
  6.         MAKE_HR_SERVER_MESSAGE(GATT_HR_SERVER_READ_CLIENT_CONFIG_IND);
  7.         message->hr_sensor = hr_sensor;     /* Pass the instance which can be returned in the response */
  8.         message->cid = access_ind->cid;                 /* Pass the CID so the client can be identified */
  9.         MessageSend(hr_sensor->app_task, GATT_HR_SERVER_READ_CLIENT_CONFIG_IND, message);
  10.     }
  11.     else if (access_ind->flags & ATT_ACCESS_WRITE)
  12.     {
  13.         if (access_ind->size_value == GATT_CLIENT_CONFIG_NUM_OCTETS)
  14.         {
  15.             /* On a Write, send new client config value to the app */
  16.             MAKE_HR_SERVER_MESSAGE(GATT_HR_SERVER_WRITE_CLIENT_CONFIG_IND);
  17.             message->hr_sensor = hr_sensor;
  18.             message->cid = access_ind->cid;
  19.             <font color="Red">message->config_value = (access_ind->value[0] & 0xFF) | ((access_ind->value[1] << 8) & 0xFF00);</font>
  20.             MessageSend(hr_sensor->app_task, GATT_HR_SERVER_WRITE_CLIENT_CONFIG_IND, message);
  21.             /* Library response to the access request */
  22.             sendHrServerAccessRsp(&hr_sensor->lib_task, access_ind->cid, HANDLE_HEART_RATE_MEASUREMENT_CLIENT_CONFIG, gatt_status_success, 0, NULL);
  23.         }
  24.         else
  25.         {
  26.             sendHrServerAccessErrorRsp(hr_sensor, access_ind, gatt_status_invalid_length);
  27.         }
  28.     }
  29.     else
  30.     {
  31.         /* Reject access requests that aren't read/write, which shouldn't happen. */
  32.         sendHrServerAccessErrorRsp(hr_sensor, access_ind, gatt_status_request_not_supported);
  33.     }
  34. }
复制代码
access_ind变量是GATT_MANAGER_SERVER_ACCESS_IND_T类型的
  1. typedef GATT_ACCESS_IND_T GATT_MANAGER_SERVER_ACCESS_IND_T;
复制代码
GATT_ACCESS_IND_T这个类型的申明是uint8                   value[1],这里value只有一个成员的空间,但是在处理的时候确有两个成员,见前面代码标红处,请问是不收到20个字节的数据也是这样处理
  1. typedef struct
  2. {
  3.     /*! Connection identifier of remote device. */
  4.     uint16                  cid;
  5.     /*! Handle being accessed. */
  6.     uint16                  handle;
  7.     /*! Flags - uses ATT_ACCESS range. */
  8.     uint16                  flags;
  9.     /*! The offset of the first octet to be accessed. */
  10.     uint16                  offset;
  11.     /*! Length of the value. */
  12.     uint16                  size_value;
  13.     /*! Value data. */
  14.     uint8                   value[1];
  15. } GATT_ACCESS_IND_T;
复制代码


楼主热帖
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
连续签到天数:1天
签到总天数:831天
签到总奖励:24012金币
发表于 2018-12-3 22:51:35 | 显示全部楼层
access_ind->value[0] ,,,这个value是指针来的,这里可以传很多数据,不只两个。
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册  

本版积分规则

小黑屋|手机版|我爱蓝牙网 - 52Bluetooth

GMT+8, 2024-4-30 21:14 , Processed in 0.332731 second(s), 16 queries , Gzip On, MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表