MySensors: generic FOTA scripts and OTA duration fields - #46
Merged
Conversation
Firmware selection can live in a data_repository script (fota_script). If that label is set, assigned_firmware is never used, even when the script is missing or disabled. Record completed OTA time in seconds and ota_time_taken_str (for example 1m40s).
# Conflicts: # plugin/gateway/provider/mysensors_v2/event_listener.go
Rewrite the event type check with De Morgan's law. Gateway and handler Start block on success, so drop the always-true err != nil guard that staticcheck SA4023 flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a generic firmware-selection hook for the MySensors v2 gateway. Policy lives in a data-repository JavaScript (
onConfig, optionalonBlock), not in Go. A sample STM32 A/B script is documented indocs/ota_stm32_ab.md.Also records how long a completed OTA took.
FOTA scripts
When a node has
fota_scriptset to a data-repository id:onConfigchooses the image (firmwareId,noUpdate, orresponseHex).onBlockis optional; thefirmwareIdfromonConfigis reused.assigned_firmwareis not used, even if the repository is missing ordata.disabledis true.When
fota_scriptis empty, the existingassigned_firmwarepath is unchanged.getFirmware(id)is injected for scripts that need type, version, CRC, checksum, and the first 16 image bytes (head).Node labels
fota_scriptfota_disabledtrueturns off all OTA for that node (script and stock).The sample script also writes
ab_*labels (running/request slot, last reported type/version/CRC, image being served). Those keys are policy, not core.OTA progress
On a finished transfer, node
othersnow includes:ota_time_taken: duration in secondsota_time_taken_str: compact form, e.g.4m37sStart/end timestamps that were stored as RFC3339 strings are parsed so the duration is actually filled in.
Notes
getFirmware) so they encode as JSON.