Commit Graph

1826 Commits

Author SHA1 Message Date
Gregg a7d57699a0 Added homeSpan.resetIID()...
...as well as SpanService.getIID() and SpanCharacteristic.getIID().

This provides control of IIDs used for each Service and Characteristic.
By using this with adaptive lighting test, was able to verify that HomeKit can interpret TLV values of 1 byte, 2 bytes, and 4 bytes, but not 3 bytes.  Suggests that TLV values need to be multiples of 2 (i.e. uint8, uint16, uint32).  Will change TLV value-writing methodology so that padding zeros are used to round to 1, 2, 4, or 8 bytes.
2024-04-14 21:05:09 -05:00
Gregg e4df56293a Added TLV8:printAll()
Recursively prints an entire TLV and all embedded sub-TLVs based on a best-guess if the value of any TLV is a sub-TLV.
2024-04-14 13:37:04 -05:00
Gregg 48cab1f82b Changed tlv8_t from struct to class and made variables private
Add getLen() and getTag() method to get length and tag of tlv8_t.

Also overrode subscript operator [] so you can access any element of internal uint8_t array.

Given previous additions (such as getVal()) there is now no reason to need to access the underlying std::unique_ptr directly.
2024-04-13 22:59:37 -05:00
Gregg 28990d6ed6 Revert "Changed TLV:add() so it returns TLV8 instead of iterator."
This reverts commit 7a50479bac.
2024-04-13 22:00:37 -05:00
Gregg 7a50479bac Changed TLV:add() so it returns TLV8 instead of iterator.
Makes it easier to chain .add() functions as well as dynamically create sub TLVs.

Changing TLV8::add() in this fashion also required updating various use cases of TLV::add() in HAP.cpp where add() was used to reserve space for a blank TLV element.  All changes have been tested.
2024-04-13 19:12:26 -05:00
Gregg 5ded77d6d9 Replace TLV8 (*it)[0] with new TLV8 getVal() method in HAP.cpp 2024-04-08 21:52:51 -05:00
Gregg d40d709643 Add TLV8 add() methods for uint64_t and char*, as well as new getVal() template for returning an integer 2024-04-08 21:33:27 -05:00
Gregg acebaf6caa Add ability to unpack TLV8 by iterator
Also fixed bug using increment operator (++) by replacing with std::next()
2024-04-06 21:45:49 -05:00
Gregg 7e2625034c Added TLV8_it add(uint8_t tag, TLV8 &subTLV)
Allows easy-add of a sub TLV to an existing TLV8
2024-04-04 21:31:28 -05:00
Gregg 75cbf9715f added mechanism to strip unnecessary backslashes from Home App JSON
Apple "escapes" forward slashes in JSON output, replacing '/' with '\/', which destroys base64 strings.
2024-04-04 21:12:13 -05:00
Gregg 3d4b02e492 created getDataGeneric() and getStringGeneric()
Though this simplifies the code, the code size is still the same - compiler must have already optimized these functions.
2024-03-31 21:40:00 -05:00
Gregg 1892a0a5a2 created getTLVGeneric() and used as base for getTLV() and getNewTLV()
avoids unnecessary duplication of code where the only difference is whether you need the value or the newValue of a Characteristic.
2024-03-31 21:25:22 -05:00
Gregg f137b0bee5 Updated getTLV() so it uses a fixed buffer as intermediate step
This is much more memory efficient.  Instead of decoding entire STRING from base64 to a temporary buffer or potentially very large size and then unpacking into TLV object, we decode a maximum of 48 characters at a time and unpack the resulting 36 (max) bytes until entire STRING is consumed.

getTLV() returns pack_size of final TLV, unless there is a problem with conversion, in which cae TLV is wiped and return value=0
2024-03-31 21:13:17 -05:00
Gregg eb821f002f created getTLV(TLV8 &tlv)
Works, but is memory-inefficient since it decodes entire string before unpacking.  Need to add new functionality to TLV8 so that unpacking can be done in chunks similar to how pack() works.

Also need to create getNewTLV() OR make all get/getNew generic to reduce code size.
2024-03-31 09:23:23 -05:00
Gregg cbe26c7c41 update setString() to use setValCheck() and setValFinish() 2024-03-31 08:51:06 -05:00
Gregg 11bd605a03 updated setData and setTLV to use new common setValCheck() and setValFinish() 2024-03-30 22:13:52 -05:00
Gregg f6d4d37ff7 Initial creation of setTLV() 2024-03-30 17:51:37 -05:00
Gregg e8f9ca8ac1 Modified UUID check to allow for Custom short-form UUID
Also truncated string Characteristics printed via 'i' CLI Command to show only first 32 characters followed by "..." if there are more than 32.
2024-03-30 06:03:31 -05:00
Gregg 69fd86f2ef Testing TLV Characteristic using DisplayOrder (custom Characteristic) 2024-03-29 22:18:04 -05:00
Gregg 1b74564baf More TLV updates 2024-03-29 09:19:06 -05:00
Gregg a11eab4b37 Fixed return value in TLV8::add() 2024-03-27 20:41:29 -05:00
Gregg 9b0b18310e changed TLV8 from std::forward_list to std::list
Though this increases space requirement for TLV8 (just a little), using std::list allows adding elements directly to end, which ensure the order is maintained when packing and unpacking.  Will avoid potential confusion when TLV8 is used for Characteristics.
2024-03-24 22:03:23 -05:00
HomeSpan 7c5b01e967 Additional logic for TLV Characteristics 2024-03-24 09:37:27 -05:00
Gregg 6bc45cf884 Added enum and logic for TLV Characteristics 2024-03-17 19:54:48 -05:00
HomeSpan 41f755039f
Update Reference.md 2024-03-16 14:29:36 -05:00
Gregg faa99e0fbb Added checks for use of setVal()
Throws warning, but still performs change, if setVal() is used within update() to change the value of a Characteristic that is being updated by the Home App, UNLESS the Characteristics has requested a write-response (in which case setVal() is expected).

Throw warning, and DOES NOT perform change, if setVal() is used on a Characteristic without EV permission, UNLESS it has been used in update() in response to a write-response request.

Also added diagnostic to 'i' CLI command that indicates which connections have currently asked to EV Notifications for each Characteristic.  Only applies if EV permission is set for a Characteristic.
2024-03-16 13:56:04 -05:00
Gregg 8ce80157b3 Added native support for WR (write-response)
HAPClient::putCharacteristics() now parses for "r":true in JSON, which is the HAP request for a write-response.  When found, HomeSpan will return with a full write-response for all Characteristics updated using "207 Multi-Status", where "value" will be included only if "r":true was specified for a Characteristic.

HomeSpan processes "r":true for any Characteristic regardless if permissions includes WR.

To change the value of the Characteristic from within an update() method, use setVal() WITH OPTIONAL SECOND ARGUMENT AS FALSE to supress an EV broadcast (in the unlikely event that there was a notification subscriber).

To do: Consider generally disallowing the changing of any Characteristic value from within update() using setVal() unless the Characteristic has WR permission.  And if so, automatically surpress EV notification.
2024-03-15 17:35:04 -05:00
HomeSpan 181c5e99b2
Update Tutorials.md 2024-03-09 19:04:59 -06:00
Gregg cf2a98d1c2 Review and refresh comment in Tutorial Examples as needed.
Also introduced the use of Enumerated Constants in Example 13 - Target States
2024-03-09 19:00:05 -06:00
HomeSpan 2d1b567388
Update Tutorials.md 2024-03-09 17:26:05 -06:00
Gregg 7a58a20de1 Created Example 21 - AccessoryIdentifier 2024-03-09 15:07:31 -06:00
HomeSpan 04a10309c2
Sync on-line documentation (#802)
* Update NOW.md

* Update Solutions.md

* Update Solutions.md
2024-03-09 08:59:21 -06:00
HomeSpan 0f10d9354d
Merge pull request #799 from HomeSpan/master
Update Dev with Master
2024-03-05 06:03:22 -06:00
HomeSpan 1510718e65
Update Solutions.md 2024-03-05 05:58:15 -06:00
HomeSpan d441f81548
Update Solutions.md 2024-03-04 20:49:58 -06:00
Gregg be893b0968 Update DEV_Blinker.h 2024-03-04 06:04:13 -06:00
Gregg 38e0b1efea Bug-fix in SpanPoint that caused a crash when receiveSize=0
When printing SpanPoint configuration data to the Serial Monitor info using the 'i' CLI command, HomeSpan did NOT check to see if the receiveSize was zero, in which case there would be no queue, which caused a crash when trying to report the queue depth.   Since all existing SpanPoint examples were based on receiving data from remote devices, this bug was never encountered (since the receiveSize was always greater than zero).

Fix: check to see if receiveSize==0.  If it is, do not retrieve queue depth, but report zero instead.
2024-03-03 17:27:45 -06:00
Gregg e3e0b11717 Converted HKDF from struct to simple functions in HKDF namespace
Eliminated the need to instantiate a static HKDF structure within HAPClient since there is no storage within HKDF itself, just a single function call (create).
2024-03-02 16:02:16 -06:00
Gregg 24f36bbccb Moved all NVS Handles into Span
Also added Span constructor that call nvs_open for each nvs_handle upon start-up instead of waiting for homeSpan.begin() and HAP::init()
2024-03-02 15:49:06 -06:00
HomeSpan 3bb9df4818
Update README.md 2024-03-02 12:16:31 -06:00
HomeSpan 6011d09e8d
Update Reference.md 2024-03-02 12:02:58 -06:00
Gregg 0d404ccf1b Fixed bug in setPairingCode() and added second "internal" argument
homeSpan.setPairingCode() operates silently if called from within a sketch, but will report error to Serial Monitor and HALT sketch if code is invalid.

Otherwise, if called from 'S', or from AP, or as default during start-up, diagnostics are printed as usual and sketch will NOT halt if invalid code is provided
2024-03-02 11:57:40 -06:00
HomeSpan c17fabe326
Update Pixels.md 2024-02-29 18:36:58 -06:00
Gregg 959e3cbcde Update Pixel.cpp 2024-02-27 06:17:46 -06:00
HomeSpan b6c479eafc
Update Pixels.md 2024-02-26 06:50:09 -06:00
HomeSpan 8aec89c0fd
update dev (#787)
* Update README.md

* Update Solutions.md

* Update FAQ.md

* Update FAQ.md

* Update Solutions.md

* Update Solutions.md

* Update Solutions.md
2024-02-26 05:59:38 -06:00
Gregg e708d1d148 Update Pixel.ino 2024-02-25 22:19:35 -06:00
Gregg c16e0612be Added Pixel::isRGBW(), and added Other Example -> PixelTester sketch
Also flagged the original constructor, Pixel(int pin, boolean isRGBW), as being deprecated, though it will still work as expected.
2024-02-25 21:53:33 -06:00
Gregg a0bf2c8c8a Removed setColorMap and replaced as second parameter to Pixel constructor
Provides for full backwards compatibility with previous constructor.
2024-02-25 17:21:52 -06:00
Gregg 0cf12f3331 Completed Pixel::setColorMap() 2024-02-24 20:51:45 -06:00