Additional logic for TLV Characteristics
This commit is contained in:
parent
6bc45cf884
commit
7c5b01e967
|
|
@ -1846,7 +1846,7 @@ SpanCharacteristic::~SpanCharacteristic(){
|
||||||
void SpanCharacteristic::printfAttributes(int flags){
|
void SpanCharacteristic::printfAttributes(int flags){
|
||||||
|
|
||||||
const char permCodes[][7]={"pr","pw","ev","aa","tw","hd","wr"};
|
const char permCodes[][7]={"pr","pw","ev","aa","tw","hd","wr"};
|
||||||
const char formatCodes[][9]={"bool","uint8","uint16","uint32","uint64","int","float","string","data"};
|
const char formatCodes[][9]={"bool","uint8","uint16","uint32","uint64","int","float","string","data","tlv8"};
|
||||||
|
|
||||||
hapOut << "{\"iid\":" << iid;
|
hapOut << "{\"iid\":" << iid;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -618,7 +618,7 @@ class SpanCharacteristic{
|
||||||
sprintf(nvsKey,"%04X%08X%03X",t,aid,iid&0xFFF);
|
sprintf(nvsKey,"%04X%08X%03X",t,aid,iid&0xFFF);
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if(format!=FORMAT::STRING && format!=FORMAT::DATA && format!=FORMAT::TLV_ENC){
|
if(format<FORMAT::STRING){
|
||||||
if(nvs_get_u64(homeSpan.charNVS,nvsKey,&(value.UINT64))!=ESP_OK) {
|
if(nvs_get_u64(homeSpan.charNVS,nvsKey,&(value.UINT64))!=ESP_OK) {
|
||||||
nvs_set_u64(homeSpan.charNVS,nvsKey,value.UINT64); // store data as uint64_t regardless of actual type (it will be read correctly when access through uvGet())
|
nvs_set_u64(homeSpan.charNVS,nvsKey,value.UINT64); // store data as uint64_t regardless of actual type (it will be read correctly when access through uvGet())
|
||||||
nvs_commit(homeSpan.charNVS); // commit to NVS
|
nvs_commit(homeSpan.charNVS); // commit to NVS
|
||||||
|
|
@ -637,7 +637,7 @@ class SpanCharacteristic{
|
||||||
|
|
||||||
uvSet(newValue,value);
|
uvSet(newValue,value);
|
||||||
|
|
||||||
if(format!=FORMAT::STRING && format!=FORMAT::DATA && format!=FORMAT::TLV_ENC) {
|
if(format<FORMAT::STRING){
|
||||||
uvSet(minValue,min);
|
uvSet(minValue,min);
|
||||||
uvSet(maxValue,max);
|
uvSet(maxValue,max);
|
||||||
uvSet(stepValue,0);
|
uvSet(stepValue,0);
|
||||||
|
|
@ -659,14 +659,14 @@ class SpanCharacteristic{
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getString(){
|
char *getString(){
|
||||||
if(format == FORMAT::STRING)
|
if(format>=FORMAT::STRING)
|
||||||
return value.STRING;
|
return value.STRING;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getNewString(){
|
char *getNewString(){
|
||||||
if(format == FORMAT::STRING)
|
if(format>=FORMAT::STRING)
|
||||||
return newValue.STRING;
|
return newValue.STRING;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -706,7 +706,7 @@ class SpanCharacteristic{
|
||||||
} // setString()
|
} // setString()
|
||||||
|
|
||||||
size_t getData(uint8_t *data, size_t len){
|
size_t getData(uint8_t *data, size_t len){
|
||||||
if(format!=FORMAT::DATA)
|
if(format<FORMAT::DATA)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
size_t olen;
|
size_t olen;
|
||||||
|
|
@ -724,7 +724,7 @@ class SpanCharacteristic{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getNewData(uint8_t *data, size_t len){
|
size_t getNewData(uint8_t *data, size_t len){
|
||||||
if(format!=FORMAT::DATA)
|
if(format<FORMAT::DATA)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
size_t olen;
|
size_t olen;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue