Commit Graph

304 Commits

Author SHA1 Message Date
Gregg b5dcfbbd7d Modified range checks so that "NAN" gets picked up as error for FLOAT Characteristics 2024-01-11 21:57:42 -06:00
Gregg 392eac38b9 Added homeSpan.getWebLog() 2024-01-08 18:19:38 -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 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 00944c1f2f Converted sprintfNotify and eventNotify to use HapOut
Successfully tested with MultiTest script
2023-12-31 12:36:47 -06:00
Gregg 20fe4ab6fd Deleted sprintfAttributes for Span, SpanAccessory, and SpanService
These now use the new printfAttributes with HapOut
2023-12-31 11:24:15 -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 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 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 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 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 a6a84b5e21 Added ability to turn off SpanPoint encryption
New class-level method SpanPoint::setEncryption(boolean encrypt).  Default is to use encryption unless method is called with encrypt=false.

With encryption, 7 connections max; without encryption, 20 connections max.
 Serial Monitor provides warnings if connections are exceeded.
2023-12-19 09:08:37 -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 9e3f6c8303 Override new operator for SpanAccessory, SpanService, and SpanCharacteristic
New Operator now uses PSRAM if available, else uses Internal RAM.  Obviates the need for the ps_new() macro, though will keep definition since it may be useful for any class that does not already override malloc() to use PSRAM.
2023-11-24 10:30:20 -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 2bc107032c Added HS_REALLOC macro for generalized realloc() when using PSRAM
When using PSRAM, changing the number of Accessories no longer creates any change to heap usage on internal RAM.  The entire Accessory will be stored in PSRAM.
2023-11-21 18:36:51 -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
Gregg 4ab7503a72 Added error checking for NVS storage
Also added NVS storage diagnostic to 'm' command.
2023-11-12 21:37:33 -06:00
Gregg 1e62a038f1 Changed unordered_set to vector when checking for duplicate AID
This eliminated the use of unordered_set everywhere in HomeSpan
2023-11-12 12:33:09 -06:00
Gregg 98d6abeb1f Changed storage of required and optional Characteristics from unordered_set to vector
Significantly reduces memory usage - unordered_sets take up much more memory and using std::find from <algorithm> is as efficient as using find() method of an unordered_set.

To do: Remove all uses of unordered_set across HomeSpan wherever possible
2023-11-12 09:48:46 -06:00
Gregg 713c5c65bf Added new homeSpan.rebootCallback() function
An optional callback used to track the number of times the device reboots, where a reboot is defined as any restart where the uptime was less than a specified number of milliseconds (default=5000)
2023-11-04 10:43:28 -05:00
Gregg 8b3192e122 Moved vTaskDelay(5) from pollTask() to homeSpan.autoPoll()
Adding the vTaskDelay(5) to the code that spawns the separate task is more consistent with how Arduino-ESP32 spawns the main loop() task.
2023-10-31 18:11:09 -05:00
Gregg 42f69adf49 Made vTaskDelay(5) in pollTask conditional of using autoPoll()
vTaskDelay(5) is only needed if polling is in its own task.  If calling poll() directly, there is no need for any delay.
2023-10-30 06:29:38 -05:00
Gregg 56a2f0bece Changed Accessory Limit from 41 to 150 and added Memory Warning
Low Memory Watermark is compared to DEFAULT_LOW_MEM_THRESHOLD (currently set at 80,000 bytes) after HAP initialization but before WIFI connection.  If Low Memory Watermark is below DEFAULT_LOW_MEM_THRESHOLD, a WARNING is issued.

Note: memory is based on heap with MALLOC_CAP_DEFAULT capabilities
2023-10-29 20:55:02 -05:00
Gregg 5ce7211539 Made conforming changes to setVerboseWiFiReconnect 2023-10-28 18:40:04 -05:00
HomeSpan 871eba3c1d
Merge branch 'release-1.8.1-dev' into verbose_reconnect 2023-10-28 18:16:48 -05:00
Gregg 81ee9e2dbc Added homeSpan.setWifiCallbackAll(int n)
Adds a second type of WiFi Callback that is called every time WiFi is established OR re-established after a disconnect.  Passes the number of times WiFi has been connected as an argument.
2023-10-28 17:06:40 -05:00
Francois 2bda112780 Verbose WiFi Reconnect
Add the ability to turn off WiFi reconnect messages.
2023-10-27 08:17:06 -04: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 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 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 4557e3866f Converted various homeSpan.set() methods from void to Span& to enable chaining 2023-07-21 13:27:31 -05:00
Gregg db0f522297 Added DRAM/IRAM memory stats to 'm' CLI command 2023-07-05 06:05:10 -05:00
Gregg 21da828f83 Update HomeSpan.cpp 2023-05-13 15:39:01 -05:00
Gregg 40bb97215f Added homeSpan methods setSerialInputDisable() and getSerialInputDisable()
Provides ability to disable HomeSpan from reading from Serial port (which is otherwise normally enabled)
2023-05-13 10:34:21 -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 66bb13af03 Continued change from Serial.print to LOG0() 2023-05-08 22:43:42 -05:00
Gregg 368ce12c04 Started work on converting all Serial.print() to LOG0() macro 2023-05-08 17:07:21 -05:00
Gregg beb79538e9 Update to WebLog TimeServer Logic
Acquiring time from a timeserver is now spawned as a separate task running in the background.  This avoids blocking HomeSpan while setting the time.

Default wait time has been extended from 10 seconds to 2 minutes, since there are no problems with blocking.
2023-04-27 19:29:05 -05:00
HomeSpan 889a326e02 Address conflict between SpanButton and certain Adafruit Boards
Change enum from BUTTON and TOGGLE to HS_BUTTON and HS_TOGGLE to avoid conflict with #define BUTTON in certain Adafruit boards
2023-04-20 21:56:55 -04:00
Gregg c287564aed Update HomeSpan.cpp 2023-04-03 17:15:51 -05:00