Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_nRF8001 by
BLEDescriptor.cpp
00001 #include "Arduino.h" 00002 #include "BLEDescriptor.h" 00003 00004 BLEDescriptor::BLEDescriptor(const char* uuid, unsigned char valueSize) : 00005 BLEAttribute(uuid, BLETypeDescriptor), 00006 _valueSize(min(valueSize, BLE_ATTRIBUTE_MAX_VALUE_LENGTH)), 00007 _valueLength(0) 00008 { 00009 _value = (unsigned char*)malloc(this->_valueSize); 00010 } 00011 00012 BLEDescriptor::BLEDescriptor(const char* uuid, const char* value) : 00013 BLEAttribute(uuid, BLETypeDescriptor), 00014 _valueSize(min(strlen(value), BLE_ATTRIBUTE_MAX_VALUE_LENGTH)), 00015 _valueLength(0) 00016 { 00017 _value = (unsigned char*)malloc(this->_valueSize); 00018 this->setValue(value); 00019 } 00020 00021 BLEDescriptor::~BLEDescriptor() { 00022 if (this->_value) { 00023 free(this->_value); 00024 } 00025 } 00026 00027 unsigned char BLEDescriptor::valueSize() const { 00028 return this->_valueSize; 00029 } 00030 00031 const unsigned char* BLEDescriptor::value() const { 00032 return this->_value; 00033 } 00034 00035 unsigned char BLEDescriptor::valueLength() const { 00036 return this->_valueLength; 00037 } 00038 00039 void BLEDescriptor::setValue(const unsigned char value[], unsigned char length) { 00040 this->_valueLength = min(length, this->_valueSize); 00041 00042 memcpy(this->_value, value, this->_valueLength); 00043 } 00044 00045 void BLEDescriptor::setValue(const char* value) { 00046 this->setValue((const unsigned char *)value, strlen(value)); 00047 }
Generated on Tue Jul 12 2022 15:15:46 by
1.7.2
