Commit Graph

566 Commits

Author SHA1 Message Date
Gregg e3b9ed99cb Added homeSpan.setTimeServerTimeout(uint32_t tSec);
Sets timeout when connecting to Time Server (default is 10 seconds if not specified)
2022-03-05 20:35:01 -06:00
Gregg 2787966c48 Converted webLog.addLog() to variadic form
Also created WEBLOG() variadic macro
2022-03-05 18:13:27 -06:00
Gregg d9a9e6f31c Changed webLog in HomeSpan from pointer to instantiated variable
Added isEnabled to SpanWebLog to indicate whether Web Log has been enabled.  This allows the use of homeSpan.webLog.addLog() without ever enabling (in which case the log entries are ignored).
2022-03-05 12:50:20 -06:00
Gregg acc64f863a Added addLog(const char *) to SpanWebLog()
Also included logic so that clockTime is set to "Unknown" is addLog() is called prior to WiFi being established.

Next up: replace addLog(const char *) with a variadic set of parameters with dynamic storage allocation.
2022-03-05 10:40:01 -06:00
Gregg 168be05586 Progress on SpanWebLog() 2022-03-05 10:03:13 -06:00
Gregg 91ab626d6c Update HomeSpan.h 2022-03-04 06:15:48 -06:00
Gregg b6c019d1a8 Finished Time Stamping - Started Web Log Structure 2022-03-03 21:37:20 -06:00
Gregg 20ce79ef34 Added check to ensure time server is available
If not, homeSpan.timeServer is reset to NULL
2022-03-02 21:41:06 -06:00
Gregg 571bc55852 Added optional homeSpan.setTimeServer() method
If specified, HomeSpan will try to get internet time after establishing WiFi connection.  Consumes one socket connection.
2022-02-27 18:29:58 -06:00
Gregg ae4b6e8df1 Initial creation of getStatusURL() web log
Built basic framework to response to "GET /status".  Next up:  Add timeclock.
2022-02-27 18:04:12 -06:00
Gregg 170e0b61b1 Add new macro CUSTOM_SERV() to created custom services
Also, updated error checking so that the UUID for both custom Services and custom Characteristics are checked for syntax.  A fatal error is thrown if an ill-formatted UUID is found, since this will definitely prevent pairing with the HomeApp.

The UUID for HAP Services and Characteristics are NOT error checked, since these are fixed in HomeSpan.

Also, the custom Characteristics are not validated against the optional list for a service.  If the user adds a custom Characteristic to a HAP Service, it is assumed to be valid.  Similarly, none of the Characteristics (HAP of Custom) in a Custom Service are validated at all.
2022-02-27 09:51:27 -06:00
Gregg bf2e1354b1 Added second version of SpanUserCommand() that takes a void *arg
Useful for passing a pointer to a Service that can be used in the CLI command.
2022-02-22 21:53:17 -06:00
Gregg ea09e5c8f3 Create FeatherPins.h
For developer use only - facilitates testing the same code across an ESP32, ESP32-S2, and ESP32-C3 without re-wiring by using an Adafruit FeatherBoard as a common jig.
2022-02-21 15:08:19 -06:00
Gregg 02d841390c Updated License Dates 2022-02-20 13:05:03 -06:00
Gregg 7bfc1d48fb Updated version to 1.5.0 2022-02-20 12:09:03 -06:00
Gregg b141a83630 Update extras.ino 2022-02-19 18:29:34 -06:00
Gregg a83d3a7fda Added static HSV and RGB color methods to Pixel() and Dot()
Updated Pixel example to demonstrate use of the static HSV method
2022-02-17 18:27:31 -06:00
Gregg a4fb99a684 Updated Pixel Example 2022-02-13 11:57:34 -06:00
Gregg eee0eb6954 Embedded HSV and RGB methods inside Color object
Makes coding with Pixel() and Dot() easier
2022-02-12 15:31:55 -06:00
Gregg c40c744702 Small modification to status message 2022-02-11 09:24:51 -06:00
Gregg ac88329d34 Deprecated setMaxConnections(); Added reserveSocketConnections()
Use homeSpan.reserveSocketConnections(n) to reserve n sockets *not* to be used for HAP.  Multiple calls can be used to cumulate a total number of reserved sockets.  This makes is easy to add reserveSocketConnections(n) at multiple point in the code whenever a certain number of sockets need to be reserved for use with that portion of the code.  For example enableOTA() calls reserveSocketConnections(1).

If both setMaxConnections(), and one or more reserveSocketConnections(), methods are called HomeSpan will use the more restrictive net value.
2022-02-10 21:55:03 -06:00
Gregg 4973d1aaa1 Revert "Initial coding of protectPinISR(pin) method"
This reverts commit 852a916d61.
2022-02-10 21:09:42 -06:00
Gregg 32b417a1da Added homeSpan method deleteStoredValues()
Provides a programmatic way of deleting all stored Characteristic values from NVS.  Identical to the 'V' CLI Command.
2022-02-10 21:02:10 -06:00
Gregg f955ff689b Added homeSpan.setPairCallback() method
Callback function must be of type void()(boolean isPaired).  Will be called when device is paired and when device is unpaired.  Allows for user-defineable actions upon device pairing/unpairing.
2022-02-06 08:39:47 -06:00
Gregg 9e40666231 Added Pixel() and Dot() operator overloads to Color struct
Color now supports a==b, a!=b, a+b, a-b, a+=b, and a-=b operators
2022-02-05 23:30:28 -06:00
Gregg acdcab1132 Verified Pixel() and Dot() classes work on ESP32-C3 2022-02-05 16:24:01 -06:00
Gregg d0a13e5417 Updated Pixel() class to use more streamlined methods implemented in Dot() class
Pixel() and Dot() classes are now complete.  Tested DotStar RGB, NeoPixel RGB, and NeoPixel RGBW, all running at same time on a single ESP32.

Next up: Must update Pixel Example as well as Holiday Lights Project
To Do: Add documentation page for Pixel() and Dot()
2022-02-05 12:35:01 -06:00
Gregg a21cc0679d Add two-wire addressable DotStar RGB LEDs to Pixel.h
Pixel.h now contains Pixel() and Dot() classes.
Dot() class uses more streamlined methods; must next update Pixel() to use similar methods, which will allow Pixel and Dot to be more "interchangeable".
2022-02-05 09:17:56 -06:00
Gregg 852a916d61 Initial coding of protectPinISR(pin) method
Works for all NVS calls in homeSpan.h.  To Do:  Add logic to all other NVS calls.
2022-01-30 22:33:07 -06:00
Gregg d2bbd4f56c Added logic for RGB vs. RGBW
Tested with original 8-pixel RGB and 60-pixel RGBW.  Works as expected.
2022-01-29 18:26:17 -06:00
HomeSpan 877f47a64d Split RFControl constructor into public and private versions
Private constructor only used for Pixel, which is friend class of RFControl
2022-01-27 21:41:05 -06:00
Gregg 4588669cd2 Added ARDUINO_VARIANT (type of board) to MDNS 2022-01-23 16:40:46 -06:00
Gregg 46820c66a2 Add Arduino-ESP32 version number to MDNS output 2022-01-23 15:00:12 -06:00
Gregg a09b8d0b85 Update Pixel.cpp 2022-01-22 07:18:19 -06:00
Gregg 95b41fd929 Revert "Update logic so Pixel uses only ONE channel and shares across all instances"
This reverts commit 4af3a22764.
2022-01-22 07:09:48 -06:00
Gregg 4af3a22764 Update logic so Pixel uses only ONE channel and shares across all instances 2022-01-21 21:56:51 -06:00
Gregg e060856b78 corrected an issue in loadData ISR that would cause a hang
Also updated Pixel example with Knight Rider Effect.
Testing on C3 seems to be working.  Must test on S2 and ESP32 next.
2022-01-20 21:01:31 -06:00
Gregg 4419a91bef verified functionality on ESP32-S2 2022-01-17 13:15:24 -06:00
Gregg fd3955f0c2 verified functionality on ESP32 original 2022-01-17 12:52:09 -06:00
Gregg b6d21fd2c0 streamlined identification of interrupt masks and memory size 2022-01-17 12:36:02 -06:00
Gregg 89f0d0dd94 verified works on C3 when either channel 0 or 1 is used 2022-01-17 11:30:55 -06:00
Gregg 5f513c4c34 updated 2022-01-17 08:25:26 -06:00
Gregg 79c028c057 moved loadData into interrupt 2022-01-17 07:16:31 -06:00
Gregg 40c05bd53f some more cleanup
Next up:  Move loadData into isrHandler, if possible.
To Do: redo single-color methods
2022-01-16 23:24:54 -06:00
Gregg 1a99df4214 check in progress 2022-01-16 23:14:12 -06:00
Gregg 46d7ade046 Re-doing Pixel class once again
This time using customized interrupts to fill RMT memory on-the-fly.

* Added getChannel() to RFControl
* Add 3rd, optional, boolean argument to RFControl(int pin, bool refTick, bool defaultDrive) to that RMT can be initialized but without the default driver (allows for use of custom interrupt code instead)
2022-01-16 14:16:52 -06:00
Gregg 6f4cea1b4d Updated version number to 1.4.3
Also updated Pixel example.
2022-01-10 22:52:08 -06:00
Gregg aefa737675 Completed "optimization"
Pixels now lets you reserve memory for pixels so that the call to start the RF transmission can be done for multiple pixels at once.  However, gain is not as much as expected.  May need to revisit if driving a large matrix of pixels is needed.
2022-01-08 17:28:43 -06:00
Gregg ee6c270de3 optimizing to allow for pulse train batching 2022-01-08 16:18:37 -06:00
Gregg 9d0c56799c Update extras.ino 2022-01-07 06:58:40 -06:00
Gregg 1b402b5ebc changed range of S and V to be 0-100 instead of 0-1
But still use float so that values of 50.3, 99.5, etc. are still distinguishable.
2022-01-07 06:25:11 -06:00
Gregg 3020b800a6 testing 2022-01-06 21:43:54 -06:00
Gregg f10f5cffcd Normalized and optimized Pixel methods
created color_t typedef and use as basis for all RGB and HSV methods
2022-01-06 21:15:03 -06:00
Gregg d5b27d6e14 Added ability to set same color on multiple pixels
Added 4th, optional argument, nPixels, to setRGB() and setHSV().
2022-01-06 18:09:22 -06:00
Gregg e8c7afae00 Increased default max number of connections to 14!
Reflects increase in max number of LWIP sockets from 10 (Arduino-ESP32 v2.0.0) to 16 (Arduino-ESP32 v2.0.1).  Since HomeSpan needs at least 2 (one for Server and 1 free for new connections), this leaves 14 connections for controllers.  A big improvement over only having 8!
2022-01-02 15:36:54 -06:00
Gregg 5d3a4bfc38 Added simple Pixel example to Other Examples 2022-01-01 08:14:32 -06:00
Gregg 12c283e8c3 Update Pixel.h 2022-01-01 07:14:30 -06:00
Gregg 368a06301a renamed sk68xx class to Pixel and made it generic
Constructor now allows you to specify high/low timings for 1-bit and 0-bit, as well as timing for reset delay.  Default parameters are included if none are specified.
2021-12-31 18:10:51 -06:00
Gregg 3b6bc13b1c Added setHSV() to sk68xx class 2021-12-31 15:34:20 -06:00
Gregg facba4c02a Added Pixel.h and Pixel.cpp and implemented SK68XX Addressable LED Class
Also add getPin() to RFControl (which is used by SK68XX Class) as well as boolean operator overrides for both RFControl and PwmPin/ServoPin so that instances can be checked for validity.
2021-12-31 14:51:42 -06:00
Gregg d667f5e81d Added homeSpan.setStatusAutoOff(uint16_t duration)
Optional method to automatically turn off Status LED after a *duration* seconds.  LED will resume normal operation any time it is re-triggered with a new pattern.  This also resets the elapsed time used to check for autoOff.
2021-12-26 23:07:37 -06:00
Gregg 8737efea14 Added setUnit(char *) as method to SpanCharacteristic
Optional method to add or override the units for a Characteristic (i.e., "percentage", or "celsius") as per HAP-R2 Table 6-6.
2021-12-23 22:28:26 -06:00
Gregg 3cc14c3a8d Addressed automation issue by extending true/false parsing
Added true/false parsing to all integer-based Characteristics.  Previously true/false was only parsed for BOOL Characteristics.  For integer-based on/off Characteristics, the Home App would send a 0 for off, and a 1 for on, consistent with HAP-R2.  BUT...when using Home App AUTOMATIONS, the Home App would send true/false for integer-based Characteristics, which is inconsistent with HAP-R2.  This meant automations worked with lights (that use the boolean ON Characteristic) but not with fans (that use the uint8 ACTIVE Characteristic).

With this "fix", true/false will be recognized all the time (except for float- and string-based Characteristics.  Confirmed that fans now work with Home App Automations.
2021-12-23 15:37:26 -06:00
Gregg 715adf44f1 Added setDescription(const char *) method to SpanCharacteristic
This allows you to add an optional "description" to a Characteristic.  This is not the same as the name of a Service and is generally not used by the Home App.  However, it appears to be consumed by the Eve app, which can be helpful in some circumstances when developing custom characteristics.
2021-12-17 06:44:27 -06:00
Gregg a872111743 Fixed bug in CUSTOM_CHAR() when applied to STRING Characteristic
Created a new CUSTOM_CHAR_STRING(NAME,UUID,PERMISISONS,DEFVAL) macro specifically for STRING Characteristics
2021-12-03 07:02:25 -06:00
Gregg bc5299cf57 Updated version number to 1.4.2
Ready for release!
2021-11-27 09:48:07 -06:00
Gregg 83170306f5 Updated Blinker class for compatibility with Arduino-ESP32 v2.0.1
The update from Arduino-ESP32 2.0.0 to 2.0.1 contained significant changes to the structures used by the IDF for generic timers.  This broke the Blinker code (would not compile for ESP32-S2 and C3 chips).

The solution: Modified Blinker::isrTimer() to use a *generic* interrupt-clearing function when available (IDF version >= 4.0.0).  Below 4.0.0 the code continues to manually clear the interrupt flag by resetting specific structure variables, though the logic is simpler since this is only needed for the ESP32 chip (the S2 and C3 are not supported in earlier versions of Arduino-ESP32).

This provides for full compatibility with Arduino-ESP32 versions 2.0.1, 2.0.0, and 1.0.6.  The use of a generic interrupt clearing function when IDF>=4.0.0 will hopefully make this future-proof to any further changes by Espressif to the underlying timer structures.
2021-11-25 10:03:57 -06:00
Gregg d8bb51902f Fixed Bug in TimedWrites
The loop over TimedWrites incorrectly erased iterators inside a for-loop.  For some reason this never caused an issue on the ESP32, but crashed on the ESP32-C3.  Solution is to change the for-loop to a while-loop with proper handling of the iterator when an element is deleted.  This appears to fix the problem.
2021-11-24 18:27:55 -06:00
Gregg 48b21df329 Created method setPairingCode(const char *s)
Allows for programmatic creation of Pairing Setup Code.  Not recommended, but added for a convenience - should use 'S' from CLI instead.
2021-11-12 18:01:27 -06:00
Gregg b5f4592b29 Removed Characteristic::ConfiguredNameStatic() end updated Television Example
Characteristic::ConfiguredNameStatic() is no longer needed since you can now change permissions on ConfiguredStatic to remove PW with removePerms(PW).  Updated Television Example accordingly.

To Do:  Add getLinks() and setPerms/addPerms/removePerms to API Reference Documentation
2021-11-10 05:54:19 -06:00
HomeSpan fcf715d874 Added getLinks() method to SpanServices
This returns a vector of linked Services that can be used in a for-each loop as such:

for(auto services : getLinks()){ ... }

Must cast services into specific Service type to access anything not generic to the SpanService   class
2021-11-09 21:18:34 -06:00
HomeSpan 3f833beb74 Added ability to change permissions for Characteristics
New methods for Characteristics:

setPerms(uint8_t perms);
addPerms(uint8_t dPerms);
removePerms(uint8_t dPerms);

where perms and dPerms = PR|PW|EV...
2021-11-09 21:08:52 -06:00
Gregg 6f765e8988 Added non-notify option to setVal()
Second optional argument to setVal() determines whether or not HomeSpan sends notification of new value to HomeKit.  Default if left blank is "true" for backwards compatibility.
2021-11-07 20:45:44 -06:00
HomeSpan 08c92f8eb0 Update Span.h
Make Characteristic::Identifier required for Service::InputSource
2021-10-31 17:20:56 -05:00
HomeSpan a53d98070c Update version numbers to 1.4.1 2021-10-30 22:06:02 -05:00
Gregg 226548defa Added check to ensure Custom Characteristic has valid UUID
And also converted ERRORS to WARNINGS when a Characteristic that is not in the REQ or OPT list is specified for a Service.   This allows the user to add any Characteristic to any Service without forcing an Error (just a Warning).
2021-10-29 22:54:10 -05:00
Gregg 61a2be533b Moved Range checking to a standalone routine checkRanges()
Ranges are now checked for all Characteristics at the end of the configuration, instead of at the end of each Accessory definition.  This is much cleaner and the output is easier to read.

To do:  Revisit use of REQ and OPT - what should constitute a fatal error and what should be a warning.

To do:  Revisit Character definitions - attempt to normalize using the methods implemented for Custom Characteristics
2021-10-26 22:05:44 -05:00
Gregg 65b15b5628 Added AID info to Set Range log message 2021-10-26 05:39:54 -05:00
Gregg 92c198d01a Update src.ino 2021-10-25 22:10:44 -05:00
Gregg b6001f9418 Update Span.h 2021-10-25 21:58:51 -05:00
Gregg eb9530800e Created typedef for HAP types - used to simplify CUSTOM_CHAR
No need to specify both FORMAT and TYPE.   For example, specifying UINT16 automatically sets type to be uint16_t.

To do:  Explore if this can be used for standard Characteristics - revisit standard Characteristics definitions and structure to see if it can be simplified.
2021-10-25 21:57:29 -05:00
Gregg eeb3c334ac Update src.ino 2021-10-24 21:24:45 -05:00
Gregg 4309be8f91 Finalized CUSTOM_CHAR() macro to add a custom Characteristic 2021-10-24 21:19:38 -05:00
Gregg d5fa8335fb Update src.ino 2021-10-24 20:58:45 -05:00
Gregg 96d74e5920 Adding Macros to allow for creation of custom Characteristics and Service 2021-10-24 18:45:46 -05:00
Gregg 37e0486cf7 Removed all unusable TV Characteristics from TV and Input Source Services
But retained the actual Characteristics in the Characteristics lists in the event that they may be activated in the Home App in the future.
2021-10-23 22:58:16 -05:00
Gregg 4eb1ebf806 Update HomeSpan.h 2021-10-23 13:21:21 -05:00
Gregg b90fc5aad5 Updated logic re STRING Characteristics
Added setString() as analog to setVal().  This complements getString and getNewString() which are analogs to getVal() and getNewVal().
2021-10-23 13:16:49 -05:00
Gregg dcbfbc3e15 Correct setVal() logic to properly check for EV permissions, not PW permissions 2021-10-22 09:17:26 -05:00
Gregg 8a24819955 Added Characteristic::ConfiguredNameStatic()
This "custom" Characteristic is identical to ConfiguredName() but only allows paired-read and notifications.  By excluding paired-write it prevents the user from editing the name of a TV input source from the Home App.  This is useful when some sources are fixed, such as "netflix" instead of generic, such as "hdmi 1".
2021-10-22 06:35:33 -05:00
Gregg 7c32f7a364 Fix bug in PushButton()
Ensure a pin value of -1 is retained so that any further calls to other methods are disabled if the pin is not defined.
2021-10-21 20:32:25 -05:00
Gregg d4603df58d Creating Television Example 2021-10-20 06:15:12 -05:00
Gregg 26c15c9ca2 Fixed strncpy() warnings
Changed strncpy() to strcpy() when copying new string values
2021-10-18 22:48:56 -05:00
Gregg f07fa4e9c7 Testing TV functions 2021-10-17 22:02:11 -05:00
HomeSpan 353749baea
Merge pull request #121 from unreality/master
add support for Televisions
2021-10-17 16:10:50 -05:00
HomeSpan 82d86001e2 Update extras.ino 2021-10-16 14:49:50 -05:00
HomeSpan 1566f93274 Update extras.ino 2021-10-16 11:33:49 -05:00
Gregg 760abae5ce Testing pronto codes 2021-10-16 08:16:22 -05:00
Gregg 5976fd3d0d Add enableCarrier(uint32_t frequency, float duty) and disableCarrier() to RFControl
Allows you to overlay a carrier wave on the RF Signal - in practice this is only used for IR signals (not RF).  Automatically scales frequency to account for 80x difference between APB Clock and Ref Tick Clock depending on which is used.   Checks to ensure resulting parameters (high period and low period) are all in bounds (0,65536) and reports an error if they are not.
2021-10-15 22:32:03 -05:00
Gregg 4ad607951f Add clock selection to RFControl (80 MHz or 1 MHz)
Added second argument to RFControl(uint8_t pin, boolean refClock=true) to allow choice of Ref Tick (1 MHz) clock or APB (80 MHz) clock.  Default is to use 1 MHz Ref Tick.

Also fixed bug in logic that divides clock for ESP32-C3.  Factor should be 79, not 80, since divider is apparently configured to divide by factor+1.
2021-10-15 18:16:18 -05:00
Gregg 5bced71345 Changed rf.add() and rf.phase() to allow for uint32_t durations
Instead of limiting number of ticks to 15-bits (32767), RFControl allows for tick size to be any 32-bit number.  If ticks > 32767, RFControl adds repeated LOW or HIGH phases as needed to match full duration.  This provides for much more flexibility in creating pulse trains that include very long-duration "spaces" between repeats.
2021-10-15 17:42:17 -05:00
Gregg 7d6265d543 Upgrade version number from 1.3.0 to 1.4.0 2021-10-09 08:12:29 -05:00
Gregg 7295803dde Remove LED_BUILTIN as default for statusPin
HomeSpan default is that there is NO control button and NO status LED.  Must use setStatusPin() or setControlPin() to enable.
2021-10-08 05:47:51 -05:00
Gregg 8236b6fb9a Marked old SpanRange() class as [[deprecated]]
This will cause a Warning (not an Error) at compile time indicating the class has been deprecated and that the Characteristic::setRange() method should be used instead.  Sketch will still run and SpanRange will still function correctly if used.  Will delete from code base at some point in the future.
2021-10-05 21:27:41 -05:00
Gregg 6de645216c CHANGED default settings for StatusPin and ControlPin
Re-worked code to allow for NO Status LED Pin and NO Control Pin.  If Control Pin is not set explicitly with homeSpan.setControlPin(), there will be no Control Pin.  There is no longer a default since there are too many board variations with S2 and C3 chips now supported.  Same for Status Pin - it will not be defined unless set explicitly with homeSpan.setStatusPin(), with the exception that if LED_BUILTIN is defined (i.e. there is a built-in LED), then the Status LED Pin will default to LED_BUILTIN if not explicitly defined.  MUST UPDATE DOCUMENTATION - THIS CHANGES DEFAULT BEHAVIOR OF HOMESPAN AND MAY REQUIRE UPDATES TO EXISTING SKETCHES
2021-10-05 21:10:24 -05:00
Gregg b95ebcb4fa Added ARDUINO_ESP_VERSION Macro
Will be "1.0.6", "2.0.0", etc.  Can be used as anywhere as a c-string
2021-10-05 20:08:34 -05:00
Gregg 56c09c44aa Updated Blinker again to ensure C3 compatibility
moved gpio_set_direction to start() method so that it is called every time needed in case another part of the program (i.e. DEV_Identify) calls pinMode() and resets the pin to a strict OUTPUT.
2021-10-05 06:32:19 -05:00
Gregg 0fd9424d79 Added Arduino-ESP32 Version Number to initial output 2021-10-04 21:14:16 -05:00
Gregg d82566158a Disabled watchdog timeout messages when running on ESP32-C3 2021-10-04 20:39:32 -05:00
Gregg 641e2ca955 Added check in RFControl to allow for backwards compatibility with Arduino-ESP 1.0.6
To do: Disable watchdog timer in ESP32-C3
2021-10-03 22:01:37 -05:00
Gregg ae1037946a Update Blinker() to fix inherent problem with digitalRead() in ESP32-C3
Pin must be INPUT_OUTPUT for digitalRead to work with ESP32-C3 (the IDF uses a new protocol for the C3).
2021-10-03 21:39:23 -05:00
Gregg 7980273609 Completed update of RFControl for ESP32-S2 and -C3 compatability
Testing completed for RFControl and PWM on all three ESP32 chip types.

To Do: update RFControl documentation to include total number of usable channels per chip, as well as the alternate version of start();
2021-10-03 18:08:07 -05:00
Gregg dc5844b520 Updated RFControl for compatibility with ESP32-S2 and ESP32-C3
Complete re-write of code.
2021-10-03 12:08:33 -05:00
Gregg 82ad33c98f Updated error-check for out-of-range PWM frequency (an ESP32-S2 check)
PWM has now been fully tested and verified with an ESP32 device under Arduino-ESP32 versions 1.0.6 and 2.0.0, and with an ESP32-S2 device under Arduino-ESP32 version 2.0.0.  Tests confirmed using both high (5000 Hz) and low (1 Hz or 5Hz) frequencies to ensure timers are correctly configured.

Next Task:  Update RFControl routines for 2.0.0 and ESP32-S2 compatibility.
2021-09-25 15:58:23 -05:00
Gregg 50bdfd7d37 Added better display of IDF Version 2021-09-25 14:41:20 -05:00
Gregg 0ea762b4a8 Added backwards compatibility to PWM to operate in 2.0.0 and 1.0.6
Accounts for new *required* elements of the LEDC channel and timer structures to be set in later versions of the IDF.  These elements are not available in earlier versions of the IDF and the program can't be compiled unless ignored.
2021-09-25 14:33:32 -05:00
Gregg 07da5ac924 Updated SRP code for 2.0.0 compatibility
Arduino-ESP32 has modified the Mbed TLS library so that it uses ESP32 hardware acceleration.  However, there is a 512-byte limit to the size of the variables used in an exponential modulo calculation.  One of the steps in the SRP code used a 768-byte variable, which cannot be handled in version 2.0.0 though it works fine in version 1.0.6.  Solution was to simply reduce the 768-byte variable by modulo N prior to performing the exponential modulo calculation.
2021-09-23 21:12:37 -05:00
Gregg 0dd341faa9 Update HomeSpan.h
eliminates -Wpmf-conversion warnings generated by our checks for override of update(), loop(), and button() methods
2021-09-22 05:31:46 -05:00
Gregg 5496503afd Added version info for sodium and mbedtls
Also, fixed "bug" in SRP route (did not impact function - just a generated less random numbers than expected).
2021-09-19 22:07:34 -05:00
Gregg 4da033195a Removing .DS_Store files 2021-09-19 14:04:16 -05:00
Gregg 61a87ccc63 Clean up PWM - ready for testing
To do: Test RGB LED Examples with ESP32 and ESP32-S2 boards.

Next:  Re-work Remote Control routines to make compatible with S2 and C3
2021-09-19 13:53:20 -05:00
Gregg 0ccb1d34a0 More updates to PWM to ensure S2 and C3 compatibility
New IDF parameter in 2.0.0 for LEDC allows PWM signal to be inverted!  Need to ensure flags.output_inverted is set to 0!

Also:  Deleted old PWM class, which was saved for backwards compatibility.  This "breaks" HomeSpan for those using the old PWM class (instead of LedPin).

Also:  Added checks to ensure that frequency is achievable (for S2 and C3, the 14-bit duty resolution is insufficient to allow frequencies slower than 5 Hz - this is  not a practical limit when using LedPin to drive actual LEDs and lights).
2021-09-19 13:39:40 -05:00
HomeSpan 7255a9530f Updating Extras to work through S2 and C3 issues 2021-09-18 16:28:56 -05:00
Gregg 8b33f61464 Update src.ino 2021-09-18 13:59:36 -05:00
Gregg c67336ab57 Updated Blinker logic to support S2 and C3
Needed to set clk_src to APB, else default is XTAL, which is only 40MHz clock!
2021-09-18 06:35:41 -05:00
Gregg 014def4c66 Fixed compiler complaint about pow() function.
AND added 2.0.0 only variable - see LED_USE_APB_CLK.
2021-09-15 20:05:15 -05:00
Gregg 6c9bf39f54 Added PWM diagnostic messages and chip-specific maximum duty resolution 2021-09-14 21:09:58 -05:00
Gregg 3ea8f956a5 Converted initial level of LedPin from uint8_t to float 2021-09-13 06:02:20 -05:00
HomeSpan 98a5a895cc Update PwmPin.cpp
Tested new functionality on RGB LED.  Works well with using floating point precision.
2021-09-12 16:19:10 -05:00
HomeSpan 60cb20f132 Completed update to PWM code
Should now work with ESP32-S2 and C3.  Allows for as many LEDs and Servos as there are channels and timers across low and high (esp32 only) modes. Allows LED to be set with floating point precession instead of just uint8.  Allows specification of LED frequency for each LED (1-65535 Hz).  Automatically provides maximum duty resolution for frequency chosen.
2021-09-12 15:17:27 -05:00
HomeSpan 0a0c536b6d Starting work on ServoPin update 2021-09-12 12:31:08 -05:00
HomeSpan a5d31b1ea5 Re-working PWM routines 2021-09-12 09:23:29 -05:00
HomeSpan 8d45e20671 Update Utils.h 2021-09-06 21:29:13 -05:00
HomeSpan 6088fb16fe Added logic to Timer code to allow for compiling under S2 and C3
With these changes the code compiles but nothing has been tested yet to see if it actually works under S2 and C3!
2021-09-06 12:35:26 -05:00
HomeSpan edf5522ca0 Addresses compiler warnings in Arduino-ESP32 2.0.0 2021-09-05 20:39:37 -05:00
Gregg 946819f3d4 updated setValidValues() to return pointer to self
Allows for chaining methods.
2021-09-05 09:14:21 -05:00
Gregg 6a74ce9283 Add setValidValues(int n, ...) method to Characteristic
Allows user to explicitly set the valid values for a Characteristic of type UINT8.  Throws an error if used with any other Characteristic type.
2021-09-05 08:54:34 -05:00
Gregg 2e9539a115 Fixed "space" bug in AP code
Fixed bug in which Access Point was not properly translating a '+' sign to a space when processing HTML forms.
2021-08-15 07:09:30 -05:00
Raal Goff fc9714ed95 ConfiguredName is writeable, allow writes to string characteristics when they have write perms 2021-08-09 19:41:31 +08:00
Raal Goff 86f99f696b allow 'value' property in characteristics updates to have whitespace 2021-08-08 09:27:25 +08:00
Raal Goff 586f690727 increase allowed range for Identifier characteristic 2021-08-07 21:46:16 +08:00
Raal Goff 38457c2b72 add HAP Services and Characteristics for Televisions 2021-08-03 21:43:32 +08:00
Gregg 36499f35ab Added ESP32 chip type, revision, memory, etc. to initial output 2021-06-26 18:35:28 -05:00
Gregg 2d36bb7a81 Update src.ino 2021-06-20 15:30:25 -05:00
Gregg 6d77e2559a Added setApFunction(); simplified enableAutoStartAP()
Simplified enableAutoStartAP() so it no longer takes any arguments.  It now simply enables the auto launch of the WiFi Access Point at start-up if WiFi Credentials are not found.

New method setApFunction() will now be used to set an alternative method for the WiFi Access Point.  This will be called anytime 'A' is typed into the CLI, which also covers the auto-launch of the AP at start-up a well as starting it via the Control Button, since both of these functions call processCommand('A').
2021-06-20 15:20:56 -05:00
HomeSpan fc01e37590 Created setWifiCredentials() method
To be used with user-define Access Point, but CAN be used to programmatically hardcode SSID and PASSWORD (not a good idea to do this!)
2021-06-20 06:37:09 -05:00
Gregg e3d081bb35 updated enableAutoStartAP to accept user-define function as argument 2021-06-19 21:36:18 -05:00
Gregg e94a9bba04 Updating Example 18; and set HomeSpan version to 1.3.0 2021-06-13 18:40:54 -05:00
Gregg 6356012fd6 Added 'V' command to CLI
This command erases all values of saved Characteristics
2021-06-13 14:49:36 -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 f4c9c430ef Replace restore() method with second optional parameter when instantiating Characteristic
To enable save/restore for a Characteristic, set second parameter to TRUE when instantiating.  Since first parameter was optional as well, this requires setting it as well.

Next up:  Must add logic to setVal() to store new value as well.
2021-06-13 09:20:13 -05:00
Gregg 40798b15cf Begin development of NVS Characteristic storage
Used method restore() to restore value.  To do:  Change this to a flag during instantiation of a new Characteristic instead of a separate method.
2021-06-13 08:45:11 -05:00
Gregg 1dfd66bf25 Add homeSpan.enableAutoStartAP()
Enables auto-start of AccessPoint if WiFi Credentials not found.
2021-06-05 10:30:21 -05:00
Gregg 83507abb41 Update src.ino 2021-05-30 13:48:28 -05:00
Gregg bda90c59ca Created SpanUserCommand()
Allows the user to add a command function to the Command Line Interface.  All User Commands are defined with a '@' prefix.

To Do:  Document this new feature.
2021-05-30 13:45:52 -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 d49bca9bbe Completed LedPin() and ServoPin()
Both classes check that total number of combined instantiations does not exceed 16.  ServoPin() has additional limit of only 8 instantiations.

DEPRECATED: PwmPin().  Keep for backwards compatibility only.
TO DO:  Update Tutorial Examples to replace PwmPin with LedPin, and update Extras.h documentations with LedPin and ServoPin.
2021-03-20 23:21:09 -05:00
Gregg a8dff0a7de Update PwmPin.cpp 2021-03-20 17:35:04 -05:00
Gregg 59e34fde05 Updated LedPin() 2021-03-20 17:19:47 -05:00
Gregg bc498c32e4 Created LedPin()
This is a replacement for PwmPin().   It keeps track of channel numbers internally, which greatly simplifies the user interface.  Starts by using the 8 Low Speed Timer channels and then moves to the 8 High Speed Timer channels if more than 8 LedPins are instantiated.  Throws a non-fatal error if more than 16 LedPins are instantiated, and ignores any attempts to set the duty cycle of those channels.
2021-03-20 17:14:19 -05:00
Gregg 65df97c563 Added ServoPin() class to PwmPin.h
Controls a 50-Hz servo motor using ESP32 built-in LED PWM.  Allows custom range for microseconds and degrees.
2021-03-20 12:20:43 -05:00
Gregg 61655845a9 Updated PWM
Removed need to include channel number in set() method.  Why was this ever there?  Need to update Examples and PwmPin docs.  But keep stub method that includes channel for backwards compatibility.
2021-03-19 06:38:41 -05:00
Gregg b90f173a6f Set version number to 1.2.1 in preparation for release 2021-03-13 06:31:18 -06:00
Gregg 16aff0e855 Updated formatting of Accessory Database output to Serial Monitor
Used unicode arrows and symbols, and included more detailed information about each Service and Characteristic.
2021-03-10 22:44:59 -06:00
Gregg d2a7030640 Reclaimed memory from REQ and OPT vectors after they are no longer needed.
Lots more memory optimization to perform!
2021-03-09 21:47:52 -06:00
Gregg 8121146c6b Changed ERROR to WARNING when a required Characteristic is missing
Only throw a non-fatal warning instead of a fatal error if a Service is missing a required Characteristic.  This allows for user flexibility in leaving out required Characteristics for Services that don't seem to need them (contrary to the HAP docs).

Also, changed PositionState Characteristic back to Required (instead of Optional) in WindowCovering Service (as specified by HAP).  If PositionState is not included this will only throw an error instead of a warning as a result of the above change.

To Do: Update Example 13 to properly incorporate PositionState Characteristic.
2021-03-09 20:33:54 -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 7e3d982ee5 Added min/max Range defaults for all Characteristics
Also added new flag "staticRange" for all Characteristics that indicates whether the min/max range can be changed.  An ERROR will be thrown if setRange is attempted for a Characteristic having staticRange=true.
2021-03-05 22:34:55 -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 5ca0bdc907 Added error checks to setVal()
Warning will be thrown if setVal() request is outside of mix/max range for the Characteristic, though min/max range not yet modified by SpanRange().

TO DO:  Create new Characteristic methods setRange(typename T_MIN, typename T_MAX) and setRange(typename T_MIN, typename T_MAX, typename T_STEP) that will reset min/max, or min/max/step, and trigger required output in database.  Add in checks to ensure setRange is NOT used to STRING or BOOLEAN.  Also add check to ensure STEP is always>0.  Add new UVAL for STEP that is normally zero, which indicates NO step size has been set (and does not need to be reported to database).   Then, set warnings about SpanRange being deprecated at some point in the future.
2021-03-01 09:09:24 -06:00
Gregg c8a2770253 Renamed Services.h to Span.h
Also, made it possible to use UVAL.set() for STRING Characteristic (upon initialization) but setVal() is NOT allowed.
2021-02-28 17:48:34 -06:00
Gregg 7930e3a0d9 Re-Factored SpanCharacteristic Constructor and Services.h
Added Characteristics.h file that defines all static data for HAP Characteristics.  Changed macros in Services.h to use this new HapChar structure.

Code is now more streamlined and ready for mix/max range-checking to be added.
2021-02-28 10:49:17 -06:00
Gregg 064d881e9c Refactored getVal() and getNewVal()
Functionality is identical, but template has been moved into UVal structure along with setVal, which simplifies code and allows for other uses if needed.
2021-02-27 12:54:32 -06:00
Gregg f591735deb Refactored setVal() to use a template
Ensures robustness and is fully backwards compatible.  User does NOT have to specify a template parameter, as the compiler determines this from the setVal() argument itself.  Allows for any numeric type to be properly mapped to correct HAP format for the Characteristic.

This change is also needed to prepare for the refactoring of SpanRange, the addition of UVals to store HAP min/max, and new error-checking of min/max limits within setVal.
2021-02-27 12:36:50 -06:00
Gregg 433e1cd59a Updated setVal() logic
Updated setVal() logic to ensure that every possible combination of parameter type and Characteristic type is handled properly, and without generating a compile-time error related to ambiguous parameters.
2021-02-26 07:53:33 -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 b2790386d6 Update Services.h
HAP documentation is INCORRECT!  Actual range for ColorTemperature is 140-500.  Change default to 200.
2021-02-20 15:43:35 -06:00
Gregg c7447b061c Set Version to 1.2.0 2021-02-18 21:09:28 -06:00
Gregg 96d3877ef6 Added check to ensure HostName is valid
Must be 255 or less alphanumeric characters or a hyphen, except hyphen can't be first or last character.
2021-02-18 21:02:41 -06:00
Gregg 66cd30fa80 Small tweak to diagnostic message when OTA is started 2021-02-17 08:54:29 -06:00
Gregg 269d749b5b Update src.ino 2021-02-16 07:19:48 -06:00
Gregg 24cc2486e2 Added Linked Services logic
New SpanService method addLink(SpanService *svc), where svc is a pointer to the SpanService that is being specified as a Linked Service for the current Service.

addLink() returns a pointer to "this" so may be chained
2021-02-14 18:32:54 -06:00
Gregg 35c8f5b48c Added option to disable OTA password
homeSpan.enableOTA() is now homeSpan.enableOTA(boolean auth=true).  Set auth=false to disable password authentication.  Set to true, or leave blank, to enable password authentication.
2021-02-13 21:24:46 -06:00
Gregg f1c3684e1c Updated maxConnections logic and added Socket numbers to output
homeSpan.begin() automatically resizes maxConnections to ensure it is at or below maxLimit, where maxLimit=CONFIG_LWIP_MAX_SOCKETS-2-otaEnabled.

maxConnections still defaults to 8 if unspecified, which means it is reduced to 7 if OTA is enabled.  Users should set maxConnections to a lower number is they have implemented other socket-based services in their sketch
2021-02-13 14:28:10 -06:00
Gregg 7400383b0a Increased number of sockets in WiFiServer to maxConnection+1
This should account for the extra connection opened when all slots are already filled.
2021-02-12 13:23:02 -06:00
Gregg 7e03998865 Added WiFi callback functionality
HomeSpan will call a user-defined function upon establishing WiFi connectivity.
Set function with homeSpan.setWifiCallback(f), where f must be of form void f().
2021-02-11 07:27:29 -06:00
Gregg 3a519bdc54 Added logic to check for OTA partitions
Warning will be thrown If OTA is enabled but partition table is not configured for OTA.  OTA will not be started.
2021-02-09 21:23:37 -06:00
Gregg 98cfde8aa9 Modified 'O' command so that a blank entry cancels the request to update the OTA password 2021-02-08 18:31:51 -06:00
Gregg 5c002708f9 Update version numbers 2021-02-07 19:25:59 -06:00
Gregg db3e1c4bb8 Added ability to specify optional sketch version number.
Specify with homeSpan.setSketchVersion(char *).
Read back with homeSpan.getSketchVersion().

Also, MDNS now broadcasts three new fields:

hspn = HomeSpan Version
sketch = Sketch Version
ota = "yes" if OTA enabled, else "no"

These are all optional to HAP but useful if trying to keep track of version updates when using OTA and Serial Monitor is not available.
2021-02-07 11:49:55 -06:00
Gregg 78b7900f19 Added ARDUINO_VARIANT to initial info output 2021-02-07 10:07:37 -06:00
Gregg 29470e4dd9 Completed OTA logic
OTA pasword now stored in NVS.  Use 'O' command to change from default.  Note password is stored as MD5 hash, and is therefore unrecoverable.  Changes to password DO NOT take effect until next reboot.  Password CAN be changed even if OTA has not been enabled for sketch.  Blank passwords are not allowed.

Stored password can only be erased with 'E' command.
2021-02-07 09:58:52 -06:00
Gregg 208905419c Added OTA logic - enable with homeSpan.enableOTA();
TO DO:  Add password for OTA (and require it)
2021-02-06 18:10:48 -06:00
Gregg 170f972d3b Fixed bug in pairing logic that would drop leading zeros when transmitting SALT
A 16-byte SALT with a leading zero would be sent as only a 15-byte number.  The chance of this occuring is 1 in 256, which is small but still significant.  Solution is to specify required size of MPI output in loadTLV.  This forces mbedtls_mpi_write_binary() to pad with leading zeros.

Also eliminated unused code (TLV pack_old).
2021-02-06 16:29:55 -06:00
Gregg 03e43e0bbb Added 'Q' command to change default Setup ID and store in NVS
Setup ID can now be stored in NVS and set dynamically with the 'Q' command.  However, homeSpan.setQRID(char *id) will override if present, but will not change the default stored in the NVS.  This default wil be used once again if homeSpan.setQRID() is removed from the sektch.

If the NVS is empty, the default is set to "HSPN" as in version 1.1.4.
2021-01-31 18:58:45 -06:00
Gregg a39b1ede0b Created QR Code Image 2021-01-28 21:14:19 -06:00
Gregg b6b835ad42 Created HapQR class in standalone HapQR.h file
Class used for the creation and storage of a pairing QR Code (just the text, not the actual graphic) from a HAP Setup Code, HAP Category, and HAP Setup ID.  The resulting QR Code text is output to Serial Monitor whenever the SetUp Code is generated or changed.  The user can type this text into any QR Generator to create a QR Code graphic for pairing the device to HomeKit (in lieu of creating a printed tag of the Setup Code formatted using the Scancardium font).

Though not needed for HomeSpan, this class implements all the settings and parameters (such as Version and Reserved) used to generate any Apple HomeKit QR Code.

This class is used internally by HomeSpan and is not intended for the end-user.
2021-01-26 19:13:07 -06:00
Gregg 2a5d5c138b Update src.ino 2021-01-24 18:53:49 -06:00
Gregg 9b71d6928a Added QR Code logic
HomeSpan now broadcasts a Hashed Setup ID as MDNS "sh", which is used when pairing with a QR Code instead of a Setup Code.  A text version of the resulting QR code is output to the Serial Monitor whenever the 9-digit Setup Code is generated or changed.  The text version of the QR code can then be input into any QR Code Generator to create a pairable QR Code.

The default Setup ID used to create the Hashed Setup ID is "HSPN".  This can be changed with homeSpan.setQRCode(const char *id), where id is exactly 4 alphanumeric characters.  If not, the request to change the Setup ID is silently ignored and remains "HSPN."
2021-01-24 18:46:55 -06:00
Gregg 78cbd926f1 Updated licenses and version number
Change copyright years to 2020-2021, and updated version number to 1.1.4 in preparation for next patch.
2021-01-24 12:02:24 -06:00
Gregg 9f7d288d18 Ignore any '\r' characters received from Serial Monitor
This allows the Serial Monitor to send NL or CR/NL at end of each line.  A newline ('\n') must be at the end to terminate reading from the Serial Monitor, but any preceeding carriage returns are stripped out.
2021-01-23 20:55:06 -06:00
Gregg d68c34c53f Update HomeSpan.h
Fixed a few more compiler warnings related to const char *
2021-01-22 22:05:13 -06:00
Gregg d41b335aee Cleaned up various compiler warnings when compiled with max warning level
Also added a missing check on hapServer existing before it is used (bug introduced in last update where hapServer became dynamically initialized).
2021-01-22 21:37:29 -06:00
Gregg 750a658241 Added new method homeSpan.setPortNum(port)
HomeSpan defaults to running the HAP Server on port 80 (the standard HTTP port).  This method allows the user to over-ride the default and have HomeSpan run the HAP Server on any other port.

ALSO:  In updating this portion of the code, identified an additional parameter to the ESP32 version of WiFiServer that allows one to specify the number of simultaneous Server connections.  The ESP32 default is 4, which suggests that the ESP32 was internally juggling connections that HomeSpan was keeping open (since the HomeSpan default is 8 connections).

This WiFiServer call has been updated to now specify both the port number AND the number of maximum simultaneous connections (to match whatever has been set by HomeSpan).  This may or may not result in improving performance when more than 4 clients are connected.
2021-01-22 09:45:50 -06:00
Gregg b87a3d1dc3 Added new method homeSpan.setHostNameSuffix()
Allows user to replace the 6-byte AccessoryID "suffix" in the hostName with a custom suffix, included a blank string.  To do: Add to documentation.
2021-01-21 08:07:57 -06:00
Gregg dff13d4b08 Update version number to v1.1.3
Getting ready to release v1.1.3 patch
2021-01-09 12:55:31 -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 8d55d0a60e Fixed WiFi Access Point Password Bug
Updated Network::getFormData() to properly read special characters (!#$, etc.) input into Access Point web page as part of password of SSID.
2021-01-09 08:09:50 -06:00
Gregg f9e317a3b1 Updated Access Point WiFi connection logic
Matches new logic in HomeSpan CLI, except that wait time cycles from 2 to 10 seconds in steps of 2 seconds, then repeats, since user is expected to be manually monitoring the process, and the Access Point auto times-out in 300 seconds anyway.
2021-01-05 20:42:29 -06:00
Gregg 368c7f6d69 Update Network.cpp 2021-01-05 20:05:46 -06:00
Gregg 0939bc5ade Revamped WiFi connection logic
WiFi connection now occurs asynchronously so that if WiFi is lost, or cannot be connected at start-up, the device still operates intead of blocking while it tries to connect.  The new logic should allow for a wider range of chips to connect.
2021-01-03 17:26:17 -06:00
Gregg 27b6bb7eba Added MAX_ACCESSORIES limit=41
Program now halts if more than 41 Accessories are defined.  This allows for a bridge to have 40 Accessories.  HAP limit is 150, but there is not enough memory in ESP32 to robustly handle more (testing up to 50 LightBulb Services worked, but was sluggish).
2021-01-02 21:45:12 -06:00
Gregg 3aa5456881 Fixed memory problem with sendEncrypyted()
Switched from using fixed buffer, httpBuf, to a TempBuffer to allow for dynamic allocation of memory when assembling and transmitting large blocks of data.  This was causing a memory overflow of the static httpBuf when responding to a getAccessories() request for a large number of Accessories.
2021-01-02 21:18:50 -06:00
Gregg b9656fea37 Updated version to 1.1.2 - ready for release 2020-12-27 13:34:45 -06:00
Gregg a1035bd911 Added validation check to ensure AccessoryInformation is always the first Service to be defined in an Accessory
Required by HAP (overlooked in original error-checking logic)
2020-12-27 12:47:03 -06:00
Gregg b50db3f078 Cleaned up almost all compiler warning messages and cleaned up wifi connect message
1) Used `const char *` instead of `char *` where appropriate, including the need to create a dummy blank string for us in certain places.
2) Set initialization of WiFiClient to 0 instead of NULL, since WiFiClient is not a pointer (probably don't need to set it to anything since WiFiClient overrides the boolean operator anyway).
3) Cleaned up some of the messaging and logic when WiFi tries to connect so that users know to wait a bit.
4) Only remaining warning messages are for casting SpanService to (void *), which I think i unavailable (and is not forbidden).

To Do: Go through examples and check for warnings (will likely need to convert `char *` to `const char *` in many places.
2020-12-27 09:11:18 -06:00
Gregg 0b316de602 Added REQUIRED Macro
User can specifiy a REQUIRED minimum version on the HomeSpan Library for the sketch to compile.  If the library version is older, the pre-processor will halt the compilation with a #error output
2020-12-26 16:46:36 -06:00
Gregg 3af65a5774 Updated notification logic so that newValue as well as value gets updated by setVal() 2020-12-24 16:40:41 -06:00
Gregg cc748f346c Updated RFControl
Changed enum class PHASE back to simple uint8.  Was too complicated to have a dedicted structure just to represent HIGH and LOW.
2020-12-22 17:27:56 -06:00
Gregg e7e6d4de61 Added 'phase' method to RFControl
RFControl::phase() allows you to add either a HIGH or LOW entry (i.e. a single phase of a pulse.  RFControl::add() continues to add a full HIGH/LOW pulse so these changes are fully backwards compatible.
2020-12-21 22:07:58 -06:00
Gregg 8b4d4cf32d Updated version to 1.1.1 2020-12-12 20:23:30 -06:00
Gregg a9bc186a90 Fixed problem with timeVal() function
had forgotten to initialize updateTime to zero at startup (how did this ever work?)
2020-12-12 18:34:39 -06:00
Gregg 70d579e21f Added UUID for TargetHeaterCoolerState
This is missing for HAP-R2 documentation.  Was able to find within Apple HomeKit ADK GitHub repo.
2020-12-07 05:55:10 -06:00
Gregg 1eea70aa47 Update Services.h
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.
2020-12-06 15:07:45 -06:00
Gregg d849595bfe More updates to Accessory ID
* 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
2020-12-05 13:50:24 -06:00
Gregg 1847478252 Added ability to specify "aid" for Accessories
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.
2020-12-05 12:41:33 -06:00
Gregg 2b4e3bfcfd Update version number to 1.0.1 2020-11-28 07:51:16 -06:00
Gregg 302a84007e Update RFControl.cpp
Added new tests for out-of-range conditions
2020-11-27 19:59:09 -06:00
Gregg cefc1df399 RF Control Update
Changed arguments for add() method from int to uint8_t.   Updated pulse train figure.
2020-11-27 10:24:03 -06:00
Gregg f259791305 Update Services.h
Added defaults for string-based Characteristics
2020-11-26 07:49:40 -06:00
Gregg 8b7a48e0ce Update HomeSpan.cpp
Re-ordered CLI menu
2020-11-22 20:44:09 -06:00
Gregg 89024bc555 Made first argument of homeSpan.begin() optional
Default is Category::Lighting
2020-11-21 13:52:04 -06:00
Gregg f200138a2d Added back src/ino files which will be excluded via .gitattributes instead of .gitignore
This keeps them in the reop, but excludes them from releases.
2020-11-08 07:41:36 -06:00
Gregg 0fdff88ab6 Update Services.h 2020-11-06 21:38:40 -06:00
Gregg b6c5a6b68d Added License Info to all files 2020-11-02 20:09:09 -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 bde63bf79d Updated PushButton to add initial logic for double-clicking 2020-11-01 10:00:20 -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 0f2c3afbf0 Completed adding all Characteristic structures for all HAPCharType
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
2020-10-29 07:21:25 -05:00
Gregg 118626ce83 Update Services.h 2020-10-28 20:20:27 -05:00
Gregg edac6df4b5 Added a few new Services 2020-10-28 20:05:46 -05:00
Gregg c7f762da5f Completed error-checking/validation
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.
2020-10-28 19:48:53 -05:00
Gregg 254406c802 Added more error-checking to SpanCharacteristic
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.
2020-10-28 07:31:58 -05:00
Gregg a584cbb042 Update Services.h
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
2020-10-27 22:11:46 -05:00
Gregg 5838768f38 Completed adding all characteristic types to HAPCharList 2020-10-25 21:29:47 -05:00
Gregg 1d8bdc1202 Redo of Service Structure
Created HAPCharType and added vectors for required and optional characteristics to every service.  Next up:  add all HAP characteristic types to HAPCharType
2020-10-25 18:06:44 -05:00