Commit Graph

410 Commits

Author SHA1 Message Date
Gregg 615d373850 Added Example 20 - Dynamic Bridge. Also created homeSpan.getAccessory(aid) 2022-05-14 10:00:30 -05:00
Gregg d326ae1abf Added logic to delete PushButtons when Service is deleted
This completes all code for the ~SpanService() destructor.

To do: create tutorial example demonstrating a Dynamic Bridge
2022-05-09 21:27:18 -05:00
Gregg dc11c59a00 Deleted 'C' CLI command - replaced with homeSpan.updateDatabase()
Method homeSpan.updateDatabase(boolean updateMDNS) recomputes database hash and compares with previous hash.  If changed, config number is updated and saved in NVS along with new hash.  If updateMDNS is true, a new "c#" MDNS record is also broadcast with the new config number.  This triggers HomeKit to call for a database refresh.  Method returns true if config number has changed, or false if it has not.
2022-05-09 21:03:23 -05:00
Gregg 058d6b0c96 Completed destructors for SpanAccessory, SpanService, and SpanCharacteristics
Tested to ensure any combination can be deleted.

To do: must add logic to destruct any PushButtons that were added to a Service
2022-05-08 15:27:50 -05:00
Gregg 05f1204b4f Continuing destructor code... 2022-05-08 11:56:26 -05:00
Gregg 554cefd3ce Initial work on adding destructors to Accessories, Services, and Characteristics
Will allow for dynamic changes to database without rebooting.
2022-05-08 07:02:19 -05:00
Gregg bddfb4658a Added 'm' CLI command to print free 8-bit heap memory 2022-05-06 22:19:37 -05:00
Gregg 7546350775 Added "C" CLI command and updated/fixed config number logic
The "C" command computes a hash of the current database config and updates the config number if needed.  If config number has changed, the MDNS "c#" record is updated and the new config number is rebroadcast.  This triggers HomeKit to immediately request an update of the HAP database so that the changes can be shortly reflected in the Home App without the need to close any Client connections or reboot the device.

The config number logic has also been updated/fixed.  Previously it would create a hash from the full HAP database, which includes the value of each characteristic.  Thus, initial value changes of Characteristics, as a result of stored values in NVS, would cause an update to the config number upon reboot.
 This is not problematic, but also not intended, as a change in value is not really a change in the database config.  The new logic computes a hash of the database that EXCLUDES all Characteristic values.
2022-05-06 17:04:15 -05:00
Gregg 628c29c6b6 Updating logic that determined HAP Configuration Number (MDNS=c#) 2022-05-06 16:13:25 -05:00
Gregg f48cea8afb Completed refactoring of 'i' CLI command
All error checking and database validation is now done dynamically every time the 'i' command is run.
2022-05-01 17:03:07 -05:00
Gregg 18414d8856 Continuing refactor of 'i' CLI command 2022-05-01 12:47:08 -05:00
Gregg 7b30f971e2 Continued refactoring of 'i' CLI command 2022-05-01 09:24:45 -05:00
Gregg 9f71c67f14 Updated logic for required/optional Characteristics
Logic now embedded in 'i' CLI command.
2022-04-30 22:20:42 -05:00
Gregg 0e6f7d27f9 Continuing with 'i' refactoring
Next up: Re-do optional/required Characteristics logic
2022-04-30 18:18:15 -05:00
Gregg 5f463b013e Continuing to refactor 'i' CLI command 2022-04-30 16:29:31 -05:00
Gregg 88f2373a71 Continued refactoring of 'i' CLI command 2022-04-30 11:04:57 -05:00
Gregg 212900f624 Initial re-factoring of "i" command
Instead of creating a static configLog for display upon start-up, an info log will be generated based on real-time data whenever the 'i' CLI command is requested.  This provides for more streamlined error-checking as well.
2022-04-30 07:57:01 -05:00
Gregg 82035df0a7 Removed enabling of IPv6
Not having an IPv6 address is NOT the cause of the Arduino 2.0 OTA network port problem.
2022-04-29 18:16:43 -05:00
Gregg 6a8b3653da Update FeatherPins.h
Mappings are now based on specific boards, not just the architecture (e.g. S2 vs. C3).
2022-04-27 21:11:44 -05:00
Gregg 4659e6f660 Enabled IPV6 Address Broadcast
Added to see if this addresses the mdns-discovery issue in Arduino IDE 2.0.0 interface.
2022-04-27 20:42:38 -05:00
Gregg 6dacbb0a8c Update FeatherPins.h
Changed mapping for S2 to Espressif ESP32-S2 (instead of UM Featherboard)
2022-04-27 06:31:32 -05:00
Gregg 044fe22b1f Made FirmwareRevision Characteristic PR+EV instead of just PR
Allows for updating FirmwareRevision, which HomeKit seems to poll every 60 seconds.
2022-04-26 21:45:29 -05:00
Gregg 54dbda9484 Changed homeSpan.start() to homeSpan.autoPoll() 2022-04-24 08:42:18 -05:00
Gregg c290c8637e Added homeSpan.start() method as alternative to homeSpan.poll()
Rather than call homeSpan.poll() in the main Arduino loop() function, you can instead call homeSpan.start() at the end of the set-up function.  This keeps the main Arduino loop() function free for user-defined code that will not block, and does not get blocked by, homeSpan.poll().

If using a dual-core processor, polling now occurs on core 0, instead of the core 1 (where all other Arduino stuff normally runs).

HomeSpan will throw a fatal error and halt processing if both homeSpan.poll() and homeSpan.start() are used in the same sketch.
2022-04-23 07:22:45 -05:00
Gregg 0507f26b13 Updated "Other Examples" and added SPAN_ACCESSORY() Macro
Need to revisit Television sketch - the latest iOS seemed to have disabled the ability to dynamically set visibility of input sources.  Checking/Un-Checking the visibility radio buttons either during pairing, or after pairing on the settings screen, seems to be ignored by the Home App (the same input sources are shown in the selector regardless of any changes made).  However, dynamically changing the name of an input source seems to work fine.
2022-04-16 15:21:13 -05:00
Gregg 92ece5413f Removed requirement to include HAP Protocol in Accessory Information Service
HAP Protocol does not appear to be needed anymore (as of iOS 15?)
2022-04-08 17:54:50 -05:00
Gregg d20df43a58 Eliminated HAP Protocol Service and updated Examples 1-8
Experimentation reveals that the HAP Protocol Information Service no longer seems to be required by HomeKit.  Examples work fine without it.
2022-04-08 17:46:33 -05:00
Gregg 98f812ba0c Updating examples 1-7 to conform with latest iOS changes 2022-04-04 06:13:30 -05:00
Gregg 240a995c86 Added LOG0() macro 2022-04-02 22:10:05 -05:00
Gregg 057901b5bb Update src.ino 2022-03-14 22:14:59 -05:00
Gregg 6409157180 Completed all SpanOTA safemode logic and cleaned up previous iterations of the logic
Must document in safemode in API as well as discuss in OTA documentation.
2022-03-14 22:01:28 -05:00
Gregg ffdf0296c6 Dramatically simplified OTA enable check in safemode
Rather than auto-enable OTA if not already enabled in safemode, changed the logic to simply rollback to previous app if OTA was used to download a sketch that does not itself have OTA enabled, unless OTA was previously enabled without safemode.

To do:  Delete all complicated SpanOTA logic that (unsuccessfully) tried to track OTA status and check SHA246 partition codes to determine if reboot was OTA or Serial.  None of this is need, but some of the code may be useful for other things in the future.
2022-03-14 21:46:37 -05:00
Gregg 1b0c4835cb Progress on additional SafeMode logic to Auto-enable OTA 2022-03-13 14:42:19 -05:00
Gregg b6eb5afcbf Started work on auto-enabling OTA to start even if not enabled. 2022-03-13 10:19:11 -05:00
Gregg eac06129fc Moved all OTA logic into SpanOTA and completed "safeLoad" protocol 2022-03-12 16:31:50 -06:00
Gregg f3d5092340 SpanOTA in progress 2022-03-12 14:31:15 -06:00
Gregg 2f1044b013 Adding Custom Magic Cookie to OTA Partition
Will prevent uploading a non-HomeSpan sketch via OTA to an existing HomeSpan device.
2022-03-12 08:24:01 -06:00
Gregg 7ddbfd55cc Slight OTA cleanup plus confirmed that you cannot enable ROLLBACK in Arduino-ESP32
Since much of the Arduino-ESP32 library is precompiled, you cannot use -DCONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE to define this during compile time (it gets defined but is not used by the precompiled libraries).

TO DO:  create an NVS entry that flags whether last update was via OTA.  If so, automatically enable OTA regardless of enableOTA setting.  This would ensure that OTA cannot be disabled accidentally by uploading a non-enabledOTA sketch to  remote device.
2022-03-07 22:02:23 -06:00
Gregg 3336ac7fbe Small clean-up of OTA
Researching potential use of rollback of OTA.
2022-03-06 18:39:05 -06:00
Gregg db3bea3b5c Completed Example 19 - Web Logs
Also updated SpanWebLog::addLog() so that the log message is also output to the Serial Monitor if the HomeSpan Log Level is set to 1 or greater.

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

If LOG1() or LOG2() is provided with multiple arguments, the first is considered the format and Serial.printf(format...) is called.  This allows you to use printf-like functionality within LOG1() and LOG2().
2022-03-06 07:48:12 -06:00
Gregg 33042f191e Added logURL to MDNS broadcast
Broadcast as "logURL" only if Web Logging is enabled.
2022-03-05 22:34:30 -06:00
Gregg f37889f8da Added ClientIP as permanent part of Web Log ; DELETED homeSpan.getClientIP()
ClientIP will show as "0.0.0.0" if log message is not related to client request
2022-03-05 22:24:23 -06:00
Gregg cf22ff1a92 Added homeSpan.getClientIP()
Gets IP address (as char *) of last client to send a request.  Useful as part of web log messages.  Will return 0.0.0.0 if used outside of any code that is responding to a client request.
2022-03-05 22:06:34 -06:00
Gregg 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