An ESP32-based Redis-watcher and info-displayer https://rpjios.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ryan Joseph b1ef2031f8 WIP пре 1 година
scripts Add Deep sleep mode & provisioning functional verification пре 1 година
LICENSE Create LICENSE пре 1 година
README.md Update README.md пре 1 година
zero_watch.ino WIP пре 1 година
zw_common.cpp ZeroWatch public repo initial commit пре 1 година
zw_common.h WIP пре 1 година
zw_displays.cpp WIP: add pagination, scroll w/ home button; scroll brightness w/ RST button пре 1 година
zw_displays.h Add Deep sleep mode & provisioning functional verification пре 1 година
zw_logging.h WIP, not sure when I did all of this but should probably check it in... пре 1 година
zw_ota.cpp No. 6: Remove delay use in main loop (#8) пре 1 година
zw_ota.h No. 6: Remove delay use in main loop (#8) пре 1 година
zw_otp.cpp Minor changes пре 1 година
zw_otp.h Break out zw_otp пре 1 година
zw_provision.cpp Retry Redis connection a few times on failure; add null display spec; try to clear boot count upon successful OTA; bump to 0.2.3.8 пре 1 година
zw_provision.h Add Deep sleep mode & provisioning functional verification пре 1 година
zw_redis.cpp WIP: add pagination, scroll w/ home button; scroll brightness w/ RST button пре 1 година
zw_redis.h Get time from Redis, set it to RTC пре 1 година
zw_wifi.cpp WIP: add pagination, scroll w/ home button; scroll brightness w/ RST button пре 1 година
zw_wifi.h Add Deep sleep mode & provisioning functional verification пре 1 година

README.md

ZeroWatch

A highly-configurable ESP32-based Redis-watcher and TM1637-displayer, with OTA capability.

Currently driving stuff like this and this:

version 2 version 1

Dependencies

Provisioning

Units must be provisioned with critical datum, written to EEPROM, before they will behave correctly.

To do so, fill in the aforementioned fields appropriately, set ZERO_WATCH_PROVISIONING_MODE to 1 and upload to your ESP32 while monitoring serial (at this baud rate). There are wait-points that allow you to remove power for the unit before data is written.

Most critical of these values is hostname, which is limited to 32 characters in length and must be unique across your network. All references to HOSTNAME elsewhere in this document refer to this data.

None of the remaining fields must be longer than PSTRING_LENGTH_LIMIT bytes and ZWPROV_REDIS_PORT must always only be two bytes (sizeof(uint16_t)).

Once provisioned, the unit will halt forever, so to return it to normal behavior: unset ZERO_WATCH_PROVISIONING_MODE and all ZWPROV_* fields, rebuild and reflash. That’s it!

Configuration

Most of the behavior, save for the display specifications (which will one day be configurable as well), is configurable at runtime via the Redis instance the unit connects to.

Specifically, a number of fields are exposed as HOSTNAME:config:* keys for which any written (valid) value will be honored on the next refresh cycle.

There is also a control point key at HOSTNAME:config:controlPoint, a metadata getter at HOSTNAME:config:getValue and the OTA update configuration key at HOSTNAME:config:update.

OTA

Set ZWPROV_OTA_HOST when provisioning to an HTTP host visible to the unit and this will be combined with the update metadata’s url component to produce the fully-qualified URL for acquisition of the update binary.

The aforementioned metadata must be written to HOSTNAME:config:update as as JSON object consisting of: url, md5, size, and otp (a “one-time password”), e.g.:

{
    "url":  "zero_watch_updates/zero_watch-v0.2.0.6.ino.bin",
    "md5":  "1a6f92066b6e3a63362c6b376fbc438d",
    "size": 924960,
    "otp": 123
}

On the next refresh cycle, this data will be picked up and acted upon. Monitor serial or Redis (depending on HOSTNAME:config:publishLogs) for logging. Upon successful update, the unit will delete HOSTNAME:config:update and reset to the new software (after a small, build-time configurable delay).

Pre-built images of recent versions are available here, but only via HTTPS so as to be unusable as ZWPROV_OTA_HOST. You should only be deploying this type of insecure OTA on a secure local or virtual private network, anyway! 😄