为什么BLE设备在C中接收到错误的值?

时间:2015-04-30 08:05:41

标签: c bluetooth-lowenergy

我是BLE开发的新手。 设备-A 会将01发送到设备-B

我为设备-A 定义了struct,如下所示。

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;

device-A 中,它会通过以下代码将数据发送到 device-B

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);

在上面的代码中,设备-A 1 发送到设备-B

数据在设备-B 处收到,但值为 08 ,并且还显示 33568264

我错过了什么吗?

0 个答案:

没有答案