Needed to support ESP-NOW on ESP-8266 chips, which seem to only work if connecting into softAP MAC Address once HomeSpan is connected to WiFi network (prior to connection ESP-8266 will properly connect to normal STA address as well as softAP address).
Similar to CUSTOM_CHAR_STRING() macro, but does not include a parameter to set the default value (since the user can type an invalid string). Instead, user setData after creating the Characteristic as needed.
* Changed ~SpanService to virtual function to ensure any user-defined destructor is also called
* Found/corrected bug in error message related to defining a Characteristic without any Service
* Added warning/error ID numbers to warning/error messages
* Other misc changes to clean up compiler warnings
Allows for bi-directional transmission between main HomeSpan device and one or more remote devices.
To Do: Create and test with Temperature Sensor Example
Added SpanPoint::setAsHub(), which is called after homeSpan.begin() to set device as Hub so SpanPoint knows not to change WiFi channel.
Also added check to make sure there are no SpanPoint objects instantiated before a call to homeSpan.begin() (if it is called at all).
This enables SpanPoint to operate as a standalone library with no reliance on anything in HomeSpan.
To Do: migrate all HomePeer code into SpanPoint. This will yield a universal standalone HomePoint library that can be used for BOTH the receiver and the sender (which automatically means two-way communication is always possible)
Verified ESP-NOW is communicating correctly with HomeSpan. Verified encryption works. Next step - create linkages between incoming data and Services; create queue structure to transfer data.
This allows the "src.ino" test file to once again properly compile without requiring modifications to any existing HomeSpan sketches. This was needed to ensure src.ino can find object code in "extras", which is now required to use the new statusDevice() method. Since the Arduino IDE only copies files that are in "src" folders, "extras" needed to be moved to "src/extras". For backwards compatibility with all other sketches, the "extras" directory now contains stubs for the ".h" include files.
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.
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.
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.
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.
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
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).
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
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.
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.
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').