Deleted sprintfAttributes for Span, SpanAccessory, and SpanService
These now use the new printfAttributes with HapOut
This commit is contained in:
parent
1f13906a25
commit
20fe4ab6fd
|
|
@ -618,18 +618,12 @@ void Span::processSerialCommand(const char *c){
|
|||
}
|
||||
break;
|
||||
|
||||
case 'd': {
|
||||
|
||||
// TempBuffer<char> qBuf(sprintfAttributes(NULL)+1);
|
||||
// sprintfAttributes(qBuf);
|
||||
case 'd': {
|
||||
|
||||
printfAttributes();
|
||||
LOG0("\n*** Attributes Database: size=%d configuration=%d ***\n\n",hapOut.getSize(),hapConfig.configNumber);
|
||||
hapOut.flush();
|
||||
|
||||
// LOG0("\n*** Attributes Database: size=%d configuration=%d ***\n\n",qBuf.len()-1,hapConfig.configNumber);
|
||||
// prettyPrint(qBuf);
|
||||
|
||||
hapOut.setLogLevel(0);
|
||||
printfAttributes();
|
||||
hapOut.flush();
|
||||
|
|
@ -638,6 +632,7 @@ void Span::processSerialCommand(const char *c){
|
|||
break;
|
||||
|
||||
case 'Q': {
|
||||
|
||||
char tBuf[5];
|
||||
const char *s=c+1+strspn(c+1," ");
|
||||
sscanf(s," %4[0-9A-Za-z]",tBuf);
|
||||
|
|
@ -1255,24 +1250,6 @@ void Span::printfAttributes(int flags){
|
|||
|
||||
///////////////////////////////
|
||||
|
||||
int Span::sprintfAttributes(char *cBuf, int flags){
|
||||
|
||||
int nBytes=0;
|
||||
|
||||
nBytes+=snprintf(cBuf,cBuf?64:0,"{\"accessories\":[");
|
||||
|
||||
for(int i=0;i<Accessories.size();i++){
|
||||
nBytes+=Accessories[i]->sprintfAttributes(cBuf?(cBuf+nBytes):NULL,flags);
|
||||
if(i+1<Accessories.size())
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",");
|
||||
}
|
||||
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"]}");
|
||||
return(nBytes);
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
void Span::prettyPrint(char *buf, int nsp, int minLogLevel){
|
||||
|
||||
if(logLevel<minLogLevel)
|
||||
|
|
@ -1714,24 +1691,6 @@ void SpanAccessory::printfAttributes(int flags){
|
|||
hapOut << "]}";
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
int SpanAccessory::sprintfAttributes(char *cBuf, int flags){
|
||||
int nBytes=0;
|
||||
|
||||
nBytes+=snprintf(cBuf,cBuf?64:0,"{\"aid\":%u,\"services\":[",aid);
|
||||
|
||||
for(int i=0;i<Services.size();i++){
|
||||
nBytes+=Services[i]->sprintfAttributes(cBuf?(cBuf+nBytes):NULL,flags);
|
||||
if(i+1<Services.size())
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",");
|
||||
}
|
||||
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"]}");
|
||||
|
||||
return(nBytes);
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// SpanService //
|
||||
///////////////////////////////
|
||||
|
|
@ -1839,42 +1798,6 @@ void SpanService::printfAttributes(int flags){
|
|||
hapOut << "]}";
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
int SpanService::sprintfAttributes(char *cBuf, int flags){
|
||||
int nBytes=0;
|
||||
|
||||
nBytes+=snprintf(cBuf,cBuf?64:0,"{\"iid\":%d,\"type\":\"%s\",",iid,type);
|
||||
|
||||
if(hidden)
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"\"hidden\":true,");
|
||||
|
||||
if(primary)
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"\"primary\":true,");
|
||||
|
||||
if(!linkedServices.empty()){
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"\"linked\":[");
|
||||
for(int i=0;i<linkedServices.size();i++){
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"%d",linkedServices[i]->iid);
|
||||
if(i+1<linkedServices.size())
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",");
|
||||
}
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"],");
|
||||
}
|
||||
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"\"characteristics\":[");
|
||||
|
||||
for(int i=0;i<Characteristics.size();i++){
|
||||
nBytes+=Characteristics[i]->sprintfAttributes(cBuf?(cBuf+nBytes):NULL,flags);
|
||||
if(i+1<Characteristics.size())
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,",");
|
||||
}
|
||||
|
||||
nBytes+=snprintf(cBuf?(cBuf+nBytes):NULL,cBuf?64:0,"]}");
|
||||
|
||||
return(nBytes);
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
// SpanCharacteristic //
|
||||
///////////////////////////////
|
||||
|
|
|
|||
|
|
@ -285,7 +285,6 @@ class Span{
|
|||
void resetStatus(); // resets statusLED and calls statusCallback based on current HomeSpan status
|
||||
void reboot(); // reboots device
|
||||
|
||||
int sprintfAttributes(char *cBuf, int flags=GET_VALUE|GET_META|GET_PERMS|GET_TYPE|GET_DESC); // prints Attributes JSON database into buf, unless buf=NULL; return number of characters printed, excluding null terminator
|
||||
void printfAttributes(int flags=GET_VALUE|GET_META|GET_PERMS|GET_TYPE|GET_DESC); // writes Attributes JSON database to hapOut stream
|
||||
|
||||
void prettyPrint(char *buf, int nsp=2, int minLogLevel=0); // print arbitrary JSON from buf to serial monitor, formatted with indentions of 'nsp' spaces, subject to specified minimum log level
|
||||
|
|
@ -409,7 +408,6 @@ class SpanAccessory{
|
|||
int iidCount=0; // running count of iid to use for Services and Characteristics associated with this Accessory
|
||||
vector<SpanService *, Mallocator<SpanService*>> Services; // vector of pointers to all Services in this Accessory
|
||||
|
||||
int sprintfAttributes(char *cBuf, int flags); // prints Accessory JSON database into buf, unless buf=NULL; return number of characters printed, excluding null terminator, even if buf=NULL
|
||||
void printfAttributes(int flags); // writes Accessory JSON to hapOut stream
|
||||
|
||||
protected:
|
||||
|
|
@ -441,7 +439,6 @@ class SpanService{
|
|||
boolean isCustom; // flag to indicate this is a Custom Service
|
||||
SpanAccessory *accessory=NULL; // pointer to Accessory containing this Service
|
||||
|
||||
int sprintfAttributes(char *cBuf, int flags); // prints Service JSON records into buf; return number of characters printed, excluding null terminator
|
||||
void printfAttributes(int flags); // writes Service JSON to hapOut stream
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in New Issue