代码段:
#define ATT_UUID_SIZE 16
#define ATT_BT_UUID_SIZE 2
typedef unsigned char uint8;
typedef struct
{
uint8 len; //!< Length of UUID (2 or 16)
uint8 uuid[ATT_UUID_SIZE]; //!< 16 or 128 bit UUID
} attAttrType_t;
typedef struct
{
uint16 startHandle;
uint16 endHandle;
attAttrType_t type;
} attReadByTypeReq_t;
attReadByTypeReq_t req;
req.startHandle=svcStartHdl;
req.endHandle=svcEndHdl;
req.type.len=ATT_BT_UUID_SIZE;
req.type.uuid[ATT_BT_UUID_SIZE]={0xAD,0x2B};
=&GT;它说错误#29当我分配0xAD和0x2B作为uuid我可能做错了什么?
答案 0 :(得分:0)
req.type.uuid[ATT_BT_UUID_SIZE]={0xAD,0x2B};
此行不正确。 uuid [xxx]的uuid是一个数组地址,不能通过'='方法赋值。这样做:
req.type.uuid[0] = 0xAD;
req.type.uuid[1] = 0x2B;
或者像这样:
memcpy(req.type.uuid, YOUR_VALUE, ATT_BT_UUID_SIZE);