Commit Graph

143 Commits

Author SHA1 Message Date
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
Gregg 62f68cb33c Upgraded TempBuffer logic to use .get() to return pointer
Next up: update Network.cpp to use client.available() and reduce fixed memory usage.
2023-07-26 06:27:54 -05:00
Gregg 5f9458e625 Converted static HTTP Buffer to dynamic TempBuffer
Saved about 8K in RAM!
2023-07-25 05:54:40 -05:00
Gregg 7bc885dd26 Completed initial migration of Serial.print to LOG0
Finished all applicable cases in main source code.
TO DO: apply LOG0 to extras
2023-05-10 22:12:21 -05:00
Gregg 368ce12c04 Started work on converting all Serial.print() to LOG0() macro 2023-05-08 17:07:21 -05:00
Gregg ec1cd44382 Small tweaks to reset reasons in web log 2023-04-27 19:53:33 -05:00
Francois 7e08e00734 Added description of Reset Reason Code to WebLog. 2023-04-26 13:51:42 -04:00
Gregg 2ce78fead6 Added charset=utf-8 to weblog to allow for utf-8 encoding 2023-04-23 15:14:57 -05:00
Gregg 947e2af012 Added homeSpan.setWebLogCSS(const char *css)
Allows user to define a custom style sheet to change the webLog output.  Style sheet is based on pre-defined class:

bod1 = main body of web page, including header (in format of <h2>)
tabl1 = top table showing general status
tab2 = bottom table showing all weblog entries
2023-04-23 10:01:00 -05:00
Gregg 6fca946dd5 Added Sodium and MbedTLS versions, and Pairing Status, to Web Log 2023-04-23 07:46:37 -05:00