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 5ede30b..2203d1b 100644 --- a/README.md +++ b/README.md @@ -56,22 +56,23 @@ 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}` 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..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} @@ -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 diff --git a/src/main.c b/src/main.c index 3418914..bfa95dd 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; @@ -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; @@ -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; };