Skip to content

Commit 3ec8350

Browse files
committed
Jira 867, BLE setValue(), add support for strings, git #210
Feature added: - This is directly pulled from Arduino community PR #210. Overloading the setValue() method to take in a string as the only input parameter, instead of a pointer and its size.
1 parent d818a3a commit 3ec8350

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libraries/CurieBLE/src/BLECharacteristic.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ bool BLECharacteristic::setValue(const unsigned char value[], unsigned short len
248248
return writeValue(value, (int)length);
249249
}
250250

251+
bool BLECharacteristic::setValue(const char* value)
252+
{
253+
return this->setValue((const unsigned char *)value, strlen(value));
254+
}
255+
251256
bool BLECharacteristic::writeValue(const byte value[], int length)
252257
{
253258
return writeValue(value, length, 0);

libraries/CurieBLE/src/BLECharacteristic.h

+9
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ class BLECharacteristic: public BLEAttributeWithValue
180180
*/
181181
bool setValue(const unsigned char value[], unsigned short length);
182182

183+
/**
184+
* Set the current value of the Characteristic with a String
185+
*
186+
* @param value New string value to set, strings exceeding maxLength will be truncated
187+
*
188+
* @return bool true set value success, false on error
189+
*/
190+
bool setValue(const char* value);
191+
183192
/**
184193
* @brief Write the value of the characteristic
185194
*

0 commit comments

Comments
 (0)