连续签到天数:1天 | 签到总天数:676天 | 签到总奖励:8354金币 |
|
马上注册,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册 
×
最近用CSR8670的BLE进行数据传输,移植的使用的HRS的Srever库。HRS里的数据接受好像是2个字节长度的,如果我现在需要通过手机向这个服务发送一个长达20个字节的数据,CSR8670这端是如何实现的呢,请教一下
这段代码是处理手机端发过来的数据的
- static void hrServerClientConfigAccess(GHRS_T *hr_sensor, const GATT_MANAGER_SERVER_ACCESS_IND_T *access_ind)
- {
- if (access_ind->flags & ATT_ACCESS_READ)
- {
- /* On a Read, ask the app for current client config value */
- MAKE_HR_SERVER_MESSAGE(GATT_HR_SERVER_READ_CLIENT_CONFIG_IND);
- message->hr_sensor = hr_sensor; /* Pass the instance which can be returned in the response */
- message->cid = access_ind->cid; /* Pass the CID so the client can be identified */
- MessageSend(hr_sensor->app_task, GATT_HR_SERVER_READ_CLIENT_CONFIG_IND, message);
- }
- else if (access_ind->flags & ATT_ACCESS_WRITE)
- {
- if (access_ind->size_value == GATT_CLIENT_CONFIG_NUM_OCTETS)
- {
- /* On a Write, send new client config value to the app */
- MAKE_HR_SERVER_MESSAGE(GATT_HR_SERVER_WRITE_CLIENT_CONFIG_IND);
- message->hr_sensor = hr_sensor;
- message->cid = access_ind->cid;
- <font color="Red">message->config_value = (access_ind->value[0] & 0xFF) | ((access_ind->value[1] << 8) & 0xFF00);</font>
- MessageSend(hr_sensor->app_task, GATT_HR_SERVER_WRITE_CLIENT_CONFIG_IND, message);
- /* Library response to the access request */
- sendHrServerAccessRsp(&hr_sensor->lib_task, access_ind->cid, HANDLE_HEART_RATE_MEASUREMENT_CLIENT_CONFIG, gatt_status_success, 0, NULL);
- }
- else
- {
- sendHrServerAccessErrorRsp(hr_sensor, access_ind, gatt_status_invalid_length);
- }
- }
- else
- {
- /* Reject access requests that aren't read/write, which shouldn't happen. */
- sendHrServerAccessErrorRsp(hr_sensor, access_ind, gatt_status_request_not_supported);
- }
- }
复制代码 access_ind变量是GATT_MANAGER_SERVER_ACCESS_IND_T类型的
- typedef GATT_ACCESS_IND_T GATT_MANAGER_SERVER_ACCESS_IND_T;
复制代码 GATT_ACCESS_IND_T这个类型的申明是uint8 value[1],这里value只有一个成员的空间,但是在处理的时候确有两个成员,见前面代码标红处,请问是不收到20个字节的数据也是这样处理- typedef struct
- {
- /*! Connection identifier of remote device. */
- uint16 cid;
- /*! Handle being accessed. */
- uint16 handle;
- /*! Flags - uses ATT_ACCESS range. */
- uint16 flags;
- /*! The offset of the first octet to be accessed. */
- uint16 offset;
- /*! Length of the value. */
- uint16 size_value;
- /*! Value data. */
- uint8 value[1];
- } GATT_ACCESS_IND_T;
复制代码
|
|