Commit Graph

152 Commits

Author SHA1 Message Date
Gregg 39b7b54d48 Fixed CSS in weblog
Missing conversion from String to c_str() when using hapOut.
2024-01-07 10:22:21 -06:00
Gregg 0492b67b55 Changed hapOut delay back to 1ms - works fine
Identified issue with ESP32-S3 crashing when using PSRAM.  Problem was not the code, but that the sketch was using pins that are needed to run the Octal PSRAM that comes with the Espressif S3 DevKit.
2024-01-06 21:08:32 -06:00
Gregg bd474778e5 fix for PSRAM with new hapOut
Force hapOut to use internal memory only.

Tested on ESP32-S2 with/without PSRAM.  However, crashes on ESP32-S3 when using PSRAM (?!)
2024-01-06 16:55:17 -06:00
Gregg 12c6cf3fe1 Changed HapOut delay from 1ms to 50ms for WiFi transmits. Seems to be much more stable. 2024-01-01 17:35:02 -06:00
Gregg cc7ffb4c07 Moved prettyPrint into HapOut
This completes re-work of all JSON buffer memory management to use HAPOut.

Next up: Stress test with Max Accessories to see how many Accessories we can now handle.
2024-01-01 09:39:54 -06:00
Gregg bef151cdb1 Converted all remaining sprintfAttributes to printfAttributes
This removes last of large-sized JSON buffers - everything has now been converted to using hapOut.

Next up: Must add prettyPrint to hapOut to support 'd' command
2024-01-01 08:49:33 -06:00
Gregg 6c3df551eb Added back weblogCallback() functionality that uses hapOut 2023-12-31 17:05:22 -06:00
Gregg 00944c1f2f Converted sprintfNotify and eventNotify to use HapOut
Successfully tested with MultiTest script
2023-12-31 12:36:47 -06:00
Gregg 1f13906a25 Added SHA-384 hash computation to HapOut
Hashing of entire database is now done piecemeal within HapOut, preventing the need to load the entire database into a large buffer just to obtain a unique hash.

Modified updateDatabase() to use HapOut.getHash()
2023-12-31 09:36:19 -06:00
Gregg f2cb880e4e Converted sprintfAttributes to printfAttributes and added encryption to HapOut
Success!
2023-12-30 23:07:09 -06:00
Gregg 83924a6bdf Added getSize() to HapOut and changed default behavior to NEVER output anything
Note: getSize() must be called before flush(), which resets byte counter
2023-12-30 17:52:28 -06:00
Gregg 18c74e6f17 Moved StreamBuf into HapOut as private nested class 2023-12-30 17:07:12 -06:00
Gregg 117c348708 Moved StreamBuf parameter calls into HapOut 2023-12-30 16:22:35 -06:00
Gregg fb5c9e1e29 Begin integration of hapStream into HAP.ccp 2023-12-30 11:37:56 -06:00
Gregg f3e98601b0 Initial test of StreamBuffer added to WebLog 2023-12-29 22:19:49 -06:00
Gregg cd85cc1629 Completed refactoring of SRP6A and integration into all steps of Pair-Setup 2023-12-28 17:32:17 -06:00
Gregg 9209cb6b41 Completed Pair-Setup M3 update 2023-12-28 11:13:34 -06:00
Gregg 6979ab8080 In process of updated Pair-Setup M3...
Cleaning up code by replacing calls to mbedTLS within Pair-Setup with arguments passed to/from SRP6A.  Much better and better encapsulates SRP6A
2023-12-28 07:04:07 -06:00
Gregg c529f93646 Moved definitions of N3072 and other constants into SRP6A structure 2023-12-27 21:45:09 -06:00
Gregg b960c2fdaf Initial integration of local SRP6A into Pair Setup 2023-12-27 17:13:32 -06:00
Gregg da55b9b6b1 Start re-working SRP6A's use in Pair-Setup to make it local instead of global 2023-12-27 14:31:22 -06:00
Gregg beef66eec0 Added new initializer to TempBuffer
Allows TempBuffer to be initialized by concatenation of multiple existing buffers.

Constructor contains pairs of (T *buf), nElements, where last argument MUST BE NULL to signify end of variable argument list.

Will work with any type T, and nElements is in units of elements of type T.
2023-12-26 15:53:38 -06:00
Gregg 223107d8aa Cleaning up postverify 2023-12-26 10:38:33 -06:00
Gregg 6280c17154 Removed all old TLV code 2023-12-25 22:17:08 -06:00
Gregg 3c172da714 Completed and fully tested refactoring of TLV8
Next up: remove old TLV code and clean up
2023-12-25 22:04:02 -06:00
Gregg 76a6a2bde9 Completed postPairSetup and fully tested - also changes TLV8 from vector to forward_list
Changed TLV8 from vector to forward_list to ensure iterators are always retained after adding new elements.

Nest: refactor postPairings
2023-12-25 14:46:11 -06:00
Gregg 0e0f1dcb1c Completed initial re-factoring of postPairSetup - must test! 2023-12-24 17:35:25 -06:00
Gregg edb0cc1be0 added TLV length function
Checks that iterator exists (i.e. does not equal end()) and returns length, else returns -1.  Can be used for checking for both the presence, and length, of a TLV record
2023-12-24 15:22:00 -06:00
Gregg 66e7fc6654 Starting re-factoring of postPairSetup 2023-12-23 21:21:34 -06:00
Gregg fe3389da3b Preparing for re-factoring postPairSetup 2023-12-23 15:59:04 -06:00
Gregg 6e323976fd Completed re-factoring of postPairVerify using new TLV8
Next: re-factor postPairSetup
2023-12-23 15:44:01 -06:00
Gregg 1587f56626 Starting to integrate new TLV8 into postPairVerify 2023-12-23 14:29:53 -06:00
Gregg aa700f94f1 Added new TLV8 class
To do: Refactor HAP.cpp to use new TLV8 class
2023-12-22 12:07:26 -06:00
Gregg 70126cb04f Eliminated .get() from TempBuffer objects where possible
Stylistic only.  Cannot remove .get() when a TempBuffer is being re-cast.  Also can't remove .get() when cast can't be determined, such as when used in Serial.printf() [potential to do: explore if this can be addressed, though this is stylistic only and has no impact on code]
2023-11-25 16:48:23 -06:00
Gregg f6ebc1ae22 Changed various static and dynamic stack-based buffers to TempBuffer
Also added casting overload to TempBuffer so that get() method is no longer needed
2023-11-25 16:13:24 -06:00
Gregg b7c294d210 Change NVS storage for Characteristics to always use nvs_set_u64()
Reduces NVS consumption by from 3 to only 1 records when storing numerical values.

Also:  Fixed memory problem in getCharacteristics by replacing dynamically-sized stack buffers with TempBuffer (must do this everywhere), which was causing stack probllem when combination number of Accessories and number of Characteristics got very large.
2023-11-24 09:53:12 -06:00
Gregg 9e0512e48b Address WebLog size issue that limited number of entries
Added logic to sequentially transmit chunks of the HTML response String whenever it grows beyond 1024 bytes.  This ensures the number of WebLog entries does not create a very large HTML String that eats up all the free heap space.  WebLog entries are now only limited by storage of the entries themselves.  Tested successfully with 500 entries.
2023-11-22 06:15:43 -06:00
Gregg 8268e519dd PSRAM: Adds custom allocator and HS_MALLOC/HS_CALLOC macros
Forces all heap requests to be drawn from PSRAM, unless the device does not contain PSRAM.

To do:  Provide easy-to-use NEW() macro; add custom allocator to unordered sets; auto-shrink vectors after updateDatabase()
2023-11-20 21:57:20 -06:00
Francois a9578924c2 Fixing HTML syntax error in weblogs. 2023-11-15 08:06:07 -05:00
Gregg ae60a84855 Update HAPClient::sendEncrypted() to send individual frames to save memory
Rather than use a large temporary buffer to store all encrypted frames to transmit all at once, each encrypted frame is transmitted as soon as created, which means the temporary buffer only needs to be large enough to store a single encrypted frame.

For a device with a large number of Accessories, this can save 15-20 KB of temporary storage, allowing for more Accessories.

Note this change does not reduce the size of the unencrypted message that is initially produced and can also be quite large.  Potential for future project.
2023-11-11 10:26:25 -06:00
Gregg 4de61e5914 Change webLogCallback() to pass String as reference 2023-10-24 13:43:04 -05:00
Gregg 0f96d0fff6 Added homeSpan.setWebLogCallback(String (*f)())
Allows extension of initial table produced in WebLog, where f is a function that returns a String.  The returned String is copied into the WebLog HTML just before the </table> tag is printed in the initial table.
2023-10-22 18:23:25 -05:00
Gregg 3396a5ff96 Refactored Controller Structure and Add/Remove/List/Save Functions
Changed fixed-size array `struct Controller[MAX_CONTROLLERS]` to a dynamic linked-list of Controllers.  Re-coded all related functions.  MAX_CONTROLLERS no sets the size of any buffers but is only used to limit the ultimate size of the linked-list.

Saved about 1K of RAM since most of the time there are only 2 Controllers defined (as opposed to the 16 allowed).
2023-08-03 22:29:31 -05:00
Gregg 5a356432b3 Simplified `uint8_t *TLV<tagType, maxTags>::buf(tagType tag, int len)`
Also updated HAP.cpp to use new `uint8_t *TLV<tagType, maxTags>::buf(tagType tag, uint8_t *src, int len)`
2023-07-30 21:54:14 -05:00
Gregg a84429f930 Refactored TLV
* Added support for zero-length TLV
* Added SEPARATOR as a formal kTLVType (and updated listControllers() to use)
* Added `uint8_t *buf(tagType tag, uint8_t *src, int len);` to load buffer needing external memcpy (and updated listControllers() to use)
2023-07-30 21:37:47 -05:00
Gregg 17410e825e Completed adding LIST to HAPClient::postPairingsURL()
HomeSpan now correctly responds to pairing list requests
2023-07-29 08:35:01 -05:00
Gregg 7325baa1a5 Added HAPClient::listControllers()
Will be used for pairings list request
2023-07-29 01:21:55 -05:00
Gregg bf057e2fad modified HAP::receivedEncrypted() to use TempBuffer instead of fixed stack array 2023-07-28 19:51:56 -05:00
Gregg 131e5b1a92 Removed duplicate if(POST /pairings) 2023-07-28 19:38:16 -05:00
Gregg 793f7882b1 Replaced appropriate snprintf() with asprintf() and used *m in sscanf
Optimized use of heap memory instead of stack memory for temporary variables, and makes code easier to read, provided all heap usage is free() at end of each function.

Also removed char *hostName as a member variable of homeSpan.  It's never actually used since MDNS constructs its own copy of hostName as needed.
2023-07-26 22:46:20 -05:00