diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 213c671..90e4c12 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -1043,6 +1043,86 @@ void Span::processSerialCommand(const char *c){ } break; + case 'p': { + + Serial.printf("\n*** Pairing Data used for Cloning another Device\n\n"); + size_t olen; + TempBuffer tBuf(256); + mbedtls_base64_encode((uint8_t *)tBuf.buf,256,&olen,(uint8_t *)&HAPClient::accessory,sizeof(struct Accessory)); + Serial.printf("Accessory data: %s\n",tBuf.buf); + for(int i=0;i tBuf(200); + size_t olen; + + tBuf.buf[0]='\0'; + Serial.print(">>> Accessory data: "); + readSerial(tBuf.buf,199); + if(strlen(tBuf.buf)==0){ + Serial.printf("(cancelled)\n\n"); + return; + } + mbedtls_base64_decode((uint8_t *)&HAPClient::accessory,sizeof(struct Accessory),&olen,(uint8_t *)tBuf.buf,strlen(tBuf.buf)); + if(olen!=sizeof(struct Accessory)){ + Serial.printf("\n*** Error in size of Accessory data - cloning cancelled. Restarting...\n\n"); + reboot(); + } else { + HAPClient::charPrintRow(HAPClient::accessory.ID,17); + Serial.printf("\n"); + } + + for(int i=0;i>> Controller data: "); + readSerial(tBuf.buf,199); + if(strlen(tBuf.buf)==0){ + Serial.printf("(done)\n"); + while(i