Skip to content

Commit

Permalink
ESP32 update is working - with changes in update server.
Browse files Browse the repository at this point in the history
  • Loading branch information
netmaniac committed Jan 4, 2025
1 parent e85eeee commit 5a026b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
20 changes: 13 additions & 7 deletions platformio_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
except ImportError:
import ConfigParser as configparser

# print(env.Dump())
# print (projenv.Dump())

config = configparser.ConfigParser()
config.read("platformio.ini")

Expand All @@ -25,26 +28,29 @@ def after_build(source, target, env):
# f = open('version.txt', 'r')
# val = (f.read()).split(' ', 2)
# print(val)

firmware_path = str(target[0].path)
firmware_name = basename(firmware_path)

if not os.path.exists("./builds"):
os.mkdir("./builds")

os.makedirs("./builds/ESP32", exist_ok=True)
os.makedirs("./builds/ESP8266", exist_ok=True)
# dir = "ESP8266"
if env["PIOPLATFORM"] == "espressif8266" :
dir = "ESP8266"
else:
dir = "ESP32"
configName = env['PIOENV'] #something (SCons?) have changed in Platformio 6.1.16?
sectionName = 'env:' + configName
# breakpoint()
lang = config.get(sectionName, "lang").lower()
dest = 'builds/latest_{0}.bin'.format(lang)
dest = 'builds/{d}/latest_{l}.bin'.format(d=dir, l=lang)
print("Uploading {0} to {1}".format(firmware_name, dest))
shutil.copy(target[0].path, dest)

firmware_path = str(source[0].path)
firmware_name = basename(firmware_path)
dest = 'builds/latest_{0}.elf'.format(lang)
dest = 'builds/{d}/latest_{l}.elf'.format(d=dir, l=lang)
print("Uploading {0} to {1}".format(firmware_name, dest))
shutil.copy(source[0].path, dest)
# breakpoint()


env.AddPostAction("$BUILD_DIR/firmware.bin", after_build)
6 changes: 3 additions & 3 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ extern String tmpl(const String& patt, const String& value);
#define UPDATE_URL_ALFA F("/NAMF/index.php")
#define UPDATE_URL_BETA F("/NAMF/index.php")
#elif defined(ARDUINO_ARCH_ESP32)
#define UPDATE_URL F("/NAMF32/index.php")
#define UPDATE_URL_ALFA F("/NAMF32/index.php")
#define UPDATE_URL_BETA F("/NAMF32/index.php")
#define UPDATE_URL F("/NAMF/index.php")
#define UPDATE_URL_ALFA F("/NAMF/index.php")
#define UPDATE_URL_BETA F("/NAMF/index.php")
#endif
#define UPDATE_HOST_ALFA F("alfa.fw.nettigo.pl")
#define UPDATE_HOST_BETA F("beta.fw.nettigo.pl")
Expand Down
4 changes: 3 additions & 1 deletion src/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
WiFiClient client; /// FOR ESP32 HTTP FOTA UPDATE ///

t_httpUpdate_return tryUpdate(const String host, const String port, const String path, const String ver) {
t_httpUpdate_return ret = httpUpdate.update(client, UPDATE_HOST, UPDATE_PORT, UPDATE_URL, ver);
unsigned int pt = port.toInt();
t_httpUpdate_return ret = httpUpdate.update(client, host, pt, path, ver);
// t_httpUpdate_return ret = httpUpdate.update(client, "192.168.1.228", 9080, path, ver);
//no OTA for now
return ret;
}
Expand Down

0 comments on commit 5a026b4

Please sign in to comment.