为什么BLE设备在C中接收到错误的值?
我不熟悉BLE的发展。设备-A将为什么BLE设备在C中接收到错误的值?,c,bluetooth-lowenergy,C,Bluetooth Lowenergy,我不熟悉BLE的发展。设备-A将0或1发送到设备-B 我为设备-a定义了结构,如下所示 typedef struct { uint16_t handle; /**< Attribute handle */ uint16_t offset; /**< Attribute value offset, ignored i
0
或1
发送到设备-B
我为设备-a定义了结构,如下所示
typedef struct
{
uint16_t handle; /**< Attribute handle */
uint16_t offset; /**< Attribute value offset, ignored if not needed for a command */
uint16_t len; /**< Length of attribute value */
wiced_bt_gatt_auth_req_t auth_req; /**< Authentication requirement (see @link wiced_bt_gatt_auth_req_e wiced_bt_gatt_auth_req_t @endlink) */
int32_t value[1]; /**< The attribute value (actual length is specified by 'len') */
//uint16_t value[1]; /**< The attribute value (actual length is specified by 'len') */
} wiced_bt_gatt_value_t;
在上述代码中,设备-A向设备-B发送1
数据在设备-B接收,但值为08
,并且还显示33568264
我遗漏了什么吗?我不确定我是否正确理解了你的问题,但可能是因为endianness。我认为它也可能是endianness,但如果属性实际上是“len=1”,并且只有一个字节,那么endianness就不应该进入问题。Broadcom是否为wiced开发者提供了一个论坛?也许你应该在那里发布。你声明int32_t值[1]有什么具体原因吗代码>在struct
中,而不是int32\t值代码>?新的报警级别的数据类型是什么?
wiced_bt_gatt_value_t write_value;
write_value.handle = proximity_service[SERVICE_Hello].attribute_value_handle; // Handle of Immediate Alert service's alert level handle
write_value.len = 1; // Length of immediate alert level value
write_value.value[0] = new_proximity_alert_level; // Set alert level to 2
write_value.auth_req = GATT_AUTH_REQ_NONE; // No authentication requested
wiced_bt_gatt_send_write (connection_id, GATT_WRITE_NO_RSP, &write_value);