本文整理汇总了C++中BLECharacteristic::uuid方法的典型用法代码示例。如果您正苦于以下问题:C++ BLECharacteristic::uuid方法的具体用法?C++ BLECharacteristic::uuid怎么用?C++ BLECharacteristic::uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLECharacteristic
的用法示例。
在下文中一共展示了BLECharacteristic::uuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
//.........这里部分代码省略.........
this->_advDataLen += advertisementDataLength;
}
if (scanDataType && scanDataLength && scanData) {
srData[0] = scanDataLength + 1;
srData[1] = scanDataType;
memcpy(&srData[2], scanData, scanDataLength);
srDataLen = 2 + scanDataLength;
}
sd_ble_gap_adv_data_set(this->_advData, this->_advDataLen, srData, srDataLen);
sd_ble_gap_appearance_set(0);
for (int i = 0; i < numLocalAttributes; i++) {
BLELocalAttribute *localAttribute = localAttributes[i];
if (localAttribute->type() == BLETypeCharacteristic) {
this->_numLocalCharacteristics++;
}
}
this->_numLocalCharacteristics -= 3; // 0x2a00, 0x2a01, 0x2a05
this->_localCharacteristicInfo = (struct localCharacteristicInfo*)malloc(sizeof(struct localCharacteristicInfo) * this->_numLocalCharacteristics);
unsigned char localCharacteristicIndex = 0;
uint16_t handle = 0;
BLEService *lastService = NULL;
for (int i = 0; i < numLocalAttributes; i++) {
BLELocalAttribute *localAttribute = localAttributes[i];
BLEUuid uuid = BLEUuid(localAttribute->uuid());
const unsigned char* uuidData = uuid.data();
unsigned char value[255];
ble_uuid_t nordicUUID;
if (uuid.length() == 2) {
nordicUUID.uuid = (uuidData[1] << 8) | uuidData[0];
nordicUUID.type = BLE_UUID_TYPE_BLE;
} else {
unsigned char uuidDataTemp[16];
memcpy(&uuidDataTemp, uuidData, sizeof(uuidDataTemp));
nordicUUID.uuid = (uuidData[13] << 8) | uuidData[12];
uuidDataTemp[13] = 0;
uuidDataTemp[12] = 0;
sd_ble_uuid_vs_add((ble_uuid128_t*)&uuidDataTemp, &nordicUUID.type);
}
if (localAttribute->type() == BLETypeService) {
BLEService *service = (BLEService *)localAttribute;
if (strcmp(service->uuid(), "1800") == 0 || strcmp(service->uuid(), "1801") == 0) {
continue; // skip
}
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &nordicUUID, &handle);
lastService = service;
} else if (localAttribute->type() == BLETypeCharacteristic) {
示例2: 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));
}