Renamed Services.h to Span.h
Also, made it possible to use UVAL.set() for STRING Characteristic (upon initialization) but setVal() is NOT allowed.
This commit is contained in:
parent
7930e3a0d9
commit
c8a2770253
|
|
@ -65,6 +65,10 @@ union UVal {
|
|||
double FLOAT;
|
||||
const char *STRING;
|
||||
|
||||
void set(FORMAT fmt, const char *val){
|
||||
STRING=val;
|
||||
};
|
||||
|
||||
template <typename T> void set(FORMAT fmt, T val){
|
||||
|
||||
switch(fmt){
|
||||
|
|
@ -125,7 +129,7 @@ union UVal {
|
|||
return((T) FLOAT);
|
||||
|
||||
case FORMAT::STRING:
|
||||
Serial.print("*** ERROR: Can't use getVal() or getNewVal() for string Characteristics.\n\n");
|
||||
Serial.print("\n*** WARNING: Can't use getVal() or getNewVal() with string Characteristics.\n\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
@ -332,6 +336,11 @@ struct SpanCharacteristic{
|
|||
|
||||
template <typename T> void setVal(T val){
|
||||
|
||||
if(format==STRING){
|
||||
Serial.printf("\n*** WARNING: Attempt to update Characteristic::%s(\"%s\") with setVal() ignored. Can't update string characteristics once they are initialized!\n\n",hapName,value.STRING);
|
||||
return;
|
||||
}
|
||||
|
||||
value.set(format, val);
|
||||
newValue.set(format, val);
|
||||
|
||||
|
|
@ -382,4 +391,4 @@ struct SpanButton{
|
|||
/////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "Services.h"
|
||||
#include "Span.h"
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ namespace Service {
|
|||
#define CREATE_CHAR_UINT32(HAPCHAR,DEFVAL) struct HAPCHAR : SpanCharacteristic { HAPCHAR(uint32_t val=DEFVAL) : SpanCharacteristic {&hapChars.HAPCHAR} { init(val); } };
|
||||
#define CREATE_CHAR_UINT64(HAPCHAR,DEFVAL) struct HAPCHAR : SpanCharacteristic { HAPCHAR(uint64_t val=DEFVAL) : SpanCharacteristic {&hapChars.HAPCHAR} { init(val); } };
|
||||
#define CREATE_CHAR_BOOL(HAPCHAR,DEFVAL) struct HAPCHAR : SpanCharacteristic { HAPCHAR(boolean val=DEFVAL) : SpanCharacteristic {&hapChars.HAPCHAR} { init(val); } };
|
||||
#define CREATE_CHAR_STRING(HAPCHAR,DEFVAL) struct HAPCHAR : SpanCharacteristic { HAPCHAR(const char *val=DEFVAL) : SpanCharacteristic {&hapChars.HAPCHAR} { value.STRING=val; } };
|
||||
#define CREATE_CHAR_STRING(HAPCHAR,DEFVAL) struct HAPCHAR : SpanCharacteristic { HAPCHAR(const char *val=DEFVAL) : SpanCharacteristic {&hapChars.HAPCHAR} { init(val); } };
|
||||
|
||||
namespace Characteristic {
|
||||
|
||||
Loading…
Reference in New Issue