Commit Graph

1900 Commits

Author SHA1 Message Date
HomeSpan 173ba036f0
Update TLV8.md 2024-04-20 09:05:43 -05:00
HomeSpan 15a0396897
Update TLV8.md 2024-04-20 08:00:19 -05:00
HomeSpan cd3b525dbb
Update TLV8.md 2024-04-20 07:54:41 -05:00
HomeSpan f96721b948
Update TLV8.md 2024-04-20 07:23:18 -05:00
HomeSpan 520a4f3df0
Update TLV8.md 2024-04-19 22:05:02 -05:00
HomeSpan 9b0555d256
Update TLV8.md 2024-04-19 12:58:43 -05:00
HomeSpan b05be87a29
Update TLV8.md 2024-04-18 22:20:58 -05:00
HomeSpan dfec533212
Create TLV8.md 2024-04-18 21:06:47 -05:00
HomeSpan 04443d70dd
Update Reference.md 2024-04-18 20:59:55 -05:00
HomeSpan 2ecbed9f26
Update Reference.md 2024-04-18 18:21:02 -05:00
HomeSpan 6794a804f9
Update README.md 2024-04-18 17:59:31 -05:00
HomeSpan 64f67fbb8a
Update Reference.md 2024-04-18 07:04:13 -05:00
HomeSpan bb531184d7
Documents resetIID(), Service::getIID() and Characteristic::getIID() 2024-04-18 06:43:58 -05:00
Gregg d1dd565478 Converted IID from int to uint32_t everywhere 2024-04-17 07:24:08 -05:00
Gregg 723c343277 Added error checking to warn if non-bridge device defines more than 3 Accessories
It appears that HomeKit requires devices with more than 3 Accessories to be configured as a bridge.  If not, the Home App will ignore any functional Services in the first Accessory and treat it like a bridge regardless.  Device with 3 or less Accessories do not require a bridge configuration.
2024-04-16 22:17:00 -05:00
Gregg b9efa873dc Added error-checking for homeSpan.resetIID()
HomeSpan will throw a Warning when 'i' CLI command finds a duplicate IID within the same Accessory.
2024-04-16 21:56:07 -05:00
Gregg fe3269e9ef Added new validation check for homeSpan.resetIID()
New value must be equal to, or greater than, the last IID value used.  This prevents possible re-use.
2024-04-15 22:14:05 -05:00
Gregg 73561328e6 Changed TLV8:add() for *values* to ensure resulting size is always multiple of 2
Checked that this is correctly interpreted by HomeKit using adaptive light TLV.

TLV code is now ready for documentation and then transfer to dev branch.
2024-04-14 21:29:02 -05:00
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