But declared Streamer inside HomeSpan.h instead of separate Streamer.h since it should only be used when HomeSpan.h is used.
Also, changed class structure so that it is "final" by removing virtual tags and making all protected variables private.
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.
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
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.
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]
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.
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.
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.
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.
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()
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
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.