mirror of
https://github.com/mysensors/MySensors.git
synced 2026-02-20 01:21:27 +01:00
Add progmem support for String messages (#875)
added variant of MyMessage::set and sendSketchInfo that accept a string that's stored in PROGMEM. This avoids the need to (temporarily) store strings in memory to get them into a message.
This commit is contained in:
@@ -249,6 +249,23 @@ MyMessage& MyMessage::set(const char* value)
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if !defined(__linux__)
|
||||
MyMessage& MyMessage::set(const __FlashStringHelper* value)
|
||||
{
|
||||
uint8_t length = value == NULL ? 0
|
||||
: min(strlen_P(reinterpret_cast<const char *>(value)), (size_t)MAX_PAYLOAD);
|
||||
miSetLength(length);
|
||||
miSetPayloadType(P_STRING);
|
||||
if (length) {
|
||||
strncpy_P(data, reinterpret_cast<const char *>(value), length);
|
||||
}
|
||||
// null terminate string
|
||||
data[length] = 0;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
MyMessage& MyMessage::set(bool value)
|
||||
{
|
||||
miSetLength(1);
|
||||
|
||||
Reference in New Issue
Block a user