Made Characteristic::PositionState **optional** for Service::WindowCovering. This appears to be a bug/exception in HAP-R2. Need to reflect this in on-line docs.
* if Accessory ID is NOT specified, the default is aid=1+aid of last Accessory, with aid of very first Accessory always set to 1.
* aid of first Accessory must ALWAYS be set to 1 - if user over-rides with another value, error will be thrown
* validation now includes checking for duplicate aids, as well as ensuring the first Accessory is always aid=1
If not specified, "aid" defaults to an index number representing the order in which the Accessories were created. Values are stored as uint32_t (which is more limited than HAP requirements of uint64_t, but makes the code easier).
TO DO: Must add validation to ensure duplicate aid values are not used.
button(int pin, boolean isLong) changed to button(int pin, int pressType), where pressType can be SpanButton::LONG, SpanButton::SINGLE, or SpanButton::DOUBLE. Updated Example 16 and confirmed everything works as expected.
To do: Review all prior examples and update SpanButton when needed. Also need to update Zephyr Vent Hood code!
Added ServiceLabelIndex Characteristic, which seems to be required as noted in HAP specifications. However, linking to a ServiceLabel Service does not appear to be required, so there is no need to build any Service-Linking logic into homeSpan - will wait for use-case to be identified.
To do: Add support for double-click to SpanButton, then include in Example 16.
Modified SpanCharacteristic::sprintfAttributes to streamline logic and add special handling for the ProgrammableSwitchEvent Characteristic as required by HAP: the value returned for the database or any read request must be set to null (i.e. "value":null). The only time the real value should be returned is when the device sends a EV/Notify message (when the button is pressed). Verified that the example works as expected!
TO DO: Add functionality to allow for Service Namespace and Index label so that you can have multiple programmable pushbuttons in one service - this requires logic for HAP LINKED SERVICE functionality.
To do: Create special-handling code for ProgrammableSwitchEvent Characteristic (according to HAP, it has read permission, but must always return a null). Consider adding special flag to PR+EV
Added validation to ensure all Accessories have a AccessoryInformation Service and all Accessories have a HAPProtocolInformation Service, unless the device is configured as a bridge, in which case only the first Accessory requires a HAPProtocolInformation Service.
Checks to ensure that: (A) Characteristic is allowable (i.e. either required or optional) for the defined Service, and (B) Characteristic has not already been instantiated for the defined Service.
Completed macro to use HAPCharType for define Span Characteristic structures. HAPCharType includes name, ID, and permissions. The macro adds value type (e.g. int, double) and default value. To do: Create Span Characteristics for all remaining HAPCharTypes defined in HAPConstants.h
Created HAPCharType and added vectors for required and optional characteristics to every service. Next up: add all HAP characteristic types to HAPCharType
This prevents re-visits to the landing-page that resets the statusLED every time. Also eliminates the need to keep track of when landing page is accessed and to perform any initial re-direction.
Ensures statusLED indicates a client is connected as soon as it received its first GET, even if the re-direction to /landing-page is yet to be accessed. This was needed to trigger LED_AP_CONNECTED when connecting with QR code.
The 'A' command now resets any existing WiFi functionality so that it can start an Access Point without needing to first reboot.
To Do: Add a method to cancel out of apConfigure() and reboot by pressing control button.
To Do: Create time-out for commandMode()
Changing code so that it is possible to run HomeSpan without configuring WiFi. HomeSpan can already run without being paired, but requires WiFi at start-up. No reason to force WiFi to be used if device has buttons to operate the appliance withouth the need for WiFi or a connection to HomeKit. Work in progress...
Instead of pre-defining RF433 and RF315, the user should define their own RFControl{pin} as a variable in their device-specific DEV_*.h file. Makes RFControl more generic and not specific to any transmitter name (such as 433 or 315). Also means that the pin can be set by the user instead of having to modify RFControl.h deep in the library.
Zephyr3, the latest version, was moved into its own repo and renamed ZephyrVentHood.
Deleted Zephyr1, Zephyr2, and Zephyr3, which are no longer needed.
Flattened folder structure for Examples and placed them all in top-level directory
Started adding lists to the first few Services in Service.h. This is a longer-term project to enable HomeSpan to validate a configuration and check that all Services have all required Characteristics and that any optional Characteristics defined are indeed permitted.
Full initialization now depends on "isInitialized" flag instead of monitoring Wifi connection, to protect against a loss of WiFi causing a re-initialization, instead of just a wifi reconnect with initWifi() alone.
No need for any new methods - default is now that longPress repeats every longTime milliseconds provided button continues to be held down. Once a longPress is triggered, a shortPress will not be triggered until button is released.
SpanButton now instantiates PushButton instead of keeping track of its own triggering logic. This means that SpanButton longPress() is triggered by holding down the button for longTime WITHOUT the need to release. This is a desired change.
Next: Must update Example 15 to state that SpanButtons trigger a long press withouth needing to be released.
To do: Consider adding a "repeating mode" for longPress in which the SpanButton re-triggers every longTime while button continues to be pressed. Best way to implement is probably by creating a PushButton::extend() method.
Also moved StatusCode definitions from Settings.h to HAPConstants.h. There was no reason to have the user return a StatusCode of OK or UNABLE from update() since the only other choice was BUSY and HomeKit does not seem to distinguish errors. Either it's okay or not okay, which can more easily be represented by a simply return of TRUE or FALSE from update().
The user now needs to know nothing about StatusCodes. All Examples were modified to change StatusCode update() to boolean update() and return(StatusCode:OK) to return (true).
Much simpler.
Convention is that every *.cpp references, in this order:
1) Any required core librries
2) Its own *.h (i.e. Foo.cpp -> Foo.h)
3) All other *.h files needed by the cpp, UNLESS those *.h files are already in its own *.h file. Must include all *.h files that are not in its own *.h file even if it is others that are referenced.
This change allows the user to set the log-level with homeSpan.setLogLevel() instead of needing to change in Settings.h. Next up: Update Example that introduces VERBOSE to instead use setLogLevel(). Consider adding an interactive 'L' command to change this during run-time.
Also, added "#pragma once" to every *.h file to prevent duplication of definitions. TO DO: Review all #include to ensure sanity across all files.
These optional methods can be "chained" when instantiating a new SpanService to configure the Service as Primary or Hidden (or both). This alleviates the need to ServiceType to be propogated through the Service constructor.
Next Up: Eliminate ServiceType construct and update Examples to use setPrimary instead.
Created separate init() methods for PushButton and Blinker. Created HomeSpan:setControlPin and HomeSpan:setStatusPin that can be called from main setup() to modify the defaults. All default settings being migrated to Settings.h
Next Up: Add method to break out of WiFi connection loop by using push button in case WiFi SSID/PWD has changed but there is no desire to unpair controllers. To Do: Move blinking status light setting to named macros.
Setup Code now saved after serialConfig() or apConfig().
Next up: Create 'U' command to unpair controller. Change function of control button so it unpairs (short press) or resets WiFi (long press).
To do: Revisit statusLED blinking paterns to make sure they are clear and consistent - save them as macros in settings.h
Verified all functionality works as expected. Next Up: Add this code to both serial and AP network configurations. To Do: alter 'H' command so it removes controllers (unpairs) but retains HAP ID and other data. - perhaps make this 'U' command?
And updated other SRP routines to complete implementation of use of stored verification code instead of live setup code.
Next up: Add method to change setup code in serial interface and implement similar code after network configuration routines.
This generates an SRP verification code from a setupCode and randomly-generated salt. Function creates the salt internally and returns both the resulting verification code and salt that was used. These are stored in NVS permanently.
Next Step: create SRP6A:loadVerifycode()
Move all configuration code into Network.cpp, eliminating any calls or connection to HAP.cpp. Network.cpp is now standalone for HomeSpan.cpp to call directly to handle ALL apects of WiFI and Setup Code initialization.
Also move TempBuffer from HAP.h to Utils.h so it can be used by Network.h
Allows for reset of HAP (press for 5 seconds, but less than 10) or Factory reset (press for 10 second). Use setResetPin to change from default of pint 21.
Generic blinking class for LEDs that uses Alarm Timer interrupts that work in background. Will be used to replace and extend HAP blinking of Builtin_LED to convey status of HomeSpan at varioud points in the code.
This is no longer needed since PushButtons can be easily emulated from within a Service loop() as per Example 14. Library is now fully up-to-date: TimedResets and SpanEvents have been fully removed.
AND updated Example 13 to reflect new loop() framework in place of SpanEvents. ALSO found a bunch of inconsistencies with WindowCovering HAP documentation. PositonState and HoldPosition are NOT used by HomeKit. However, HomeKit has a full slider for controlling shades which makes a Hold Button no longer needed. See Example 13 for details. Open to do: add commentary to Example 13 and eliminate SpanEvents from library!
Completed new framework for using loop() methods and deleted all code related to new SpanEvent() and event() loops. Re-worked Example 13 to utilize new framework and validated it functions as expected.
Service loops() called for only those Services with over-ridden loop() methods. TO DO: update event logic to follow new framework. Vector should point to all CHARACTERISTICS that are updated to setVal()
This check all timed write PID/TTL entries and clears all those that are expired. This completes the implementation of Timed Write functionality as required for PUT /prepare requests.
Added detailed notes section to further explain all processes related to Event Notifications. Foreshadowed next example, which will be a Service supporting current and target state characteristics.
converted checkedTimeResets() from two-pass logic that first computes the required size of SpanBuf to a single-pass that utilizes vector<SpanBuf> instead. Much cleaner and easier.
checkEvents() now allows for multiple characteristics to be updated by service->notify(). This change included the use of vector<SpanBuf> to dynamically create the the temporary storage needed. To do: re-work similar routines to use vector<SpanBuf> instead of needing to perform two passes each time to gauge size of SpanBuf array needed.
creating code to allow for multiple characteristics to be updated within event() call. To Do: define anogther sensor that supports multiple characteristics. also need to check that "new SpanEvent" works as expected from within a defined service.
putCharacteristics and checkNotifications now both call the same eventNotify routing. This is being done to prepare for services that will stream notifications back to client (like a temperature sensor, or pushbutton). TO DO: rename checkNotifications to check TimedResets, and rename SpanPut to something more generic.
Transtioned to all getter methods: getVal(), getNewVal(), updated(), using templates for all floats.
Finalized templates for getVal and getNewVal, including making <int> default so it does not have to be set for most getVal() and getNewVal() calls. Works for booleans as well. TO DO: Re-work and check ALL prior examples to ensure they use getVal, etc., and DON'T access value, newValue, isUpdated, directly.
Allow for any characteristic that is not read-only, which should leave out all string characteristics.
Upon reset, zero out all 8 bytes of UVal memory, instead of simply setting UVal.BOOL to false. This allows use of TimedReset for any characteristic with a numerical value.
Updated SpanRange to register itself automatically to the most recent Characteristic. This is more consistent with the overall framework and no longer requires user to access the range variable directly.