Finalized CUSTOM_CHAR() macro to add a custom Characteristic
This commit is contained in:
parent
d5fa8335fb
commit
4309be8f91
|
|
@ -441,7 +441,7 @@ struct SpanCharacteristic{
|
|||
uvSet(stepValue,0);
|
||||
}
|
||||
|
||||
homeSpan.configLog+="(" + uvPrint(value) + ")" + ": IID=" + String(iid) + ", UUID=0x" + String(type);
|
||||
homeSpan.configLog+="(" + uvPrint(value) + ")" + ": IID=" + String(iid) + ", UUID=" + String(type);
|
||||
if(format!=FORMAT::STRING && format!=FORMAT::BOOL)
|
||||
homeSpan.configLog+= " Range=[" + String(uvPrint(minValue)) + "," + String(uvPrint(maxValue)) + "]";
|
||||
|
||||
|
|
|
|||
|
|
@ -522,3 +522,11 @@ namespace Characteristic {
|
|||
CREATE_CHAR(double,WaterLevel,0,0,100);
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// MACROS TO ADD CUSTOM CHARACTERISTICS //
|
||||
//////////////////////////////////////////
|
||||
|
||||
#define CUSTOM_CHAR(NAME,UUID,PERMISISONS,FORMAT,TYPE,DEFVAL,MINVAL,MAXVAL,STATIC_RANGE) \
|
||||
HapChar _CUSTOM_##NAME {#UUID,#NAME,(PERMS)(PERMISISONS),FORMAT,STATIC_RANGE}; \
|
||||
namespace Characteristic { struct NAME : SpanCharacteristic { NAME(TYPE val=DEFVAL, boolean nvsStore=false) : SpanCharacteristic {&_CUSTOM_##NAME} { init(val,nvsStore,(TYPE)MINVAL,(TYPE)MAXVAL); } }; }
|
||||
|
|
|
|||
|
|
@ -4,12 +4,7 @@
|
|||
|
||||
#include "HomeSpan.h"
|
||||
|
||||
#define CUSTOM_CHAR(NAME,UUID,PERMISISONS,FORMAT,TYPE,DEFVAL,MINVAL,MAXVAL,STATIC_RANGE) \
|
||||
HapChar _CUSTOM_##NAME {#UUID,#NAME,(PERMS)(PERMISISONS),FORMAT,STATIC_RANGE}; \
|
||||
namespace Characteristic { struct NAME : SpanCharacteristic { NAME(TYPE val=DEFVAL, boolean nvsStore=false) : SpanCharacteristic {&_CUSTOM_##NAME} { init(val,nvsStore,(TYPE)MINVAL,(TYPE)MAXVAL); } }; }
|
||||
|
||||
CUSTOM_CHAR(CustomActive, 123-B0, PW+PR+EV, UINT8, uint8_t, 0, 0, 1, true);
|
||||
|
||||
CUSTOM_CHAR(CustomActive, AB-123-B0, PW+PR+EV, UINT8, uint8_t, 0, 0, 1, true);
|
||||
|
||||
void setup() {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue