Preparing for re-factoring postPairSetup
This commit is contained in:
parent
6e323976fd
commit
fe3389da3b
17
src/HAP.cpp
17
src/HAP.cpp
|
|
@ -224,12 +224,9 @@ void HAPClient::processRequest(){
|
|||
strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8
|
||||
tlv8.unpack(content,cLen)){ // read TLV content
|
||||
tlv8.print(2); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)"
|
||||
tlv8_new.unpack(content,cLen);
|
||||
tlv8_new.print();
|
||||
LOG2("------------ END TLVS! ------------\n");
|
||||
|
||||
postPairSetupURL(); // process URL
|
||||
tlv8_new.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -256,12 +253,9 @@ void HAPClient::processRequest(){
|
|||
strstr(body,"Content-Type: application/pairing+tlv8") && // check that content is TLV8
|
||||
tlv8.unpack(content,cLen)){ // read TLV content
|
||||
tlv8.print(2); // print TLV records in form "TAG(INT) LENGTH(INT) VALUES(HEX)"
|
||||
tlv8_new.unpack(content,cLen);
|
||||
tlv8_new.print();
|
||||
LOG2("------------ END TLVS! ------------\n");
|
||||
|
||||
postPairingsURL(); // process URL
|
||||
tlv8_new.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -703,7 +697,6 @@ int HAPClient::postPairVerifyURL(uint8_t *content, size_t len){
|
|||
}
|
||||
|
||||
uint8_t secretCurveKey[32]; // Accessory's secret key for Curve25519 encryption (32 bytes). Ephemeral usage - created below and used only in this block
|
||||
|
||||
crypto_box_keypair(publicCurveKey,secretCurveKey); // generate Curve25519 public key pair (will persist until end of verification process)
|
||||
|
||||
memcpy(iosCurveKey,*itPublicKey,32); // save iosCurveKey (will persist until end of verification process)
|
||||
|
|
@ -1426,11 +1419,8 @@ void HAPClient::tlvRespond(TLV8 &tlv8){
|
|||
|
||||
void HAPClient::tlvRespond(){
|
||||
|
||||
// TempBuffer<uint8_t> tBuf(tlv8.pack(NULL)); // create buffer to hold TLV data
|
||||
// tlv8.pack(tBuf); // pack TLV records into buffer
|
||||
|
||||
TempBuffer<uint8_t> tBuf(tlv8_new.pack_size()); // create buffer to hold TLV data
|
||||
tlv8_new.pack(tBuf); // pack TLV records into buffer
|
||||
TempBuffer<uint8_t> tBuf(tlv8.pack(NULL)); // create buffer to hold TLV data
|
||||
tlv8.pack(tBuf); // pack TLV records into buffer
|
||||
|
||||
char *body;
|
||||
asprintf(&body,"HTTP/1.1 200 OK\r\nContent-Type: application/pairing+tlv8\r\nContent-Length: %d\r\n\r\n",tBuf.len()); // create Body with Content Length = size of TLV data
|
||||
|
|
@ -1439,7 +1429,7 @@ void HAPClient::tlvRespond(){
|
|||
LOG2(client.remoteIP());
|
||||
LOG2(" >>>>>>>>>>\n");
|
||||
LOG2(body);
|
||||
tlv8_new.print();
|
||||
tlv8.print(2);
|
||||
|
||||
if(!cPair){ // unverified, unencrypted session
|
||||
client.print(body);
|
||||
|
|
@ -1772,7 +1762,6 @@ void Nonce::inc(){
|
|||
// instantiate all static HAP Client structures and data
|
||||
|
||||
TLV<kTLVType,11> HAPClient::tlv8;
|
||||
TLV8 HAPClient::tlv8_new{tlvNames,11};
|
||||
nvs_handle HAPClient::hapNVS;
|
||||
nvs_handle HAPClient::srpNVS;
|
||||
HKDF HAPClient::hkdf;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "SRP.h"
|
||||
#include "TLV8.h"
|
||||
|
||||
const TLV8_names tlvNames[] = {
|
||||
const TLV8_names HAP_Names[] = {
|
||||
{kTLVType_Separator,"*SEPARATOR"},
|
||||
{kTLVType_State,"*STATE"},
|
||||
{kTLVType_PublicKey,"*PUBKEY"},
|
||||
|
|
@ -103,7 +103,6 @@ struct HAPClient {
|
|||
static const int MAX_ACCESSORIES=150; // maximum number of allowed Accessories (HAP limit=150)
|
||||
|
||||
static TLV<kTLVType,11> tlv8; // TLV8 structure (HAP Section 14.1) with space for 11 TLV records of type kTLVType (HAP Table 5-6)
|
||||
static TLV8 tlv8_new; // TLV8 structure (HAP Section 14.1) with space for 11 TLV records of type kTLVType (HAP Table 5-6)
|
||||
static nvs_handle hapNVS; // handle for non-volatile-storage of HAP data
|
||||
static nvs_handle srpNVS; // handle for non-volatile-storage of SRP data
|
||||
static HKDF hkdf; // generates (and stores) HKDF-SHA-512 32-byte keys derived from an inputKey of arbitrary length, a salt string, and an info string
|
||||
|
|
@ -173,9 +172,9 @@ struct HAPClient {
|
|||
static void checkTimedWrites(); // checks for expired Timed Write PIDs, and clears any found (HAP Section 6.7.2.4)
|
||||
static void eventNotify(SpanBuf *pObj, int nObj, int ignoreClient=-1); // transmits EVENT Notifications for nObj SpanBuf objects, pObj, with optional flag to ignore a specific client
|
||||
|
||||
class HAPTLV : public TLV8 {
|
||||
class HAPTLV : public TLV8 { // dedicated class for HAP TLV8 records
|
||||
public:
|
||||
HAPTLV() : TLV8(tlvNames,11){}
|
||||
HAPTLV() : TLV8(HAP_Names,11){}
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue