Skip to content

Commit

Permalink
Merge branch 'release/v0.4.6' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yaourdt committed Jan 18, 2021
2 parents e527a38 + 58aec3d commit f2f935a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion mos.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
author: mark dornbach <[email protected]>
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}
Expand Down Expand Up @@ -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
16 changes: 8 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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"));
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit f2f935a

Please sign in to comment.