Commit Graph

291 Commits

Author SHA1 Message Date
Gregg 26c15c9ca2 Fixed strncpy() warnings
Changed strncpy() to strcpy() when copying new string values
2021-10-18 22:48:56 -05:00
HomeSpan 353749baea
Merge pull request #121 from unreality/master
add support for Televisions
2021-10-17 16:10:50 -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 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 50bdfd7d37 Added better display of IDF Version 2021-09-25 14:41:20 -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 6c9bf39f54 Added PWM diagnostic messages and chip-specific maximum duty resolution 2021-09-14 21:09:58 -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
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
Gregg 36499f35ab Added ESP32 chip type, revision, memory, etc. to initial output 2021-06-26 18:35:28 -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 6356012fd6 Added 'V' command to CLI
This command erases all values of saved Characteristics
2021-06-13 14:49:36 -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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 3af65a5774 Updated notification logic so that newValue as well as value gets updated by setVal() 2020-12-24 16:40:41 -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 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 8b7a48e0ce Update HomeSpan.cpp
Re-ordered CLI menu
2020-11-22 20:44:09 -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 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 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 5838768f38 Completed adding all characteristic types to HAPCharList 2020-10-25 21:29:47 -05:00
Gregg f3b1de2f6b Changed apConfig() to use fixed SSID of "HomeSpan-Configuration" 2020-10-12 07:55:07 -05:00
Gregg 8cfd9afa63 Minor tweaks to some LED patterns 2020-10-11 19:18:22 -05:00
Gregg e658d6d4eb Tweaks to blinker() to make sure delayTime ADDs to offTime 2020-10-10 16:40:53 -05:00
Gregg a6d9fa86e2 Update HomeSpan.cpp 2020-10-10 16:19:58 -05:00
Gregg 3872d693a5 Updated Command Mode to include timeout and for apConfigure() to have more cancel options 2020-10-10 08:22:02 -05:00
Gregg 7e4df498db Completed integration of apConfigure()
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()
2020-10-09 07:57:30 -05:00
Gregg 5cb09b6ad8 Updated Access Point code 2020-10-08 21:06:05 -05:00
Gregg 206d194cc1 Created commandMode()
Universal command mode for control button operation.
2020-10-07 22:20:44 -05:00
Gregg a4b86f4618 Re-worked network.serialConfigure() and initWifi()
To do:  Re-work apConfigure() and update factory reset so that it only deletes HAP and WIFI data, NOT setup code.
2020-10-07 08:20:37 -05:00
Gregg cf0627e8c9 Updating WiFi Configuration Logic
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...
2020-10-06 09:09:43 -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 82215e8d90 Modified SpanService to accept list of required and optional SpanCharacteristics
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.
2020-10-04 09:58:40 -05:00
Gregg 855d5e9735 Added Error messages and Warnings for SpanRange and SpanButton 2020-10-04 09:26:21 -05:00
Gregg db620e497e Added code to output configuration log and error messages
Config Log is output if logLevel>1 OR there is a fatal error in configuration
2020-10-03 22:21:38 -05:00
Gregg 1d6f07a400 Added HAP Names to all Services and Characteristics in Services.h 2020-10-03 21:39:20 -05:00
Gregg 60c2d5645d Update HomeSpan.cpp
Tweaks to WiFi reset code so that instead of re-starting, HomeSpan simply disconnects WiFi, which triggers initWifi() upon the next call to poll(().
2020-10-03 20:18:58 -05:00
Gregg 546c5048db Fixed bug in initialization logic at beginning of poll()
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.
2020-10-03 15:08:44 -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 0bdeb7508d Created #defines in Settings.h for all statusLED.start() commands
Reviewed and simplified the number of different blinking patterns.  All are now labeled in Settings.h
2020-10-03 09:36: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 fbd33bb29d Created homeSpan::setMaxConnections() to make number of HAP connections dynamic
This completes all changes to Settings.h.  User will not need to ever access this files or change any settings.
2020-09-30 10:00:10 -05:00
Gregg ba66c6f01a Normalized all #includes
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.
2020-09-29 07:28:27 -05:00
Gregg 606601f447 Add 'L' command to change Log Level 2020-09-28 19:59:03 -05:00
Gregg dee954d5bd Converted VERBOSE macros to LogLevel macros that use real-time if-statements.
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.
2020-09-28 18:04:59 -05:00
Gregg 2d8f36e735 Created HomeSpan::setApPassword() and setAPTimeout()
Moved default values into Settings.h
2020-09-27 22:31:11 -05:00
Gregg fa8c5934ea Eliminated ServiceType from Library and Example 11
Next up - update Examples 12+ to delete ServiceType
2020-09-27 15:56:48 -05:00
Gregg 814d751e71 Created SpanService::setPrimary() and setHidden()
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.
2020-09-27 14:51:31 -05:00
Gregg 538a3a9531 Added PushButton::primed()
Allows you to determine if short-press has occured but button not yet released.
2020-09-27 14:33:38 -05:00
Gregg a40447b8f8 Created methods to set Control and Status Pins
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
2020-09-27 13:41:02 -05:00
Gregg ac25b94b67 Fully implemented Generic PushButton
Generic PushButton now used for all device control functions.
2020-09-26 17:13:17 -05:00
Gregg b7de0cf710 Created Generic PushButton
Wll be used for control button.  Nothing to do with buttons that control Accessories, which are handled by SpanButton.
2020-09-26 16:23:44 -05:00
Gregg 6a2d0741aa Finished 'U' unparing routines
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.
2020-09-24 09:29:52 -05:00
Gregg 69c7d939b8 Update HomeSpan.cpp
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
2020-09-23 08:51:13 -05:00
Gregg 7d19df3f69 Added 'S' command to change setup code
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?
2020-09-22 08:14:02 -05:00
Gregg c9a661573d Made NVS Handles static variables of HAPClient
Now have nvs_handle hapNVS, wifiNVS, and srpNVS.  All three are opened once in HAPClient::init()
2020-09-22 07:28:02 -05:00
Gregg 446679abab Created SRP6A:createVerifyCode()
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()
2020-09-20 22:00:01 -05:00
Gregg b0307c9ab0 Completed WiFi credentials code
WiFi data now set/resest/saved as needed.  Next up: saving/resetting Setup Code.
2020-09-20 08:25:16 -05:00
Gregg d93c45c0bc Updated Network:apConfigure
Improved Robustness - all functionality now completed.
2020-09-19 08:39:27 -05:00
Gregg dd6c8d904a Completed Network::apConfig() 2020-09-15 07:00:31 -05:00
Gregg 123e2924a5 Completed Network::serialConfigure()
Next up: update and complete Network::apConfigure()
2020-09-12 10:06:44 -05:00
Gregg 4a6c737c72 Moving serial wifi update into Network.cpp 2020-09-07 11:02:44 -05:00
Gregg 3da2b9a311 Change Config.cpp to Network.cpp
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
2020-09-06 08:24:13 -05:00
Gregg af3c093cdc updated configure() 2020-09-04 22:19:14 -05:00
Gregg a5e0b1c0ad cleaning up Configure()
TO DO: Add max length to other form inputs;  try limiting number of connections to exactly 1.  Next:  parse form data and initiate wifi connection.
2020-09-04 07:27:50 -05:00
Gregg 9a80b8fa41 Moved all captive code into Configure.cpp 2020-09-03 21:48:08 -05:00
Gregg efe33fcdb9 Created captiveAccessURL()
Developing captive AP routines inside HAP.cpp
2020-09-01 22:08:51 -05:00
Gregg cd5b3115f5 Further updates to Captive AP Mode 2020-09-01 08:34:59 -05:00
Gregg 705a0922e1 Started work on CaptiveAP
Added span::config(hostName) to provide CaptiveAP at start-up.
2020-08-30 22:07:16 -05:00
Gregg b42dd9dfba Implemented Reset Button
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.
2020-08-23 08:14:31 -05:00
Gregg 2172ac1ce6 Implemented Blinker statusLED
Replaced manual blinking with automated Blinker statusLED
2020-08-22 21:52:25 -05:00
Gregg f056b6ae82 Completed SpanButton()
And finished code for Example 15 to verify SpanButton() works as expected.  To Do: add comments and notes to Example 15.
2020-08-20 21:39:13 -05:00
Gregg c997ca3462 Created Example 15
Initial implementation of SpanButton PushButton object and check() logic
2020-08-20 07:29:15 -05:00
Gregg 6c5a5835e6 Eliminated TimedResets from Library
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.
2020-08-17 21:54:43 -05:00
Gregg 9cecc0a31a Updated Example 13
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.
2020-08-16 21:46:58 -05:00
Gregg 1efeb2880b Created checkNotifications()
This will replace older checkEvents() after testing validates new and improved methodology.
2020-08-16 12:27:39 -05:00
Gregg 53f51cc11b Created new framework for Service loops()
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()
2020-08-16 08:45:24 -05:00
Gregg 0ade00eb9a Implemented checkTimedWrites()
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.
2020-08-14 17:46:35 -05:00
Gregg ffb7b7ed87 Updated putCharacteristics to use Timed Writes
Must next create small routine to clean up expire PIDs - something like: clearPIDs()
2020-08-14 09:59:48 -05:00
Gregg 8d6db796cb Reworking checkEvents()
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.
2020-08-10 21:59:30 -05:00
Gregg 2e3daef92a Created Example 13
Created checkEvents(), which is a simplified (better) version of checkTimedResets().  To do:  re-write checkTimedResets() to mimic checkEvents();
2020-08-09 22:15:58 -05:00
Gregg e7c2fc46f7 Renamed SpanPut to SpanBuf 2020-08-09 20:33:15 -05:00
Gregg 471d62f3c2 created standalone eventNotify function
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.
2020-08-09 09:25:10 -05:00
Gregg 1347e4fd5c Added getVal and getNewVal
Updated Example 11 to use getVal and getNewVal, but kept distinction between integer and double Characteristics
2020-08-03 21:23:50 -05:00
Gregg 6646aae799 Fixed bug in updateCharacteristics
Fixed bug that was causing a crash when trying to update to separate services at the same time.
2020-08-01 11:29:15 -05:00
Gregg 0a07f9666d Updated TimedReset
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.
2020-08-01 08:32:16 -05:00
Gregg 861a37c7a1 Converted AutoOff to TimedResets 2020-07-29 07:26:13 -05:00
Gregg 59494a129f Added HomeSpan Version number
And added DATE/TIME of Compile
2020-07-29 06:28:24 -05:00
Gregg ce17b08d4d Update HomeSpan.cpp
Added edp-idf version
2020-07-25 22:13:03 -05:00
Gregg 47e7f7b6b4 Converted StatusCode to Class
Converted "statusCode Enum" to "StatusCode Class Enum" and moved from HomeSpan.h to Settings.h
2020-07-24 21:54:09 -05:00
Gregg 8a905c4d35 SpanRange Updated
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.
2020-07-19 06:25:09 -05:00
Gregg cccb61f946 Initial commit 2020-07-18 21:47:39 -05:00