From f41d8a9c06f6b042a2515959b1ad75afde2035f1 Mon Sep 17 00:00:00 2001 From: Mark Dornbach Date: Tue, 5 Jan 2021 11:31:16 +0100 Subject: [PATCH 1/5] update several tasmota templates --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ede30b..d4385d0 100644 --- a/README.md +++ b/README.md @@ -56,16 +56,16 @@ Device | Update URL | Tasmota Template --- | --- | --- Shelly 1 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-Shelly1.zip` | `{"NAME":"Shelly 1","GPIO":[0,0,0,0,21,82,0,0,0,0,0,0,0],"FLAG":0,"BASE":46}` Shelly 1PM | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-Shelly1PM.zip` | `{"NAME":"Shelly 1PM","GPIO":[56,0,0,0,82,134,0,0,0,0,0,21,0],"FLAG":2,"BASE":18}` -Shelly Plug S | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyPlugS.zip` | `{"NAME":"Shelly Plug S","GPIO":[57,255,56,255,0,134,0,0,131,17,132,21,0],"FLAG":2,"BASE":45}` +Shelly Plug S | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyPlugS.zip` | `{"NAME":"Shelly Plug S","GPIO":[56,255,158,255,255,134,0,0,131,17,132,21,255],"FLAG":2,"BASE":45}` Shelly 2 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-Shelly2.zip` | `{"NAME":"Shelly 2","GPIO":[0,135,0,136,21,22,0,0,9,0,10,137,0],"FLAG":0,"BASE":47}` Shelly 2.5 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-Shelly25.zip` | `{"NAME":"Shelly 2.5","GPIO":[56,0,17,0,21,83,0,0,6,82,5,22,156],"FLAG":2,"BASE":18}` Shelly RGBW2 (color mode, latest firmware needed) | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyRGBW2.zip` | `{"NAME":"Shelly RGBW2","GPIO":[0,0,52,0,40,255,0,0,37,17,39,38,0],"FLAG":0,"BASE":18}` -Shelly Dimmer 1 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDimmer1.zip` | `{"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5504,5536,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18}` -Shelly Dimmer 2 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDimmer2.zip` | `{"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5504,5536,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18}` +Shelly Dimmer 1 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDimmer1.zip` | `{"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5568,5600,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18}` +Shelly Dimmer 2 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDimmer2.zip` | `{"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5568,5600,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18}` Shelly EM | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyEM.zip` | `{"NAME":"Shelly EM","GPIO":[0,0,0,0,0,0,0,0,6,156,5,21,0],"FLAG":15,"BASE":18}` Shelly Bulb | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyBulb.zip` | **not yet available, only flash if you a perfectly certain about what you are doing** Shelly Vintage | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyVintage.zip` | **not yet available, only flash if you a perfectly certain about what you are doing** -Shelly Plug US | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyPlugUS.zip` | `{"NAME":"ShellyPlugUS","GPIO":[52,255,57,255,21,134,0,0,131,17,132,157,0],"FLAG":0,"BASE":45}` +Shelly Plug US | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyPlugUS.zip` | `{"NAME":"Shelly Plug US","GPIO":[52,0,57,0,21,134,0,0,131,17,132,157,0],"FLAG":0,"BASE":45}` Shelly Duo | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDuo.zip` | `{"NAME":"Shelly Duo","GPIO":[0,0,0,0,38,37,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}` Shelly H&T | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyHT.zip` | **not yet available, only flash if you a perfectly certain about what you are doing** Shelly i3 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyI3.zip` | `{"NAME":"Shelly i3","GPIO":[0,0,0,0,0,0,0,0,83,84,82,0,0],"FLAG":2,"BASE":18}` From 6b53a2ab2dee49ca26b1fd2b8bc483346ac85c94 Mon Sep 17 00:00:00 2001 From: Mark Dornbach Date: Thu, 14 Jan 2021 15:26:39 +0100 Subject: [PATCH 2/5] add support for the Shelly Duo RGBW --- .github/workflows/build.yml | 2 +- README.md | 1 + mos.yml | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c80bf38..8d966df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: needs: release strategy: matrix: - hwModel: [Shelly1, Shelly1PM, ShellyPlugS, ShellyPlug2, ShellyUni, Shelly2, Shelly25, ShellyRGBW2, ShellyDimmer1, ShellyDimmer2, ShellyEM, ShellyBulb, ShellyVintage, ShellyPlugUS, ShellyHT, ShellyDuo, ShellyI3, Shelly1L] + hwModel: [Shelly1, Shelly1PM, ShellyPlugS, ShellyPlug2, ShellyUni, Shelly2, Shelly25, ShellyRGBW2, ShellyDimmer1, ShellyDimmer2, ShellyEM, ShellyBulb, ShellyVintage, ShellyPlugUS, ShellyHT, ShellyDuo, ShellyI3, Shelly1L, ShellyDuoRGBW] hwPlatform: [esp8266] targetFw: [tasmota, haa, espurna] runs-on: ubuntu-latest diff --git a/README.md b/README.md index d4385d0..2203d1b 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Shelly i3 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmo Shelly 1L | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-Shelly1L.zip` | `{"NAME":"Shelly 1L","GPIO":[320,0,0,0,192,224,0,0,0,0,193,0,0,4736],"FLAG":0,"BASE":18}` Shelly Plug 2 | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyPlug2.zip` | **not yet available, only flash if you a perfectly certain about what you are doing** Shelly Uni | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyUni.zip` | `{"NAME":"Shelly Uni","GPIO":[320,0,0,0,225,0,0,0,192,193,0,224,0,4864],"FLAG":0,"BASE":18}` +Shelly Duo RGBW | `http://shellyip/ota?url=http://dl.dasker.eu/firmware/mg2tasmota-ShellyDuoRGBW.zip` | **not yet available, only flash if you a perfectly certain about what you are doing** For your convenience, the table above also lists the matching Tasmota device templates from [templates.blakadder.com](https://templates.blakadder.com) which diff --git a/mos.yml b/mos.yml index 1fea174..a566582 100644 --- a/mos.yml +++ b/mos.yml @@ -190,3 +190,11 @@ conds: FLASH_SIZE: 2097152 BOOT_CONFIG_ADDR: 0x1000 MGOS_ROOT_FS_TYPE: SPIFFS + - when: build_vars.MODEL == "ShellyDuoRGBW" + apply: + name: color-bulb + build_vars: + FS_SIZE: 262144 + FLASH_SIZE: 2097152 + BOOT_CONFIG_ADDR: 0x1000 + MGOS_ROOT_FS_TYPE: SPIFFS From fc6b367b82fbdba1afa51ed18e7d7e1818334bb9 Mon Sep 17 00:00:00 2001 From: Mark Dornbach Date: Mon, 18 Jan 2021 12:27:59 +0100 Subject: [PATCH 3/5] fix compile time warnings in logging statements --- src/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 3418914..53ae730 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ rboot_config *rboot_cfg; length block length / byte */ void block_copy(uint32 src, uint32 dest, uint32 length) { - LOG(LL_DEBUG, ("block_copy start: cp %d bytes from 0x%x to 0x%x", length, src, dest)); + LOG(LL_DEBUG, ("block_copy start: cp %lu bytes from 0x%lx to 0x%lx", length, src, dest)); uint32 chunk = CHUNK_SIZE, offset = 0; bool done = false; char *data = NULL; @@ -117,13 +117,13 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data, void *ud) { } if ( spi_flash_erase_sector(state->curr_blk) != 0 ) { - LOG(LL_ERROR, ("flash delete error! abort at %d recieved bytes.", state->recieved)); + LOG(LL_ERROR, ("flash delete error! abort at %lu recieved bytes.", state->recieved)); c->flags |= MG_F_CLOSE_IMMEDIATELY; state->status = 500; break; } if ( spi_flash_write( state->curr_blk * BLOCK_SIZE, (uint32 *) state->data, BLOCK_SIZE) != 0 ) { - LOG(LL_ERROR, ("flash write error! abort at %d recieved bytes.", state->recieved)); + LOG(LL_ERROR, ("flash write error! abort at %lu recieved bytes.", state->recieved)); c->flags |= MG_F_CLOSE_IMMEDIATELY; state->status = 500; break; @@ -159,16 +159,16 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data, void *ud) { break; case MG_EV_CLOSE: // executed upon close connection - LOG(LL_INFO, ("HTTP status is %d, recieved %d bytes", state->status, state->recieved)); + LOG(LL_INFO, ("HTTP status is %d, recieved %lu bytes", state->status, state->recieved)); if (state->status == 200) { // write last block if ( spi_flash_erase_sector(state->curr_blk) != 0 ) { - LOG(LL_ERROR, ("flash delete error! abort at %d recieved bytes.", state->recieved)); + LOG(LL_ERROR, ("flash delete error! abort at %lu recieved bytes.", state->recieved)); break; } state->left_in_block = ( (state->curr_blk + 1) * BLOCK_SIZE ) - state->dest - state->recieved; if ( spi_flash_write( state->curr_blk * BLOCK_SIZE, (uint32 *) state->data, BLOCK_SIZE - state->left_in_block) != 0 ) { - LOG(LL_ERROR, ("flash write error! abort at %d recieved bytes.", state->recieved)); + LOG(LL_ERROR, ("flash write error! abort at %lu recieved bytes.", state->recieved)); break; } LOG(LL_DEBUG, ("last block dump done")); @@ -250,7 +250,7 @@ void download_file_to_flash(const char *url, uint32 dest) { state->recieved = 0; state->curr_blk = dest / BLOCK_SIZE; - LOG(LL_DEBUG, ("fetching %s to 0x%x", url, dest)); + LOG(LL_DEBUG, ("fetching %s to 0x%lx", url, dest)); mg_connect_http(mgos_get_mgr(), http_cb, state, url, NULL, NULL); return; }; From 757ad5c0557f55363c665b35a898bfe1917cacc4 Mon Sep 17 00:00:00 2001 From: Mark Dornbach Date: Mon, 18 Jan 2021 12:28:43 +0100 Subject: [PATCH 4/5] make 302 redirects case insensitive towards location header --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 53ae730..bfa95dd 100644 --- a/src/main.c +++ b/src/main.c @@ -141,7 +141,7 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data, void *ud) { if (hm->resp_code == 302) { // follow http redirect ... for (int i = 0; i < MG_MAX_HTTP_HEADERS; i++) { - if ( mg_strstr(hm->header_names[i], mg_mk_str("location") ) != NULL ) { + if ( mg_strcasecmp(hm->header_names[i], mg_mk_str("location") ) == 0 ) { LOG(LL_DEBUG, ("302 redirect to %.*s", hm->header_values[i].len, hm->header_values[i].p)); char *url; From 58aec3dc034766563f2874510701cedccec5d1c4 Mon Sep 17 00:00:00 2001 From: Mark Dornbach Date: Mon, 18 Jan 2021 13:41:57 +0100 Subject: [PATCH 5/5] bump version to 0.4.6 --- mos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mos.yml b/mos.yml index a566582..1b81e1f 100644 --- a/mos.yml +++ b/mos.yml @@ -1,7 +1,7 @@ author: mark dornbach description: a minimal firmware for ota flashing tasmota from mongoose os platform: esp8266 -version: 0.4.4 +version: 0.4.6 libs_version: ${mos.version} modules_version: ${mos.version}