diff --git a/src/HAP.cpp b/src/HAP.cpp index 3ff4f3f..92a9eec 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -34,6 +34,33 @@ ////////////////////////////////////// +std::ostream& operator<<(std::ostream& os, tlv8_t &tlv){ + + uint8_t *p=tlv.val.get(); // starting pointer + uint8_t *pend=p+tlv.len; // ending pointer (may equal starting if len=0) + + do{ + uint8_t nBytes=(pend-p)>255?255:(pend-p); // max is 255 bytes per TLV record + os.write((char *)&tlv.tag,1); + os.write((char *)&nBytes,1); + os.write((char *)p,nBytes); + p+=nBytes; + } while(p\n"; } + + HAPTLV tlv; + + uint8_t x[400]; + tlv.add(58); + memset(x,'A',400); + tlv.add(48,49,x); + memset(x,'B',400); + tlv.add(50,'B'); + memset(x,'C',400); + tlv.add(52,256,x); + + hapOut << tlv; hapOut << "\n"; hapOut.flush(); @@ -1740,7 +1780,7 @@ void HapOut::HapStreamBuffer::printFormatted(char *buf, size_t nChars, size_t ns } } } - + ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/HomeSpan.h b/src/HomeSpan.h index c08ba0f..7dc224c 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -352,9 +352,8 @@ class Span{ Span& setWifiCredentials(const char *ssid, const char *pwd); // sets WiFi Credentials Span& setStatusCallback(void (*f)(HS_STATUS status)){statusCallback=f;return(*this);} // sets an optional user-defined function to call when HomeSpan status changes const char* statusString(HS_STATUS s); // returns char string for HomeSpan status change messages - - Span& setPairingCode(const char *s); // {sprintf(pairingCodeCommand,"S %9s",s);return(*this);} // sets the Pairing Code - use is NOT recommended. Use 'S' from CLI instead - void deleteStoredValues(){processSerialCommand("V");} // deletes stored Characteristic values from NVS + Span& setPairingCode(const char *s); // sets the Pairing Code - use is NOT recommended. Use 'S' from CLI instead + void deleteStoredValues(){processSerialCommand("V");} // deletes stored Characteristic values from NVS int enableOTA(boolean auth=true, boolean safeLoad=true){return(spanOTA.init(auth, safeLoad, NULL));} // enables Over-the-Air updates, with (auth=true) or without (auth=false) authorization password int enableOTA(const char *pwd, boolean safeLoad=true){return(spanOTA.init(true, safeLoad, pwd));} // enables Over-the-Air updates, with custom authorization password (overrides any password stored with the 'O' command)