diff --git a/components/platform_console/cmd_config.c b/components/platform_console/cmd_config.c index f7f2d2e9..906bc3cc 100644 --- a/components/platform_console/cmd_config.c +++ b/components/platform_console/cmd_config.c @@ -1001,8 +1001,12 @@ void register_config_cmd(void){ register_audio_config(); // register_squeezelite_config(); register_bt_source_config(); - register_i2s_config(); - register_spdif_config(); + if(!is_dac_config_locked()){ + register_i2s_config(); + } + if(!is_spdif_config_locked()){ + register_spdif_config(); + } register_rotary_config(); } diff --git a/components/squeezelite-ota/squeezelite-ota.c b/components/squeezelite-ota/squeezelite-ota.c index fa83151b..b31777fe 100644 --- a/components/squeezelite-ota/squeezelite-ota.c +++ b/components/squeezelite-ota/squeezelite-ota.c @@ -633,7 +633,7 @@ void ota_task(void *pvParameter) gettimeofday(&tv, NULL); uint32_t elapsed_ms= (tv.tv_sec-ota_status->OTA_start.tv_sec )*1000+(tv.tv_usec-ota_status->OTA_start.tv_usec)/1000; ESP_LOGI(TAG,"OTA progress : %d/%.0f (%d pct), %d KB/s", ota_status->actual_image_len, ota_status->total_image_len, ota_status->newpct, elapsed_ms>0?ota_status->actual_image_len*1000/elapsed_ms/1024:0); - sendMessaging(MESSAGING_INFO,"Writing binary file %%%3d.",ota_status->newpct); + sendMessaging(MESSAGING_INFO,"Writing binary file %3d %%.",ota_status->newpct); ota_status->lastpct=ota_status->newpct; } taskYIELD(); @@ -662,7 +662,7 @@ void ota_task(void *pvParameter) ESP_LOGI(TAG,"OTA Process completed successfully!"); sendMessaging(MESSAGING_INFO,"Success!"); IF_DISPLAY(GDS_TextLine(display, 2, GDS_TEXT_LEFT, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, "Success!")); - vTaskDelay(1500/ portTICK_PERIOD_MS); // wait here to give the UI a chance to refresh + vTaskDelay(3500/ portTICK_PERIOD_MS); // wait here to give the UI a chance to refresh IF_DISPLAY(GDS_Clear(display,GDS_COLOR_BLACK)); esp_restart(); } else { diff --git a/components/wifi-manager/webapp/.eslintcache b/components/wifi-manager/webapp/.eslintcache index a3a26952..50e15714 100644 --- a/components/wifi-manager/webapp/.eslintcache +++ b/components/wifi-manager/webapp/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\test.js":"1","C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\custom.js":"2"},{"size":4775,"mtime":1608244817341,"results":"3","hashOfConfig":"4"},{"size":57729,"mtime":1618063084495,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"8"},"1lj4yrw",{"filePath":"9","messages":"10","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\test.js",[],[],"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\custom.js",[]] \ No newline at end of file +[{"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\test.js":"1","C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\custom.js":"2"},{"size":4775,"mtime":1608244817341,"results":"3","hashOfConfig":"4"},{"size":61704,"mtime":1618437799595,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"8"},"1275pne",{"filePath":"9","messages":"10","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\test.js",[],[],"C:\\Users\\sle11\\Documents\\VSCode\\squeezelite-esp32\\components\\wifi-manager\\webapp\\src\\js\\custom.js",[]] \ No newline at end of file diff --git a/components/wifi-manager/webapp/mock/messages_ota.json b/components/wifi-manager/webapp/mock/messages_ota.json index 1fa12cac..5aa452e2 100644 --- a/components/wifi-manager/webapp/mock/messages_ota.json +++ b/components/wifi-manager/webapp/mock/messages_ota.json @@ -1,51 +1,123 @@ -[{ +[ + { + "message": "Save Success", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_SYSTEM", + "sent_time": 14084, + "current_time": 16958 + }, { "message": "{\"ota_dsc\":\"Initializing...\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119203, - "current_time": 121837 + "sent_time": 14110, + "current_time": 16958 }, { "message": "{\"ota_dsc\":\"Starting OTA...\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 + "sent_time": 14146, + "current_time": 16958 }, { - "message": "{\"ota_dsc\":\"Erasing...\",\"ota_pct\":0}", + "message": "{\"ota_dsc\":\"Downloading firmware\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 - }, { - "message": "{\"ota_dsc\":\"Erasing...\",\"ota_pct\":10}", + "sent_time": 15208, + "current_time": 16958 + }, + { + "message": "{\"ota_dsc\":\"Download success\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 + "sent_time": 18825, + "current_time": 22219 }, { - "message": "{\"ota_dsc\":\"Erasing...\",\"ota_pct\":100}", + "message": "{\"ota_dsc\":\"New version is : mock version \",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 + "sent_time": 18849, + "current_time": 22220 }, { - "message": "{\"ota_dsc\":\"Flashing...\",\"ota_pct\":10}", + "message": "{\"ota_dsc\":\"Formatting OTA partition\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 + "sent_time": 18850, + "current_time": 22220 }, { - "message": "{\"ota_dsc\":\"Erasing...\",\"ota_pct\":90}", + "message": "{\"ota_dsc\":\"Erasing flash (1/11)\",\"ota_pct\":0}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", - "sent_time": 119255, - "current_time": 121838 + "sent_time": 22217, + "current_time": 22220 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (5/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 29896, + "current_time": 29902 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (7/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 33395, + "current_time": 33408 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (9/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 36843, + "current_time": 54597 }, { + "message": "{\"ota_dsc\":\"Erasing flash complete.\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 39463, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":5}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 41862, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":10}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 44003, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":40}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 56678, + "current_time": 65185 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":70}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 69407, + "current_time": 77858 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":95}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 80010, + "current_time": 82592 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":100}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 82084, + "current_time": 82592 + }, + { "message": "{\"ota_dsc\":\"Success!\",\"ota_pct\":100}", "type": "MESSAGING_INFO", "class": "MESSAGING_CLASS_OTA", "sent_time": 119255, "current_time": 121838 } - + ] \ No newline at end of file diff --git a/components/wifi-manager/webapp/mock/messages_ota_flash.json b/components/wifi-manager/webapp/mock/messages_ota_flash.json new file mode 100644 index 00000000..fddd83b9 --- /dev/null +++ b/components/wifi-manager/webapp/mock/messages_ota_flash.json @@ -0,0 +1,117 @@ +[ + { + "message": "{\"ota_dsc\":\"Initializing...\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 14110, + "current_time": 16958 + }, { + "message": "{\"ota_dsc\":\"Starting OTA...\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 14146, + "current_time": 16958 + }, { + "message": "{\"ota_dsc\":\"New version is : mock version \",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 18849, + "current_time": 22220 + }, { + "message": "{\"ota_dsc\":\"Formatting OTA partition\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 18850, + "current_time": 22220 + }, { + "message": "{\"ota_dsc\":\"Erasing flash (1/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 22217, + "current_time": 22220 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (5/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 29896, + "current_time": 29902 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (7/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 33395, + "current_time": 33408 + }, + { + "message": "{\"ota_dsc\":\"Erasing flash (9/11)\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 36843, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Erasing flash complete.\",\"ota_pct\":0}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 39463, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":5}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 41862, + "current_time": 54597 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":25}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 50307, + "current_time": 54598 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":30}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 52455, + "current_time": 54598 + }, + { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":35}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 54603, + "current_time": 65184 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":55}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 63042, + "current_time": 65185 + }, + { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":60}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 65190, + "current_time": 77858 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":95}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 80010, + "current_time": 82592 + }, { + "message": "{\"ota_dsc\":\"Writing binary file\",\"ota_pct\":100}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 82084, + "current_time": 82592 + }, + { + "message": "{\"ota_dsc\":\"Success!\",\"ota_pct\":100}", + "type": "MESSAGING_INFO", + "class": "MESSAGING_CLASS_OTA", + "sent_time": 119255, + "current_time": 121838 + } + ] \ No newline at end of file diff --git a/components/wifi-manager/webapp/mock/status.json b/components/wifi-manager/webapp/mock/status.json index 29890ed6..dafbadf1 100644 --- a/components/wifi-manager/webapp/mock/status.json +++ b/components/wifi-manager/webapp/mock/status.json @@ -18,6 +18,9 @@ "lms_cport": 9090, "lms_port": 9100, "lms_ip": "127.0.0.1", + "platform_name": "SqueezeAmp", "mock_plugin_has_proxy": "x", - "platform_name": "SqueezeAmp" + "mock_fail_fw_update":"", + "mock_fail_recovery":"", + "mock_old_recovery":"" } \ No newline at end of file diff --git a/components/wifi-manager/webapp/src/index.ejs b/components/wifi-manager/webapp/src/index.ejs index 94ef8fb5..60b8da16 100644 --- a/components/wifi-manager/webapp/src/index.ejs +++ b/components/wifi-manager/webapp/src/index.ejs @@ -26,11 +26,11 @@ -
+
@@ -185,10 +185,10 @@ -
\ No newline at end of file +SqueezeESP32
Software Updates
VersionDate/TimePlatformBranchBit Depth
Local Firmware Upload
KeyValue
Usage Templates
Output
WiFi Status
JoinedNameSignalSecurity
Logs
TimestampMessage
Tasks
#Task NameCPUStateMin StackBase PriorityCur Priority
Credits

squeezelite-esp32
© 2020, philippe44, sle118, daduke
This software is released under the MIT License.

This app would not be possible without the following libraries:

  • squeezelite, © 2012-2019, Adrian Smith and Ralph Irving. Licensed under the GPL License.
  • esp32-wifi-manager, © 2017-2019, Tony Pottier. Licensed under the MIT License.
  • SpinKit, © 2015, Tobias Ahlin. Licensed under the MIT License.
  • jQuery, The jQuery Foundation. Licensed under the MIT License.
  • cJSON, © 2009-2017, Dave Gamble and cJSON contributors. Licensed under the MIT License.
  • esp32-rotary-encoder, © 2011-2019, David Antliff and Ben Buxton. Licensed under the GPL License.
  • tarablessd1306, © 2017-2018, Tara Keeling. Licensed under the MIT license.
Extras/Overrides
\ No newline at end of file diff --git a/components/wifi-manager/webapp/webpack/dist/index.html.br b/components/wifi-manager/webapp/webpack/dist/index.html.br index c739e49c..d66be4e4 100644 Binary files a/components/wifi-manager/webapp/webpack/dist/index.html.br and b/components/wifi-manager/webapp/webpack/dist/index.html.br differ diff --git a/components/wifi-manager/webapp/webpack/dist/index.html.gz b/components/wifi-manager/webapp/webpack/dist/index.html.gz index 572e4b44..afe16bea 100644 Binary files a/components/wifi-manager/webapp/webpack/dist/index.html.gz and b/components/wifi-manager/webapp/webpack/dist/index.html.gz differ diff --git a/components/wifi-manager/webapp/webpack/webpack.dev.js b/components/wifi-manager/webapp/webpack/webpack.dev.js index 45a0c5ae..1ec43ca3 100644 --- a/components/wifi-manager/webapp/webpack/webpack.dev.js +++ b/components/wifi-manager/webapp/webpack/webpack.dev.js @@ -15,7 +15,9 @@ const data = { messages: require("../mock/messages.json"), messagequeue: require("../mock/messages.json"), message_queue_sequence: [], + status_queue_sequence:[], message_queue_sequence_post_empty: null, + status_queue_sequence_post_empty: null, commands: require("../mock/commands.json"), scan: require("../mock/scan.json"), ap: require("../mock/ap.json"), @@ -23,6 +25,7 @@ const data = { statusdefinition: require("../mock/statusdefinition.json"), status: require("../mock/status.json"), messages_ota_fail: require("../mock/messages_ota_fail.json"), + messages_ota_flash: require("../mock/messages_ota_flash.json"), messages_ota: require("../mock/messages_ota.json") }; const messagingTypes= { @@ -123,8 +126,47 @@ module.exports = merge(common, { app.use(bodyParser.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded app.get('/ap.json', function(req, res) { res.json( data.ap ); }); app.get('/scan.json', function(req, res) { res.json( data.scan ); }); - app.get('/config.json', function(req, res) { res.json( data.config ); }); - app.get('/status.json', function(req, res) { res.json( data.status ); }); + app.get('/config.json', function(req, res) { + if(data.status.recovery==1 && (data.status.mock_old_recovery??'')!==''){ + res.json( data.config.config ); + console.log('Mock old recovery - return config structure without gpio'); + } + else { + res.json( data.config ); + } + }); + + app.get('/status.json', function(req, res) { + if(data.status_queue_sequence.length>0){ + const curstatus = JSON.parse(data.status_queue_sequence_queue_sequence.shift()); + data.status.ota_pct=curstatus.ota_pct??0; + data.status.ota_dsc=curstatus.ota_dsc??''; + console.log(`Mock firmware update @${data.status.ota_pct}%, ${data.status.ota_dsc}`) + } + else if (data.status_queue_sequence_post_empty){ + data.status_queue_sequence_post_emptyy(); + console.log(`Mock old firmware update: simulating a restart`); + data.status_queue_sequence_post_empty = null; + } + else if(data.status.ota_pct!=undefined || data.status.ota_dsc!=undefined) { + if(data.status.ota_pct!=undefined) delete data.status.ota_pct; + if(data.status.ota_dsc!=undefined) delete data.status.ota_dsc; + } + if(data.status.message) delete data.status.message; + if(data.status.recovery==1 && (data.status.mock_old_recovery??'')!==''){ + if(data.message_queue_sequence.length>0){ + + const msgpayload = JSON.parse(data.message_queue_sequence.shift()); + data.status.message = msgpayload.message??''; + console.log(`Mocking recovery, setting status message to ${data.status.message}`) + } + else if (data.message_queue_sequence_post_empty){ + data.message_queue_sequence_post_empty(); + data.message_queue_sequence_post_empty = null; + } + } + res.json( data.status ); + }); app.get('/plugins/SqueezeESP32/firmware/-99', function(req, res) { let has_proxy= data.status.mock_plugin_has_proxy ?? 'n'; const statusCode='xy'.includes((has_proxy).toLowerCase())?200:500; @@ -132,6 +174,11 @@ module.exports = merge(common, { res.status(statusCode ).json(); }); app.get('/messages.json', function(req, res) { + if(data.status.recovery==1 && (data.status.mock_old_recovery??'')!==''){ + console.log('Mocking old recovery, with no commands backend' ); + res.status(404).end(); + return; + } if(data.message_queue_sequence.length>0){ data.messagequeue.push(data.message_queue_sequence.shift()); } @@ -144,8 +191,22 @@ module.exports = merge(common, { }); app.get('/statusdefinition.json', function(req, res) { res.json( data.statusdefinition ); }); - app.get('/commands.json', function(req, res) { res.json( data.commands ); }); + app.get('/commands.json', function(req, res) { + if(data.status.recovery==1 && (data.status.mock_old_recovery??'')!==''){ + console.log('Mocking old recovery, with no commands backend' ); + res.status(404).end(); + } + else { + res.json( data.commands ); + } + + }); app.post('/commands.json', function(req, res) { + if(data.status.recovery==1 && (data.status.mock_old_recovery??'')!==''){ + console.log('Mocking old recovery, with no commands backend' ); + res.status(404).end(); + return; + } console.log(req.body.command); try { const cmdName=req.body.command.split(" ")[0]; @@ -189,23 +250,29 @@ module.exports = merge(common, { } res.json( {} ); if(fwurl!=='' ){ + const ota_msg_list= ((data.status.mock_fail_fw_update ?? '')!=='')?data.messages_ota_fail:data.messages_ota; if(data.status.recovery!=1) { // we're not yet in recovery. Simulate reboot to recovery data.status.recovery=1; - requeueMessages(); - } - if(fwurl.toLowerCase().includes('fail')){ - console.log(`queuing ${data.messages_ota_fail.length} ota messages `); - data.message_queue_sequence.push(...data.messages_ota_fail); - - } - else { - console.log(`queuing ${data.messages_ota.length} ota messages `); - data.message_queue_sequence.push(...data.messages_ota); - data.message_queue_sequence_post_empty = function(){ - data.status.recovery=0; + if((data.status.mock_old_recovery??'')===''){ + // older recovery partitions possibly aren't + // sending messages requeueMessages(); - } + } + + } + var targetQueue='message_queue_sequence'; + var targetPostEmpty='message_queue_sequence_post_empty'; + if((data.status.mock_old_recovery??'')!==''){ + console.log('Mocking old firmware flashing mechanism. Starting!'); + targetQueue='status_queue_sequence'; + targetPostEmpty='status_queue_sequence_post_empty'; + } + console.log(`queuing ${ota_msg_list.length} ota messages `); + data[targetQueue].push(...ota_msg_list); + data[targetPostEmpty] = function(){ + data.status.recovery=0; + requeueMessages(); } } }); @@ -220,7 +287,7 @@ module.exports = merge(common, { console.log(`Updated status value ${property}\nFrom: ${data.status[property]}\nTo: ${req.body.status[property]}`); data.status[property]=req.body.status[property]; } - } + } res.json( {} ); }); app.post('/connect.json', function(req, res) { @@ -251,17 +318,37 @@ module.exports = merge(common, { requeueMessages(); }); app.post('/recovery.json', function(req, res) { - data.status.recovery=1; - requeueMessages(); - res.json( { } ); + if((data.status.mock_fail_recovery ?? '')!==''){ + res.status(404).end(); + } + else { + data.status.recovery=1; + requeueMessages(); + res.json( { } ); + } }); app.post('/flash.json', function(req, res) { + if(data.status.recovery>0){ - res.json({}); - } - else { + if((data.status.mock_fail_fw_update ?? '')!=='' || (data.status.mock_old_recovery??'')!==''){ + console.log('Old recovery mock, or fw fail requested' ); + res.status(404).end(); + } + else { + console.log(`queuing ${data.messages_ota_flash.length} flash ota messages `); + data.message_queue_sequence.push(...data.messages_ota_flash); + data.message_queue_sequence_post_empty = function(){ + data.status.recovery=0; + requeueMessages(); + + } + res.json({}); + } + + } + else { res.status(404).end(); - } + } }); app.delete('/connect.json', function(req, res) { data.status.ssid='';