Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OTA checksum verification #189

Merged
merged 4 commits into from Oct 18, 2016
Merged

Added OTA checksum verification #189

merged 4 commits into from Oct 18, 2016

Conversation

ghost
Copy link

@ghost ghost commented Oct 18, 2016

See #172

Here is a little test script for triggering OTA updates with a checksum:

#!/bin/bash

DEVICE=homie/awesome-relay
BROKER=localhost
FW_VER=1.0.0
FW_BIN=/path/to/firmware.bin
FW_MD5=$(md5sum -b $FW_BIN | cut -d" " -f1)

mosquitto_pub -h $BROKER -t "$DEVICE/\$ota" -m "$FW_VER"
sleep 1
mosquitto_pub -h $BROKER -t "$DEVICE/\$implementation/ota/checksum" -m $FW_MD5
sleep 1
mosquitto_pub -h $BROKER -t "$DEVICE/\$implementation/ota/firmware" -f $FW_BIN

@marvinroger
Copy link
Member

I would not unsubscribe from firmware and checksum0, otherwise you need, as you've done in your script, to wait a little bit before sending next messages. What do you think? Maybe you have a good reason to do so?

@ghost
Copy link
Author

ghost commented Oct 18, 2016

Thanks for your feedback. Staying subscribed is actually what I was preferring when I was poking around in the code. I only left dynamic subscribe/unsubscribe in because that's what you had chosen for payload (now firmware) before. I was wondering why you had the if (!_flaggedForOta) check in the code. It should never have triggered because Homie only subscribed to the payload topic when _flaggedForOta was also true. Did you observe a race condition or something? Anyways. I added a commit to remove dynamic subscribe/unsubscribe.

BTW, the delay in my little test script is just for me to be able to observe what's going on looking at two terminals. I don't think the delay is needed. A real implementation would obviously evaluate Homie's status responses.

@marvinroger
Copy link
Member

Well we chose this because the payload was retained, so to receive it we had to subscribe only when receiving the $ota message. But at first the payload was not retained, and it looks like I forgot the flagged for OTA check. So yes, it was actually useless.

Great! LGTM 👍

@marvinroger marvinroger merged commit da3c312 into homieiot:develop Oct 18, 2016
@ghost ghost deleted the patch-ota-checksum branch October 19, 2016 04:33
gorec2005 pushed a commit to gorec2005/homie-esp8266 that referenced this pull request Jun 28, 2020
Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>

# Conflicts:
#	src/WebResponses.cpp
gorec2005 pushed a commit to gorec2005/homie-esp8266 that referenced this pull request Jun 28, 2020
…, updates documentation. (homieiot#213)

* Removed unnecessary memmove from chunked response generation.

* Added simple template processor to AsyncFileResponse.

Unzipped files in SPIFFS, Streams, PROGMEM strings, callback/chunked responses may have template placeholders like %TEMPLATE_VAR% inside. If callback is specified in Async...Response constructor call, it will be used to replace these with actual strings.
The prototype of callback is String(const String&), i.e. it gets variable name and returns its value.
Template variables' delimiter is currently percent sign ('%').
Maximal placeholder length is 32 chars (chosen somewhat arbitrarily, it may be stored on stack during processing). It is not guaranteed that placeholders longer than that will be processed.

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants