loiol 发表于 2018-12-3 11:27:22

CSR8670底层是如何实现多个字节数据的接受

最近用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 & 0xFF) | ((access_ind->value << 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,这里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;
} GATT_ACCESS_IND_T;

技术宅 发表于 2018-12-3 22:51:35

access_ind->value ,,,这个value是指针来的,这里可以传很多数据,不只两个。
页: [1]
查看完整版本: CSR8670底层是如何实现多个字节数据的接受