From d5fc9054021de3d1e5d77078dfcbded32a1ebc37 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 5 Jan 2022 19:29:45 -0800 Subject: [PATCH 01/10] Don't delete contents of /static unless tar is downloaded --- src/mesh/http/ContentHandler.cpp | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index c051e0cda..efa47a767 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -57,7 +57,7 @@ char contentTypes[][2][32] = {{".txt", "text/plain"}, {".html", "text/html"} {".css", "text/css"}, {".ico", "image/vnd.microsoft.icon"}, {".svg", "image/svg+xml"}, {"", ""}}; -//const char *tarURL = "https://www.casler.org/temp/meshtastic-web.tar"; +// const char *tarURL = "https://www.casler.org/temp/meshtastic-web.tar"; const char *tarURL = "https://api-production-871d.up.railway.app/mirror/webui"; const char *certificate = NULL; // change this as needed, leave as is for no TLS check (yolo security) @@ -689,26 +689,29 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) res->println("Downloading Meshtastic Web Content..."); - File root = SPIFFS.open("/"); - File file = root.openNextFile(); - - DEBUG_MSG("Deleting files from /static\n"); - - while (file) { - String filePath = String(file.name()); - if (filePath.indexOf("/static") == 0) { - DEBUG_MSG("%s\n", file.name()); - SPIFFS.remove(file.name()); - } - file = root.openNextFile(); - } - - // return; - WiFiClientSecure *client = new WiFiClientSecure; Stream *streamptr = getTarHTTPClientPtr(client, tarURL, certificate); + delay(5); // Let other network operations run + if (streamptr != nullptr) { + DEBUG_MSG("Connection to content server ... success!\n"); + + File root = SPIFFS.open("/"); + File file = root.openNextFile(); + + DEBUG_MSG("Deleting files from /static\n"); + + while (file) { + String filePath = String(file.name()); + if (filePath.indexOf("/static") == 0) { + DEBUG_MSG("%s\n", file.name()); + SPIFFS.remove(file.name()); + } + file = root.openNextFile(); + } + + delay(5); // Let other network operations run TarUnpacker *TARUnpacker = new TarUnpacker(); TARUnpacker->haltOnError(false); // stop on fail (manual restart/reset required) @@ -731,7 +734,10 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) } if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) { + res->printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError()); Serial.printf("tarStreamExpander failed with return code #%d\n", TARUnpacker->tarGzGetError()); + + return; } else { // print leftover bytes if any (probably zero-fill from the server) while (http.connected()) { @@ -744,7 +750,9 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) } } else { + res->printf("Failed to establish http connection\n"); Serial.println("Failed to establish http connection"); + return; } res->println("Done"); From dbdbe75e9f6f8ce2e8f754a4daeaa4cec79b498d Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 5 Jan 2022 19:44:21 -0800 Subject: [PATCH 02/10] Rename httpClient --- src/mesh/http/ContentHandler.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index efa47a767..189dfef0e 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -43,7 +43,7 @@ using namespace httpsserver; #include #include -HTTPClient http; +HTTPClient httpClient; #define DEST_FS_USES_SPIFFS #include @@ -73,22 +73,22 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const client->setCACert(cert); } const char *UserAgent = "ESP32-HTTP-GzUpdater-Client"; - http.setReuse(true); // handle 301 redirects gracefully - http.setUserAgent(UserAgent); - http.setConnectTimeout(10000); // 10s timeout = 10000 - if (!http.begin(*client, url)) { + httpClient.setReuse(true); // handle 301 redirects gracefully + httpClient.setUserAgent(UserAgent); + httpClient.setConnectTimeout(10000); // 10s timeout = 10000 + if (!httpClient.begin(*client, url)) { log_e("Can't open url %s", url); return nullptr; } const char *headerKeys[] = {"location", "redirect", "Content-Type", "Content-Length", "Content-Disposition"}; const size_t numberOfHeaders = 5; - http.collectHeaders(headerKeys, numberOfHeaders); - int httpCode = http.GET(); + httpClient.collectHeaders(headerKeys, numberOfHeaders); + int httpCode = httpClient.GET(); // file found at server if (httpCode == HTTP_CODE_FOUND || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { String newlocation = ""; - String headerLocation = http.header("location"); - String headerRedirect = http.header("redirect"); + String headerLocation = httpClient.header("location"); + String headerRedirect = httpClient.header("redirect"); if (headerLocation != "") { newlocation = headerLocation; Serial.printf("302 (location): %s => %s\n", url, headerLocation.c_str()); @@ -96,7 +96,7 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const Serial.printf("301 (redirect): %s => %s\n", url, headerLocation.c_str()); newlocation = headerRedirect; } - http.end(); + httpClient.end(); if (newlocation != "") { log_w("Found 302/301 location header: %s", newlocation.c_str()); return getTarHTTPClientPtr(client, newlocation.c_str(), cert); @@ -107,7 +107,7 @@ WiFiClient *getTarHTTPClientPtr(WiFiClientSecure *client, const char *url, const } if (httpCode != 200) return nullptr; - return http.getStreamPtr(); + return httpClient.getStreamPtr(); } void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) @@ -700,12 +700,12 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) File root = SPIFFS.open("/"); File file = root.openNextFile(); - DEBUG_MSG("Deleting files from /static\n"); + DEBUG_MSG("Deleting files from /static : \n"); while (file) { String filePath = String(file.name()); if (filePath.indexOf("/static") == 0) { - DEBUG_MSG("%s\n", file.name()); + DEBUG_MSG(" %s\n", file.name()); SPIFFS.remove(file.name()); } file = root.openNextFile(); @@ -724,7 +724,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) BaseUnpacker::defaultTarStatusProgressCallback); // print the filenames as they're expanded TARUnpacker->setTarMessageCallback(BaseUnpacker::targzPrintLoggerCallback); // tar log verbosity - String contentLengthStr = http.header("Content-Length"); + String contentLengthStr = httpClient.header("Content-Length"); contentLengthStr.trim(); int64_t streamSize = -1; if (contentLengthStr != "") { @@ -739,14 +739,16 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) return; } else { + /* // print leftover bytes if any (probably zero-fill from the server) - while (http.connected()) { + while (httpClient.connected()) { size_t streamSize = streamptr->available(); if (streamSize) { Serial.printf("%02x ", streamptr->read()); } else break; } + */ } } else { From 3a178228939aa40fa2afb2225c80cf3b565bfd82 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 5 Jan 2022 22:12:32 -0800 Subject: [PATCH 03/10] Fixed TLS "memory allocation failure" --- src/mesh/http/ContentHandler.cpp | 51 +++++++++++++++++++++++++++----- src/mesh/http/ContentHandler.h | 2 ++ src/mesh/http/WebServer.cpp | 4 +++ src/mesh/http/WebServer.h | 1 + 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 189dfef0e..043d3275d 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -4,6 +4,7 @@ #include "airtime.h" #include "main.h" #include "mesh/http/ContentHelper.h" +#include "mesh/http/WebServer.h" #include "mesh/http/WiFiAPClient.h" #include "power.h" #include "sleep.h" @@ -123,7 +124,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); - ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/update", "GET", &handleUpdateSPIFFS); + ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/spiffs/update", "POST", &handleUpdateSPIFFS); + ResourceNode *nodeDeleteSPIFFS = new ResourceNode("/spiffs/delete", "GET", &handleDeleteSPIFFSContent); ResourceNode *nodeRestart = new ResourceNode("/restart", "POST", &handleRestart); ResourceNode *nodeFormUpload = new ResourceNode("/upload", "POST", &handleFormUpload); @@ -150,6 +152,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) secureServer->registerNode(nodeJsonDelete); secureServer->registerNode(nodeJsonReport); secureServer->registerNode(nodeUpdateSPIFFS); + secureServer->registerNode(nodeDeleteSPIFFS); secureServer->registerNode(nodeRoot); // This has to be last // Insecure nodes @@ -166,6 +169,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) insecureServer->registerNode(nodeJsonDelete); insecureServer->registerNode(nodeJsonReport); insecureServer->registerNode(nodeUpdateSPIFFS); + insecureServer->registerNode(nodeDeleteSPIFFS); insecureServer->registerNode(nodeRoot); // This has to be last } @@ -368,8 +372,10 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) if (!file.available()) { DEBUG_MSG("File not available - %s\n", filenameGzip.c_str()); res->println("Web server is running.

The content you are looking for can't be found. Please see: FAQ.

stats

Experemntal Web Content OTA Update"); + "href=https://meshtastic.org/docs/getting-started/faq#wifi--web-browser>FAQ.

Experimental " + "Web Content OTA Update -- Click " + "this just once and wait. Be patient!
"); } else { res->setHeader("Content-Encoding", "gzip"); } @@ -685,7 +691,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) { res->setHeader("Content-Type", "text/html"); res->setHeader("Access-Control-Allow-Origin", "*"); - res->setHeader("Access-Control-Allow-Methods", "GET"); + // res->setHeader("Access-Control-Allow-Methods", "POST"); res->println("Downloading Meshtastic Web Content..."); @@ -730,7 +736,7 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) if (contentLengthStr != "") { streamSize = atoi(contentLengthStr.c_str()); Serial.printf("Stream size %d\n", streamSize); - res->printf("Stream size %d\n", streamSize); + res->printf("Stream size %d

\n", streamSize); } if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, SPIFFS, "/static")) { @@ -757,7 +763,38 @@ void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res) return; } - res->println("Done"); + res->println("Done! Restarting the device. Click this in 10 seconds"); + + /* + * This is a work around for a bug where we run out of memory. + * TODO: Fixme! + */ + // ESP.restart(); + webServerThread->requestRestart = (millis() / 1000) + 5; +} + +void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res) +{ + res->setHeader("Content-Type", "text/html"); + res->setHeader("Access-Control-Allow-Origin", "*"); + res->setHeader("Access-Control-Allow-Methods", "GET"); + + res->println("Deleting SPIFFS Content in /static/*"); + + File root = SPIFFS.open("/"); + File file = root.openNextFile(); + + DEBUG_MSG("Deleting files from /static : \n"); + + while (file) { + String filePath = String(file.name()); + if (filePath.indexOf("/static") == 0) { + DEBUG_MSG(" %s\n", file.name()); + SPIFFS.remove(file.name()); + } + file = root.openNextFile(); + } + } void handleRestart(HTTPRequest *req, HTTPResponse *res) @@ -769,7 +806,7 @@ void handleRestart(HTTPRequest *req, HTTPResponse *res) DEBUG_MSG("***** Restarted on HTTP(s) Request *****\n"); res->println("Restarting"); - ESP.restart(); + webServerThread->requestRestart = (millis() / 1000) + 5; } void handleBlinkLED(HTTPRequest *req, HTTPResponse *res) diff --git a/src/mesh/http/ContentHandler.h b/src/mesh/http/ContentHandler.h index f456d0a1f..2a89b3df6 100644 --- a/src/mesh/http/ContentHandler.h +++ b/src/mesh/http/ContentHandler.h @@ -16,6 +16,8 @@ void handleSpiffsDeleteStatic(HTTPRequest *req, HTTPResponse *res); void handleBlinkLED(HTTPRequest *req, HTTPResponse *res); void handleReport(HTTPRequest *req, HTTPResponse *res); void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res); +void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res); + // Interface to the PhoneAPI to access the protobufs with messages class HttpAPI : public PhoneAPI diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index cbf25271d..d9d2ca6b4 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -175,6 +175,10 @@ int32_t WebServerThread::runOnce() // DEBUG_MSG("WebServerThread::runOnce()\n"); handleWebResponse(); + if (requestRestart && (millis() / 1000) > requestRestart) { + ESP.restart(); + } + // Loop every 5ms. return (5); } diff --git a/src/mesh/http/WebServer.h b/src/mesh/http/WebServer.h index 63a61367d..b036a303d 100644 --- a/src/mesh/http/WebServer.h +++ b/src/mesh/http/WebServer.h @@ -13,6 +13,7 @@ class WebServerThread : private concurrency::OSThread public: WebServerThread(); + uint32_t requestRestart = 0; protected: virtual int32_t runOnce(); From 76d0ad2907f4b9dfd41fe825096dea4c5092a5b7 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 5 Jan 2022 22:27:49 -0800 Subject: [PATCH 04/10] Add page with links to end points on /spiffs --- src/mesh/http/ContentHandler.cpp | 23 ++++++++++++++++++----- src/mesh/http/ContentHandler.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 043d3275d..4799494ef 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -124,6 +124,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) ResourceNode *nodeHotspotApple = new ResourceNode("/hotspot-detect.html", "GET", &handleHotspot); ResourceNode *nodeHotspotAndroid = new ResourceNode("/generate_204", "GET", &handleHotspot); + ResourceNode *nodeSPIFFS = new ResourceNode("/spiffs", "GET", &handleSPIFFS); ResourceNode *nodeUpdateSPIFFS = new ResourceNode("/spiffs/update", "POST", &handleUpdateSPIFFS); ResourceNode *nodeDeleteSPIFFS = new ResourceNode("/spiffs/delete", "GET", &handleDeleteSPIFFSContent); @@ -153,6 +154,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) secureServer->registerNode(nodeJsonReport); secureServer->registerNode(nodeUpdateSPIFFS); secureServer->registerNode(nodeDeleteSPIFFS); + secureServer->registerNode(nodeSPIFFS); secureServer->registerNode(nodeRoot); // This has to be last // Insecure nodes @@ -170,6 +172,7 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer) insecureServer->registerNode(nodeJsonReport); insecureServer->registerNode(nodeUpdateSPIFFS); insecureServer->registerNode(nodeDeleteSPIFFS); + insecureServer->registerNode(nodeSPIFFS); insecureServer->registerNode(nodeRoot); // This has to be last } @@ -371,11 +374,12 @@ void handleStatic(HTTPRequest *req, HTTPResponse *res) res->setHeader("Content-Type", "text/html"); if (!file.available()) { DEBUG_MSG("File not available - %s\n", filenameGzip.c_str()); - res->println("Web server is running.

The content you are looking for can't be found. Please see: FAQ.

Experimental " - "Web Content OTA Update -- Click " - "this just once and wait. Be patient!
"); + res->println( + "Web server is running.

The content you are looking for can't be found. Please see: FAQ.

Experimental " + "Web Content OTA Update -- Click " + "this just once and wait. Be patient!
"); } else { res->setHeader("Content-Encoding", "gzip"); } @@ -794,7 +798,16 @@ void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res) } file = root.openNextFile(); } +} +void handleSPIFFS(HTTPRequest *req, HTTPResponse *res) +{ + res->setHeader("Content-Type", "text/html"); + res->setHeader("Access-Control-Allow-Origin", "*"); + res->setHeader("Access-Control-Allow-Methods", "GET"); + + res->println("Delete Web Content

Be patient!"); } void handleRestart(HTTPRequest *req, HTTPResponse *res) diff --git a/src/mesh/http/ContentHandler.h b/src/mesh/http/ContentHandler.h index 2a89b3df6..4dfb86944 100644 --- a/src/mesh/http/ContentHandler.h +++ b/src/mesh/http/ContentHandler.h @@ -17,6 +17,7 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res); void handleReport(HTTPRequest *req, HTTPResponse *res); void handleUpdateSPIFFS(HTTPRequest *req, HTTPResponse *res); void handleDeleteSPIFFSContent(HTTPRequest *req, HTTPResponse *res); +void handleSPIFFS(HTTPRequest *req, HTTPResponse *res); // Interface to the PhoneAPI to access the protobufs with messages From 9d8a1b3522ebca3db031d8b183f96c0f67cfac21 Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Thu, 6 Jan 2022 19:25:16 +0300 Subject: [PATCH 05/10] Feature: add disable_tx setting #1065 --- src/mesh/RadioLibInterface.cpp | 3 ++- src/mesh/generated/admin.pb.h | 4 ++-- src/mesh/generated/radioconfig.pb.h | 13 ++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 4455b971c..89b4b11bc 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -93,7 +93,8 @@ bool RadioLibInterface::canSendImmediately() /// bluetooth comms code. If the txmit queue is empty it might return an error ErrorCode RadioLibInterface::send(MeshPacket *p) { - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { + DEBUG_MSG("send - lora_tx_disabled\n"); packetPool.release(p); return ERRNO_DISABLED; } diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index ebc6fc9a0..d75c2b418 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -5,8 +5,8 @@ #define PB_ADMIN_PB_H_INCLUDED #include #include "channel.pb.h" -#include "radioconfig.pb.h" #include "mesh.pb.h" +#include "radioconfig.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 529 +#define AdminMessage_size 532 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index f1ce58de1..9eb6fa875 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -155,6 +155,7 @@ typedef struct _RadioConfig_UserPreferences { uint32_t hop_limit; char mqtt_username[32]; char mqtt_password[32]; + bool is_lora_tx_disabled; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -199,9 +200,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -272,6 +273,7 @@ extern "C" { #define RadioConfig_UserPreferences_hop_limit_tag 154 #define RadioConfig_UserPreferences_mqtt_username_tag 155 #define RadioConfig_UserPreferences_mqtt_password_tag 156 +#define RadioConfig_UserPreferences_is_lora_tx_disabled_tag 157 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -349,7 +351,8 @@ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \ X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \ X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) \ X(a, STATIC, SINGULAR, STRING, mqtt_username, 155) \ -X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) +X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) \ +X(a, STATIC, SINGULAR, BOOL, is_lora_tx_disabled, 157) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -361,8 +364,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 526 -#define RadioConfig_UserPreferences_size 523 +#define RadioConfig_size 529 +#define RadioConfig_UserPreferences_size 526 #ifdef __cplusplus } /* extern "C" */ From b6eb927ad2d6c86f76cd0a0cea70086e63a261db Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Thu, 6 Jan 2022 20:00:53 +0300 Subject: [PATCH 06/10] Missed a spot to disable. --- src/mesh/RadioLibInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 89b4b11bc..67c1ad4a6 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -301,7 +301,7 @@ void RadioLibInterface::handleReceiveInterrupt() void RadioLibInterface::startSend(MeshPacket *txp) { printPacket("Starting low level send", txp); - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { DEBUG_MSG("startSend is dropping tx packet because we are disabled\n"); packetPool.release(txp); } else { From 1c63d2d33409cc8e812a0f6731f8dce5d5504ae5 Mon Sep 17 00:00:00 2001 From: ernax78 <65963237+ernax78@users.noreply.github.com> Date: Thu, 6 Jan 2022 21:01:45 +0300 Subject: [PATCH 07/10] Feature: add disable_tx setting #1065 (#1066) * Feature: add disable_tx setting #1065 --- src/mesh/RadioLibInterface.cpp | 5 +++-- src/mesh/generated/admin.pb.h | 4 ++-- src/mesh/generated/radioconfig.pb.h | 13 ++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 4455b971c..67c1ad4a6 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -93,7 +93,8 @@ bool RadioLibInterface::canSendImmediately() /// bluetooth comms code. If the txmit queue is empty it might return an error ErrorCode RadioLibInterface::send(MeshPacket *p) { - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { + DEBUG_MSG("send - lora_tx_disabled\n"); packetPool.release(p); return ERRNO_DISABLED; } @@ -300,7 +301,7 @@ void RadioLibInterface::handleReceiveInterrupt() void RadioLibInterface::startSend(MeshPacket *txp) { printPacket("Starting low level send", txp); - if (disabled) { + if (disabled || radioConfig.preferences.is_lora_tx_disabled) { DEBUG_MSG("startSend is dropping tx packet because we are disabled\n"); packetPool.release(txp); } else { diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index ebc6fc9a0..d75c2b418 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -5,8 +5,8 @@ #define PB_ADMIN_PB_H_INCLUDED #include #include "channel.pb.h" -#include "radioconfig.pb.h" #include "mesh.pb.h" +#include "radioconfig.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 529 +#define AdminMessage_size 532 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index f1ce58de1..9eb6fa875 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -155,6 +155,7 @@ typedef struct _RadioConfig_UserPreferences { uint32_t hop_limit; char mqtt_username[32]; char mqtt_password[32]; + bool is_lora_tx_disabled; } RadioConfig_UserPreferences; typedef struct _RadioConfig { @@ -199,9 +200,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", ""} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -272,6 +273,7 @@ extern "C" { #define RadioConfig_UserPreferences_hop_limit_tag 154 #define RadioConfig_UserPreferences_mqtt_username_tag 155 #define RadioConfig_UserPreferences_mqtt_password_tag 156 +#define RadioConfig_UserPreferences_is_lora_tx_disabled_tag 157 #define RadioConfig_preferences_tag 1 /* Struct field encoding specification for nanopb */ @@ -349,7 +351,8 @@ X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \ X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \ X(a, STATIC, SINGULAR, UINT32, hop_limit, 154) \ X(a, STATIC, SINGULAR, STRING, mqtt_username, 155) \ -X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) +X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) \ +X(a, STATIC, SINGULAR, BOOL, is_lora_tx_disabled, 157) #define RadioConfig_UserPreferences_CALLBACK NULL #define RadioConfig_UserPreferences_DEFAULT NULL @@ -361,8 +364,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 526 -#define RadioConfig_UserPreferences_size 523 +#define RadioConfig_size 529 +#define RadioConfig_UserPreferences_size 526 #ifdef __cplusplus } /* extern "C" */ From dff219a0373462569cc58196d32c6fc7b4efe264 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Thu, 6 Jan 2022 10:46:13 -0800 Subject: [PATCH 08/10] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 7b80bde42..5ab590add 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 7b80bde4213c530ab3d85a19d1795025299d4633 +Subproject commit 5ab590addb44f85b0590c49d09b9e0efd0e521bd From 17dfb7d15225b2ccbd77e4f19da4ddebc2b428e6 Mon Sep 17 00:00:00 2001 From: Erik R Norell Date: Fri, 7 Jan 2022 09:57:29 +0300 Subject: [PATCH 09/10] Touch on T-Echo to refresh e-ink screen --- src/configuration.h | 4 ++++ src/main.cpp | 49 +++++++++++++++++++++++++++++++++++++++ variants/t-echo/variant.h | 1 + 3 files changed, 54 insertions(+) diff --git a/src/configuration.h b/src/configuration.h index 89fa106ff..57469bfd5 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -84,6 +84,10 @@ along with this program. If not, see . #define BUTTON_PIN_ALT PIN_BUTTON2 #endif +#ifdef PIN_BUTTON_TOUCH +#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH +#endif + // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) #elif defined(CubeCell_BoardPlus) diff --git a/src/main.cpp b/src/main.cpp index 41d504e40..15085034d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -187,6 +187,9 @@ class ButtonThread : public OSThread #endif #ifdef BUTTON_PIN_ALT OneButton userButtonAlt; +#endif +#ifdef BUTTON_PIN_TOUCH + OneButton userButtonTouch; #endif static bool shutdown_on_long_stop; @@ -222,6 +225,21 @@ class ButtonThread : public OSThread userButtonAlt.attachLongPressStop(userButtonPressedLongStop); wakeOnIrq(BUTTON_PIN_ALT, FALLING); #endif + +#ifdef BUTTON_PIN_TOUCH + userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); +#ifdef INPUT_PULLUP_SENSE + // Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did + pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE); +#endif + userButtonTouch.attachClick(touchPressed); + userButtonTouch.attachDuringLongPress(touchPressedLong); + userButtonTouch.attachDoubleClick(touchDoublePressed); + userButtonTouch.attachLongPressStart(touchPressedLongStart); + userButtonTouch.attachLongPressStop(touchPressedLongStop); + wakeOnIrq(BUTTON_PIN_TOUCH, FALLING); +#endif + } protected: @@ -237,6 +255,10 @@ class ButtonThread : public OSThread #ifdef BUTTON_PIN_ALT userButtonAlt.tick(); canSleep &= userButtonAlt.isIdle(); +#endif +#ifdef BUTTON_PIN_TOUCH + userButtonTouch.tick(); + canSleep &= userButtonTouch.isIdle(); #endif // if (!canSleep) DEBUG_MSG("Supressing sleep!\n"); // else DEBUG_MSG("sleep ok\n"); @@ -245,6 +267,33 @@ class ButtonThread : public OSThread } private: + static void touchPressed() + { + screen->forceDisplay(); + DEBUG_MSG("touch press!\n"); + } + static void touchDoublePressed() + { + DEBUG_MSG("touch double press!\n"); + } + static void touchPressedLong() + { + DEBUG_MSG("touch press long!\n"); + } + static void touchDoublePressedLong() + { + DEBUG_MSG("touch double pressed!\n"); + } + static void touchPressedLongStart() + { + DEBUG_MSG("touch long press start!\n"); + } + static void touchPressedLongStop() + { + DEBUG_MSG("touch long press stop!\n"); + } + + static void userButtonPressed() { // DEBUG_MSG("press!\n"); diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index df57ee913..a1471c67b 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -120,6 +120,7 @@ extern "C" { */ #define PIN_BUTTON1 (32 + 10) #define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO +#define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo /* * Analog pins From 706d6e2671d854c89fa8578401a02954c6958b9c Mon Sep 17 00:00:00 2001 From: Jordan Mulcahey Date: Fri, 7 Jan 2022 02:29:58 -0800 Subject: [PATCH 10/10] Use /usr/bin/env in bash and python script shebangs --- bin/build-all.sh | 2 +- bin/dump-ram-users.sh | 2 ++ bin/gen-images.sh | 2 +- bin/genpartitions.py | 4 ++-- bin/install-bootloader.sh | 2 ++ bin/install-eink.sh | 2 ++ bin/mqtt-listen.sh | 1 + bin/mqtt-send-status.sh | 2 ++ bin/native-gdbserver.sh | 2 ++ bin/native-run.sh | 2 ++ bin/nrf52-console.sh | 4 ++-- bin/nrf52832-gdbserver.sh | 2 +- bin/nrf52833-gdbserver.sh | 2 +- bin/nrf52840-gdbserver.sh | 2 +- bin/program-1.0-tbeam.sh | 2 ++ bin/program-1.1-tbeam.sh | 2 ++ bin/program-release-heltec.sh | 1 + bin/program-release-tbeam.sh | 1 + bin/program-release-universal.sh | 1 + bin/promote-release.sh | 2 ++ bin/qspi-flash-test.sh | 2 ++ bin/read-system-info.sh | 2 ++ bin/regen-protos.sh | 4 ++-- bin/run-0-monitor.sh | 2 ++ bin/run-1-monitor.sh | 2 ++ bin/run-both-monitor.sh | 2 ++ bin/run-both.sh | 2 ++ bin/run-openocd.sh | 2 +- bin/start-terminal0.sh | 2 ++ bin/start-terminal1.sh | 2 ++ bin/test-simulator.sh | 2 ++ bin/upload-to-bootloader.sh | 2 ++ bin/upload-to-rak4631.sh | 2 ++ bin/upload-usb1.sh | 2 ++ bin/view-map.sh | 2 ++ 35 files changed, 60 insertions(+), 12 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 1cf83c62f..dec3bd2f6 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/bin/dump-ram-users.sh b/bin/dump-ram-users.sh index f0438834e..3cc3ce5dc 100755 --- a/bin/dump-ram-users.sh +++ b/bin/dump-ram-users.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + arm-none-eabi-readelf -s -e .pio/build/nrf52dk/firmware.elf | head -80 nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200' diff --git a/bin/gen-images.sh b/bin/gen-images.sh index c4335718e..0c10fddb8 100755 --- a/bin/gen-images.sh +++ b/bin/gen-images.sh @@ -1,4 +1,4 @@ - +#!/usr/bin/env bash set -e diff --git a/bin/genpartitions.py b/bin/genpartitions.py index 0edca5574..2e1a9f1de 100755 --- a/bin/genpartitions.py +++ b/bin/genpartitions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # This is a layout for 4MB of flash # Name, Type, SubType, Offset, Size, Flags @@ -38,4 +38,4 @@ app0, app, ota_0, , 0x{app:x}, app1, app, ota_1, , 0x{app:x}, spiffs, data, spiffs, , 0x{spi:x} """.format(**locals()) -print(table) \ No newline at end of file +print(table) diff --git a/bin/install-bootloader.sh b/bin/install-bootloader.sh index eeb2071b9..4d2568f28 100755 --- a/bin/install-bootloader.sh +++ b/bin/install-bootloader.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board set -e diff --git a/bin/install-eink.sh b/bin/install-eink.sh index b1c3d87cc..a0b5bab79 100755 --- a/bin/install-eink.sh +++ b/bin/install-eink.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board set -e diff --git a/bin/mqtt-listen.sh b/bin/mqtt-listen.sh index 73ccb50a3..29c4e3956 100755 --- a/bin/mqtt-listen.sh +++ b/bin/mqtt-listen.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash mosquitto_sub -h mqtt.meshtastic.org -v -t \$SYS/\# -t msh/+/stat/\# -t msh/+/json/\# # mosquitto_sub -h test.mosquitto.org -v -t mesh/\# -F "%j" diff --git a/bin/mqtt-send-status.sh b/bin/mqtt-send-status.sh index 4df8a895e..042819752 100755 --- a/bin/mqtt-send-status.sh +++ b/bin/mqtt-send-status.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + mosquitto_pub -h mqtt.meshtastic.org -u meshdev -P large4cats -t msh/1/stat/FakeNode -m online -d diff --git a/bin/native-gdbserver.sh b/bin/native-gdbserver.sh index cbcbae4f9..f779d6670 100755 --- a/bin/native-gdbserver.sh +++ b/bin/native-gdbserver.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e pio run --environment native gdbserver --once localhost:2345 .pio/build/native/program "$@" diff --git a/bin/native-run.sh b/bin/native-run.sh index 64d44df52..6566fc591 100755 --- a/bin/native-run.sh +++ b/bin/native-run.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e pio run --environment native .pio/build/native/program "$@" diff --git a/bin/nrf52-console.sh b/bin/nrf52-console.sh index 55c586b8c..a25666e40 100755 --- a/bin/nrf52-console.sh +++ b/bin/nrf52-console.sh @@ -1,4 +1,4 @@ - +#!/usr/bin/env bash # JLinkRTTViewer -JLinkRTTClient \ No newline at end of file +JLinkRTTClient diff --git a/bin/nrf52832-gdbserver.sh b/bin/nrf52832-gdbserver.sh index 122a43301..7ee12d8f5 100755 --- a/bin/nrf52832-gdbserver.sh +++ b/bin/nrf52832-gdbserver.sh @@ -1,3 +1,3 @@ - +#!/usr/bin/env bash JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52832_XXAA diff --git a/bin/nrf52833-gdbserver.sh b/bin/nrf52833-gdbserver.sh index 03636e755..117b7d85e 100755 --- a/bin/nrf52833-gdbserver.sh +++ b/bin/nrf52833-gdbserver.sh @@ -1,3 +1,3 @@ - +#!/usr/bin/env bash JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52833_XXAA diff --git a/bin/nrf52840-gdbserver.sh b/bin/nrf52840-gdbserver.sh index 010c1003f..7aaea2dfa 100755 --- a/bin/nrf52840-gdbserver.sh +++ b/bin/nrf52840-gdbserver.sh @@ -1,3 +1,3 @@ - +#!/usr/bin/env bash JLinkGDBServerCLExe -if SWD -select USB -port 2331 -device NRF52840_XXAA -SuppressInfoUpdateFW -DisableAutoUpdateFW -rtos GDBServer/RTOSPlugin_FreeRTOS diff --git a/bin/program-1.0-tbeam.sh b/bin/program-1.0-tbeam.sh index b2b37756b..a5e257970 100755 --- a/bin/program-1.0-tbeam.sh +++ b/bin/program-1.0-tbeam.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-EU865-1.0.0.bin echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used" esptool.py --baud 921600 erase_region 0xe000 0x2000 diff --git a/bin/program-1.1-tbeam.sh b/bin/program-1.1-tbeam.sh index 98ba5c682..31d7ce2e8 100755 --- a/bin/program-1.1-tbeam.sh +++ b/bin/program-1.1-tbeam.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + esptool.py --baud 921600 write_flash 0x10000 release/archive/old/firmware-tbeam-1.1.50.bin diff --git a/bin/program-release-heltec.sh b/bin/program-release-heltec.sh index 90506473b..f88446b0d 100755 --- a/bin/program-release-heltec.sh +++ b/bin/program-release-heltec.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash set -e diff --git a/bin/program-release-tbeam.sh b/bin/program-release-tbeam.sh index 615ec66dc..08e0a4e8d 100755 --- a/bin/program-release-tbeam.sh +++ b/bin/program-release-tbeam.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash set -e diff --git a/bin/program-release-universal.sh b/bin/program-release-universal.sh index 554f55256..b2f3ae2ca 100755 --- a/bin/program-release-universal.sh +++ b/bin/program-release-universal.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash set -e diff --git a/bin/promote-release.sh b/bin/promote-release.sh index e79a06aaf..b9380b02b 100755 --- a/bin/promote-release.sh +++ b/bin/promote-release.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e echo "This script is only for developers who are publishing new builds on github. Most users don't need it" diff --git a/bin/qspi-flash-test.sh b/bin/qspi-flash-test.sh index 6c03635dd..542b96a78 100755 --- a/bin/qspi-flash-test.sh +++ b/bin/qspi-flash-test.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # You probably don't need this - it is a basic test of the serial flash on the TTGO eink board nrfjprog --qspiini nrf52/ttgo_eink_qpsi.ini --qspieraseall diff --git a/bin/read-system-info.sh b/bin/read-system-info.sh index d078d9ba4..f116087b2 100755 --- a/bin/read-system-info.sh +++ b/bin/read-system-info.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + esptool.py --baud 921600 read_flash 0x1000 0xf000 system-info.img diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 2d96f2b7b..6cb6c2aaa 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e @@ -12,4 +12,4 @@ cd proto #echo "Regenerating protobuf documentation - if you see an error message" #echo "you can ignore it unless doing a new protobuf release to github." -#bin/regen-docs.sh \ No newline at end of file +#bin/regen-docs.sh diff --git a/bin/run-0-monitor.sh b/bin/run-0-monitor.sh index 712a61981..1ad231667 100755 --- a/bin/run-0-monitor.sh +++ b/bin/run-0-monitor.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + pio run --upload-port /dev/ttyUSB0 -t upload -t monitor diff --git a/bin/run-1-monitor.sh b/bin/run-1-monitor.sh index a25d99489..38d43c58b 100755 --- a/bin/run-1-monitor.sh +++ b/bin/run-1-monitor.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + pio run --upload-port /dev/ttyUSB1 -t upload -t monitor diff --git a/bin/run-both-monitor.sh b/bin/run-both-monitor.sh index ae1b36fd9..6703ce982 100755 --- a/bin/run-both-monitor.sh +++ b/bin/run-both-monitor.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e echo uploading to usb1 diff --git a/bin/run-both.sh b/bin/run-both.sh index 1d8c8fdb2..2cb2e0bb0 100755 --- a/bin/run-both.sh +++ b/bin/run-both.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e TARG=tbeam diff --git a/bin/run-openocd.sh b/bin/run-openocd.sh index f7ec6e1fb..3afed0793 100755 --- a/bin/run-openocd.sh +++ b/bin/run-openocd.sh @@ -1,4 +1,4 @@ - +#!/usr/bin/env bash # /home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -c gdb_port pipe; tcl_port disabled; telnet_port disabled -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f board/esp-wroom-32.cfg /home/kevinh/.platformio/packages/tool-openocd-esp32/bin/openocd -s /home/kevinh/.platformio/packages/tool-openocd-esp32 -s /home/kevinh/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/jlink.cfg -f ./lora32-openocd.cfg diff --git a/bin/start-terminal0.sh b/bin/start-terminal0.sh index 3ad4e7822..3cb406928 100755 --- a/bin/start-terminal0.sh +++ b/bin/start-terminal0.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + pio device monitor -b 921600 diff --git a/bin/start-terminal1.sh b/bin/start-terminal1.sh index 3433501ea..ca59c8096 100755 --- a/bin/start-terminal1.sh +++ b/bin/start-terminal1.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + pio device monitor -p /dev/ttyUSB1 -b 921600 diff --git a/bin/test-simulator.sh b/bin/test-simulator.sh index 46158dc56..3c5f8f811 100755 --- a/bin/test-simulator.sh +++ b/bin/test-simulator.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e echo "Starting simulator" diff --git a/bin/upload-to-bootloader.sh b/bin/upload-to-bootloader.sh index 5ee008057..f48cc38bf 100755 --- a/bin/upload-to-bootloader.sh +++ b/bin/upload-to-bootloader.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e echo "building for t-echo" diff --git a/bin/upload-to-rak4631.sh b/bin/upload-to-rak4631.sh index 95ade3e37..185fa5597 100755 --- a/bin/upload-to-rak4631.sh +++ b/bin/upload-to-rak4631.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + set -e echo "Converting to uf2 for NRF52 Adafruit bootloader" diff --git a/bin/upload-usb1.sh b/bin/upload-usb1.sh index b44b95c22..92cc051c8 100755 --- a/bin/upload-usb1.sh +++ b/bin/upload-usb1.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + pio run --upload-port /dev/ttyUSB1 -t upload diff --git a/bin/view-map.sh b/bin/view-map.sh index badeb0843..735dd7cd6 100755 --- a/bin/view-map.sh +++ b/bin/view-map.sh @@ -1,2 +1,4 @@ +#!/usr/bin/env bash + echo using amap tool to display memory map amap .pio/build/output.map