Modified UUID check to allow for Custom short-form UUID
Also truncated string Characteristics printed via 'i' CLI Command to show only first 32 characters followed by "..." if there are more than 32.
This commit is contained in:
parent
69fd86f2ef
commit
e8f9ca8ac1
|
|
@ -887,8 +887,8 @@ void Span::processSerialCommand(const char *c){
|
||||||
isBridge=false; // ...this is not a bridge device
|
isBridge=false; // ...this is not a bridge device
|
||||||
|
|
||||||
for(auto chr=(*svc)->Characteristics.begin(); chr!=(*svc)->Characteristics.end(); chr++){
|
for(auto chr=(*svc)->Characteristics.begin(); chr!=(*svc)->Characteristics.end(); chr++){
|
||||||
LOG0(" \u21e8 Characteristic %s(%s): IID=%d, %sUUID=\"%s\", %sPerms=",
|
LOG0(" \u21e8 Characteristic %s(%.32s%s): IID=%d, %sUUID=\"%s\", %sPerms=",
|
||||||
(*chr)->hapName,(*chr)->uvPrint((*chr)->value).c_str(),(*chr)->iid,(*chr)->isCustom?"Custom-":"",(*chr)->type,(*chr)->perms!=(*chr)->hapChar->perms?"Custom-":"");
|
(*chr)->hapName,(*chr)->uvPrint((*chr)->value).c_str(),strlen((*chr)->uvPrint((*chr)->value).c_str())>32?"...":"",(*chr)->iid,(*chr)->isCustom?"Custom-":"",(*chr)->type,(*chr)->perms!=(*chr)->hapChar->perms?"Custom-":"");
|
||||||
|
|
||||||
int foundPerms=0;
|
int foundPerms=0;
|
||||||
for(uint8_t i=0;i<7;i++){
|
for(uint8_t i=0;i<7;i++){
|
||||||
|
|
@ -925,7 +925,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
if(!(*chr)->isCustom && !(*svc)->isCustom && std::find((*svc)->req.begin(),(*svc)->req.end(),(*chr)->hapChar)==(*svc)->req.end() && std::find((*svc)->opt.begin(),(*svc)->opt.end(),(*chr)->hapChar)==(*svc)->opt.end())
|
if(!(*chr)->isCustom && !(*svc)->isCustom && std::find((*svc)->req.begin(),(*svc)->req.end(),(*chr)->hapChar)==(*svc)->req.end() && std::find((*svc)->opt.begin(),(*svc)->opt.end(),(*chr)->hapChar)==(*svc)->opt.end())
|
||||||
LOG0(" *** WARNING #%d! Service does not support this Characteristic ***\n",++nWarnings);
|
LOG0(" *** WARNING #%d! Service does not support this Characteristic ***\n",++nWarnings);
|
||||||
else
|
else
|
||||||
if(invalidUUID((*chr)->type,(*chr)->isCustom))
|
if(invalidUUID((*chr)->type))
|
||||||
LOG0(" *** ERROR #%d! Format of UUID is invalid ***\n",++nErrors);
|
LOG0(" *** ERROR #%d! Format of UUID is invalid ***\n",++nErrors);
|
||||||
else
|
else
|
||||||
if(std::find_if((*svc)->Characteristics.begin(),chr,[chr](SpanCharacteristic *c)->boolean{return(c->hapChar==(*chr)->hapChar);})!=chr)
|
if(std::find_if((*svc)->Characteristics.begin(),chr,[chr](SpanCharacteristic *c)->boolean{return(c->hapChar==(*chr)->hapChar);})!=chr)
|
||||||
|
|
|
||||||
|
|
@ -287,10 +287,13 @@ class Span{
|
||||||
void clearNotify(int slotNum); // set ev notification flags for connection 'slotNum' to false across all characteristics
|
void clearNotify(int slotNum); // set ev notification flags for connection 'slotNum' to false across all characteristics
|
||||||
void printfNotify(SpanBuf *pObj, int nObj, int conNum); // writes notification JSON to hapOut stream based on SpanBuf objects and specified connection number
|
void printfNotify(SpanBuf *pObj, int nObj, int conNum); // writes notification JSON to hapOut stream based on SpanBuf objects and specified connection number
|
||||||
|
|
||||||
static boolean invalidUUID(const char *uuid, boolean isCustom){
|
static boolean invalidUUID(const char *uuid){
|
||||||
int x=0;
|
int x=0;
|
||||||
|
sscanf(uuid,"%*8[0-9a-fA-F]%n",&x); // check for short-form of UUID
|
||||||
|
if(strlen(uuid)==x && uuid[0]!='0')
|
||||||
|
return(false);
|
||||||
sscanf(uuid,"%*8[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*12[0-9a-fA-F]%n",&x);
|
sscanf(uuid,"%*8[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*12[0-9a-fA-F]%n",&x);
|
||||||
return(isCustom && (strlen(uuid)!=36 || x!=36));
|
return(strlen(uuid)!=36 || x!=36);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue