diff --git a/docs/Reference.md b/docs/Reference.md index 472c8cb..0612828 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -270,6 +270,7 @@ Creating an instance of this **class** adds a new HAP Accessory to the HomeSpan * every HomeSpan sketch requires at least one Accessory * a sketch can contain a maximum of 41 Accessories per sketch (if exceeded, a runtime error will the thrown and the sketch will halt) + * extending the limit of 41 is possible by using the #define HOMESPAN_MAX_ACCESSORIES <LIMIT;>, but this is only recommended for experienced developers, as a higher limit may exceed the maximum available memory. * there are no associated methods * the argument *aid* is optional. diff --git a/src/HAP.h b/src/HAP.h index 8c8b937..0886afb 100644 --- a/src/HAP.h +++ b/src/HAP.h @@ -27,14 +27,18 @@ #pragma once -#include +#ifndef HOMESPAN_MAX_ACCESSORIES +#define HOMESPAN_MAX_ACCESSORIES 41 // maximum number of allowed Acessories (HAP limit=150, but not enough memory in ESP32 to run that many) +#endif +#include #include "HomeSpan.h" #include "TLV.h" #include "HAPConstants.h" #include "HKDF.h" #include "SRP.h" + ///////////////////////////////////////////////// // NONCE Structure (HAP used last 64 of 96 bits) @@ -75,7 +79,7 @@ struct HAPClient { static const int MAX_HTTP=8095; // max number of bytes in HTTP message buffer static const int MAX_CONTROLLERS=16; // maximum number of paired controllers (HAP requires at least 16) - static const int MAX_ACCESSORIES=41; // maximum number of allowed Acessories (HAP limit=150, but not enough memory in ESP32 to run that many) + static const int MAX_ACCESSORIES=HOMESPAN_MAX_ACCESSORIES; // maximum number of allowed Acessories (HAP limit=150, but not enough memory in ESP32 to run that many) static TLV tlv8; // TLV8 structure (HAP Section 14.1) with space for 10 TLV records of type kTLVType (HAP Table 5-6) static nvs_handle hapNVS; // handle for non-volatile-storage of HAP data