Commit Graph

175 Commits

Author SHA1 Message Date
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