diff --git a/src/HAP.cpp b/src/HAP.cpp index b002c82..d83a412 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1633,7 +1633,10 @@ void HapOut::HapStreamBuffer::flushBuffer(){ if(logLevel<=homeSpan.getLogLevel()){ buffer[num]='\0'; // add null terminator but DO NOT increment num (we don't want terminator considered as part of buffer) - Serial.print(buffer); + if(enablePrettyPrint) // if pretty print needed, use formatted method + printFormatted(buffer,num,2); + else // if not, just print + Serial.print(buffer); } if(hapClient!=NULL){ @@ -1680,12 +1683,49 @@ int HapOut::HapStreamBuffer::sync(){ hapClient=NULL; enablePrettyPrint=false; byteCount=0; + indent=0; mbedtls_sha512_finish_ret(ctx,hash); // finish SHA-384 and store hash mbedtls_sha512_starts_ret(ctx,1); // re-start hash for next time return(0); } + +////////////////////////////////////// + +void HapOut::HapStreamBuffer::printFormatted(char *buf, size_t nChars, size_t nsp){ + + for(int i=0;iwrite(buffer,num); -// delay(1); -// -// pbump(-num); -// return num; -//} -// -//////////////////////////////////////// -// -//StreamBuffer::int_type StreamBuffer::overflow(StreamBuffer::int_type c){ -// -// if(c!=EOF){ -// *pptr() = c; -// pbump(1); -// } -// -// if(flushBuffer()==EOF) -// return EOF; -// return c; -//} -// -//////////////////////////////////////// -// -//int StreamBuffer::sync(){ -// -// if(flushBuffer()==EOF) -// return -1; -// return 0; -//} -// -////////////////////////////////////////