Commit Graph

111 Commits

Author SHA1 Message Date
Gregg 78ddd8a330 Updated Examples 18 and 19
All tutorial examples now updated and confirmed working s expected in ios15.4.1 except for Example 17 (Shower).  DEV_Identify.h removed from all examples and optional AccessoryInformation() Characteristics deleted to make examples easier to use and understand.

To Do: Review and update "Other Examples" and add link to Example 19 in Tutorials.md
2022-04-12 22:14:29 -05:00
Gregg 2b669022ec Updated Example 17 with note to indicate it is not functioning correctly
This appears to be a Home App problem.  The problem cannot be fixed by adding in ServiceLabel and ServiceIndex (no impact), nor adding in isConfigured(), nor adding Name() Characteristics.  The Home App refuses to render the valves regardless of what valve type.  They will sometimes appear, and then disappear from the interface for no reason.

Testing with the Apple's HomeKit Simulator yields the same symptoms.
2022-04-12 21:36:00 -05:00
Gregg f322f2b0f1 Updated Examples 14-17 2022-04-10 16:04:36 -05:00
Gregg c2a43eca55 Updated Examples 12-14 2022-04-09 18:51:22 -05:00
Gregg 9241398f9b Updated Examples 1-11
Completely replaced Example 11, which showed how to use setPrimary() since this no longer seems to have any impact on HomeKit.  Changed sketch name from ServiceOptions to ServiceNames.
2022-04-09 18:17:59 -05:00
Gregg ac0344ebb2 Updated Examples 9 and 10 2022-04-08 18:06:46 -05:00
Gregg d20df43a58 Eliminated HAP Protocol Service and updated Examples 1-8
Experimentation reveals that the HAP Protocol Information Service no longer seems to be required by HomeKit.  Examples work fine without it.
2022-04-08 17:46:33 -05:00
Gregg 4ada3542cd Update 07-AccessoryNames.ino 2022-04-06 06:21:42 -05:00
Gregg 98f812ba0c Updating examples 1-7 to conform with latest iOS changes 2022-04-04 06:13:30 -05:00
Gregg 91f6ecb958 Updated Message Logging Example 9
Added LOG0() and variadic LOG1() messages.

Also needed to rename Accessory from "On/Off" to "On-Off" since HomeKit no longer allows "/" characters!
2022-04-03 07:21:43 -05:00
Gregg db3bea3b5c Completed Example 19 - Web Logs
Also updated SpanWebLog::addLog() so that the log message is also output to the Serial Monitor if the HomeSpan Log Level is set to 1 or greater.

To do: DOCUMENT ALL THIS!
2022-03-06 09:25:17 -06:00
Gregg 1be40ad6fc Converted LOG1() and LOG2() to variadic macros!
If LOG1() or LOG2() is only provided with a SINGLE argument, then Serial.print() is called.  This allows you to continue using LOG1() and LOG2() to directly print any variable or object that is handled by Serial.print(), such as an int, double, or even an IPAddress.

If LOG1() or LOG2() is provided with multiple arguments, the first is considered the format and Serial.printf(format...) is called.  This allows you to use printf-like functionality within LOG1() and LOG2().
2022-03-06 07:48:12 -06:00
Gregg 682e65129d Added new Example #19 showing Web Logging
Based on Example 5 (Two Working LEDs)
2022-03-05 23:08:14 -06:00
Gregg f37889f8da Added ClientIP as permanent part of Web Log ; DELETED homeSpan.getClientIP()
ClientIP will show as "0.0.0.0" if log message is not related to client request
2022-03-05 22:24:23 -06:00
Gregg cf22ff1a92 Added homeSpan.getClientIP()
Gets IP address (as char *) of last client to send a request.  Useful as part of web log messages.  Will return 0.0.0.0 if used outside of any code that is responding to a client request.
2022-03-05 22:06:34 -06:00
Gregg ad11016b28 Completed Example 18 2021-06-13 21:56:39 -05:00
Gregg e94a9bba04 Updating Example 18; and set HomeSpan version to 1.3.0 2021-06-13 18:40:54 -05:00
Gregg c7d82f74c6 Logic added to save setVal() status changes in NVS
Also created new Example 18 demonstrating NVS storage for an LED.
To do: Create CLI command to erase stored characteristics.
2021-06-13 10:55:06 -05:00
Gregg 54f7928204 Fixed bug in Example 13
WindowShade was incorrectly sending repeated event notifications to HomeKit!
2021-03-21 12:37:12 -05:00
Gregg 451a2885b1 Changed PwmPin to LedPin in all Tutorial Examples
Greatly simplifies use interface.  No need to specify or save channels.  And no need to even save pin number since that can be found using LedPin->getPin() method whenever needed.
2021-03-21 09:54:57 -05:00
Gregg a89ddf3748 Updated Example 13 - Window Shade to show proper use of Characteristic Current Position
Also added discussion of why Characteristic Position State is not needed even though it is required.
2021-03-12 09:45:50 -06:00
Gregg 53268127be Updated Examples to use `setRange()` instead of `new SpanRange()`
setRange() is preferred method.  SpanRange() is legacy only
2021-03-07 17:39:42 -06:00
Gregg ff0dfefc47 Added check to ensure initial value of Characteristic is in allowable Range
Check is not applied to STRING Characteristics.  Check is performed at end of each Accessory definition so will account for any changes to min/max as a result of calls to setRange().  If initial value is outside allowable range, a WARNING (not an ERROR) is thrown.
2021-03-06 09:08:57 -06:00
Gregg 3b40aeec74 Added check to throw error is setRange is called twice on same Characteristic 2021-03-06 08:30:09 -06:00
Gregg 26a38b68cc Completed full implementation of setRange() and deprecation of SpanRange()
Next TO DO:  Complete entry of default min/max into all Characteristics (except BOOL and STRING) defined Span.h so that setRange() error checking works for all Characteristics.
2021-03-04 07:18:13 -06:00
Gregg 5c5361be7b Moved UVal back into SpanCharacteristics 2021-03-03 19:53:13 -06:00
Gregg 6f589af43a Update DEV_Sensors.h 2021-02-23 09:56:45 -06:00
Gregg 396e3322a9 Update DEV_Sensors.h 2021-02-23 06:43:41 -06:00
Gregg 3edc30222f Updated Example 12 to demonstrate negative temperatures
Use SpanRange() to change HAP default range of 0-100 to -50 to 100.  Change starting temp +30 and have it reset to -30 after hitting +35.
2021-02-22 20:27:42 -06:00
Gregg c52ae7bdfe Update 17-LinkedServices.ino 2021-02-15 20:38:32 -06:00
Gregg 2e3f90851a Create 17-LinkedServices.ino 2021-02-15 19:40:07 -06:00
Gregg b8d4940772 Removed use of LED_BUILTIN in library and all examples
LED_BUILTIN is NOT defined for all ESP32 boards - some do not have a built-in LED!  Instead, Status LED now defaults to Pin 13, as opposed to LED_BUILTIN.  Also, added a new method, homeSpan.getStatusPin(), to return the pin number used for the Status LED, whether or not it remains the default (13) or is changed by user with homeSpan.setStatusPin(pin).  This method is now used in the DEV_Identify.h file for each example, instead of using LED_BUILTIN (which otherwise won't compile for boards without a built-in LED)
2021-01-09 12:51:35 -06:00
Gregg 8dc8a0bc48 Update 01-SimpleLightBulb.ino
Changed comments to reflect requirement that AccessoryInformation Service be defined before any other Services in an Accessory.
2020-12-27 12:58:00 -06:00
Gregg 69057d560a Converted `char *` to `const char *` in DEV_Identify() 2020-12-27 09:38:12 -06:00
Gregg 5468f8e89e Set architecture=esp32 in library.properties.
Also fixed some comments in Example 15.
2020-11-27 23:21:43 -06:00
Gregg 5585765a48 Updated comments in some examples. 2020-11-23 08:33:39 -06:00
Gregg 2a7ae8cf78 Update 06-DimmableLED.ino 2020-11-21 22:24:05 -06:00
Gregg bca25b6a72 Updating docs 2020-11-14 16:13:37 -06:00
Gregg b6c5a6b68d Added License Info to all files 2020-11-02 20:09:09 -06:00
Gregg d45f210c5b Completed comments for Example 16 and confirmed all functionality. 2020-11-01 21:10:35 -06:00
Gregg c153824b95 Updated SpanButton Examples
And re-worked the logic in Example 15 to make full use of DOUBLE press functionality.  To Do:  Add commentary to Example 16.
2020-11-01 15:22:16 -06:00
Gregg e2f11630fa Updated SpanButtton to recognize new Double Press event
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!
2020-11-01 12:21:34 -06:00
Gregg f0f761c143 Extended Exmaple 16 to use two Stateless Programmable Switches
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.
2020-10-31 15:53:06 -05:00
Gregg 3979498b3c Created Example 16 - Programmable Pushbutton
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.
2020-10-31 09:35:42 -05:00
Gregg 22962ebfe3 Moved Zephyr into a standalone repository; Re-organized tutorials
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
2020-10-04 11:00:08 -05:00
Gregg b06dadc6a1 Updated commentary in Example 15 to reflect new logic for LONG presses
Changed commentary to explain that Long Presses do NOT need to have the button released, AND a LONG press will repeat if the button is held.
2020-10-03 19:33:01 -05:00
Gregg 7ecff55f9c Updated PushButton() so that longPresses always repeat
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.
2020-10-03 12:02:57 -05:00
Gregg 77c48dcf46 Updated SpanButton to use Utils::PushButton
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.
2020-10-03 10:45:01 -05:00
Gregg 0a5cf52569 Modified Service::update() to return boolean instead of StatusCode
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.
2020-10-01 21:41:26 -05:00
Gregg 301c7dc652 Updated Example 9
Change VERBOSITY to new setLogLevel() framework.
2020-09-28 18:47:09 -05:00