本文整理汇总了C++中BLECharacteristic::setBLECharacteristicImp方法的典型用法代码示例。如果您正苦于以下问题:C++ BLECharacteristic::setBLECharacteristicImp方法的具体用法?C++ BLECharacteristic::setBLECharacteristicImp怎么用?C++ BLECharacteristic::setBLECharacteristicImp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLECharacteristic
的用法示例。
在下文中一共展示了BLECharacteristic::setBLECharacteristicImp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BLEAttribute
BLECharacteristicImp::BLECharacteristicImp(BLECharacteristic& characteristic,
const BLEDevice& bledevice):
BLEAttribute(characteristic.uuid(), BLETypeCharacteristic),
_value_length(0),
_value_buffer(NULL),
_value_updated(false),
_value_handle(0),
_cccd_handle(0),
_attr_chrc_value(NULL),
_attr_cccd(NULL),
_subscribed(false),
_reading(false),
_ble_device()
{
unsigned char properties = characteristic._properties;
_value_size = characteristic._value_size;
_value = (unsigned char*)malloc(_value_size);
if (_value == NULL)
{
errno = ENOMEM;
}
if (_value_size > BLE_MAX_ATTR_DATA_LEN)
{
_value_buffer = (unsigned char*)malloc(_value_size);
}
memset(&_ccc_cfg, 0, sizeof(_ccc_cfg));
memset(&_ccc_value, 0, sizeof(_ccc_value));
memset(&_gatt_chrc, 0, sizeof(_gatt_chrc));
memset(&_sub_params, 0, sizeof(_sub_params));
memset(&_discover_params, 0, sizeof(_discover_params));
_ccc_value.cfg = &_ccc_cfg;
_ccc_value.cfg_len = 1;
if (BLERead & properties)
{
_gatt_chrc.properties |= BT_GATT_CHRC_READ;
}
if (BLEWrite & properties)
{
_gatt_chrc.properties |= BT_GATT_CHRC_WRITE;
}
if (BLEWriteWithoutResponse & properties)
{
_gatt_chrc.properties |= BT_GATT_CHRC_WRITE_WITHOUT_RESP;
}
if (BLENotify & properties)
{
_gatt_chrc.properties |= BT_GATT_CHRC_NOTIFY;
_sub_params.value |= BT_GATT_CCC_NOTIFY;
}
if (BLEIndicate & properties)
{
_gatt_chrc.properties |= BT_GATT_CHRC_INDICATE;
_sub_params.value |= BT_GATT_CCC_INDICATE;
}
_gatt_chrc.uuid = (bt_uuid_t*)this->bt_uuid();//&_characteristic_uuid;//this->uuid();
memcpy(_event_handlers, characteristic._event_handlers, sizeof(_event_handlers));
memcpy(_oldevent_handlers, characteristic._oldevent_handlers, sizeof(_oldevent_handlers));
_sub_params.notify = profile_notify_process;
if (NULL != characteristic._value)
{
memcpy(_value, characteristic._value, _value_size);
}
// Update BLE device object
_ble_device.setAddress(*bledevice.bt_le_address());
characteristic.setBLECharacteristicImp(this);
memset(&_descriptors_header, 0, sizeof(_descriptors_header));
}