From 8c9325320a5fc9e89f560aa425ff08f1321ee016 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Mon, 22 Mar 2021 23:10:07 +0100 Subject: [PATCH] pax.express migration 2 (work in progress) --- build.py | 36 +++++++++++++++++----------------- lib/BintrayClient/library.json | 2 +- src/ota.cpp | 10 +++++----- src/ota_sample.conf | 8 ++++---- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/build.py b/build.py index ff7bd161..ced50f0a 100644 --- a/build.py +++ b/build.py @@ -86,35 +86,35 @@ with open(otakeyfile) as myfile: key, value = line.partition("=")[::2] mykeys[key.strip()] = str(value).strip() -# usage of bintray: see https://github.com/r0oland/bintray-secure-ota +# usage of paxexpress: see https://github.com/paxexpress/docs -# get bintray user credentials from ota key file -user = mykeys["BINTRAY_USER"] -repository = mykeys["BINTRAY_REPO"] -apitoken = mykeys["BINTRAY_API_TOKEN"] +# get paxexpress credentials from ota key file +user = mykeys["PAXEXPRESS_USER"] +repository = mykeys["PAXEXPRESS_REPO"] +apitoken = mykeys["PAXEXPRESS_API_TOKEN"] -# get bintray upload parameters from platformio environment +# get paxexpress upload parameters from platformio environment version = config.get("common", "release_version") package, dummy = halconfig.partition(".")[::2] -# put bintray user credentials to platformio environment -env.Replace(BINTRAY_USER=user) -env.Replace(BINTRAY_REPO=repository) -env.Replace(BINTRAY_API_TOKEN=apitoken) +# put paxexpress user credentials to platformio environment +env.Replace(PAXEXPRESS_USER=user) +env.Replace(PAXEXPRESS_REPO=repository) +env.Replace(PAXEXPRESS_API_TOKEN=apitoken) # get runtime credentials and put them to compiler directive env.Append(BUILD_FLAGS=[ u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"', u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"', - u'-DBINTRAY_USER=\\"' + mykeys["BINTRAY_USER"] + '\\"', - u'-DBINTRAY_REPO=\\"' + mykeys["BINTRAY_REPO"] + '\\"', - u'-DBINTRAY_PACKAGE=\\"' + package + '\\"', + u'-DPAXEXPRESS_USER=\\"' + mykeys["PAXEXPRESS_USER"] + '\\"', + u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"', + u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"', u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig, u'-I \"' + srcdir + '\"' ]) -# function for pushing new firmware to bintray storage using API -def publish_bintray(source, target, env): +# function for pushing new firmware to paxexpress storage using API +def publish_paxexpress(source, target, env): firmware_path = str(source[0]) firmware_name = basename(firmware_path) url = "/".join([ @@ -122,7 +122,7 @@ def publish_bintray(source, target, env): user, repository, package, version, firmware_name ]) - print("Uploading {0} to Bintray. Version: {1}".format( + print("Uploading {0} to PAX.express. Version: {1}".format( firmware_name, version)) print(url) @@ -145,9 +145,9 @@ def publish_bintray(source, target, env): ("%s\n%s" % (r.status_code, r.text) if r else str(e))) env.Exit(1) - print("The firmware has been successfuly published at Bintray.com!") + print("Firmware has been successfully published at PAX.express!") # put build file name and upload command to platformio environment env.Replace( PROGNAME="firmware_" + package + "_v%s" % version, - UPLOADCMD=publish_bintray) + UPLOADCMD=publish_paxexpress) diff --git a/lib/BintrayClient/library.json b/lib/BintrayClient/library.json index 677cec5c..1f36ebac 100644 --- a/lib/BintrayClient/library.json +++ b/lib/BintrayClient/library.json @@ -16,7 +16,7 @@ "include": "bintray-secure-ota/lib/BintrayClient" }, "dependencies": { - "ArduinoJson": "^5.13.1" + "ArduinoJson": "^6" }, "version": "1.0.0", "frameworks": "arduino", diff --git a/src/ota.cpp b/src/ota.cpp index ad11822c..db02d04f 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -21,8 +21,8 @@ using namespace std; -const BintrayClient bintray(BINTRAY_USER, BINTRAY_REPO, BINTRAY_PACKAGE); -// usage of bintray: see https://github.com/r0oland/bintray-secure-ota +const BintrayClient paxexpress(PAXEXPRESS_USER, PAXEXPRESS_REPO, PAXEXPRESS_PACKAGE); +// usage of paxexpress: see https://github.com/paxexpress/docs // Connection port (HTTPS) const int port = 443; @@ -121,7 +121,7 @@ int do_ota_update() { if (WiFi.status() != WL_CONNECTED) return 1; - const String latest = bintray.getLatestVersion(); + const String latest = paxexpress.getLatestVersion(); if (latest.length() == 0) { ESP_LOGI(TAG, "Could not fetch info on latest firmware"); @@ -138,14 +138,14 @@ int do_ota_update() { ota_display(3, "**", ""); if (WiFi.status() != WL_CONNECTED) return 1; - String firmwarePath = bintray.getBinaryPath(latest); + String firmwarePath = paxexpress.getBinaryPath(latest); if (!firmwarePath.endsWith(".bin")) { ESP_LOGI(TAG, "Unsupported binary format"); ota_display(3, " E", "file type error"); return -1; } - String currentHost = bintray.getStorageHost(); + String currentHost = paxexpress.getStorageHost(); String prevHost = currentHost; WiFiClientSecure client; diff --git a/src/ota_sample.conf b/src/ota_sample.conf index a10d79dc..7a6425dc 100644 --- a/src/ota_sample.conf +++ b/src/ota_sample.conf @@ -2,7 +2,7 @@ OTA_WIFI_SSID = MyHomeWifi OTA_WIFI_PASS = FooBar42! -[bintray] -BINTRAY_USER = MyBintrayUser -BINTRAY_REPO = MyBintrayRepo -BINTRAY_API_TOKEN = 3894a7a51d70c6523c1b7479261c34845ebf7878 \ No newline at end of file +[paxexpress] +PAXEXPRESS_USER = MyPaxexpressUser +PAXEXPRESS_REPO = MyPaxexpressRepo +PAXEXPRESS_API_TOKEN = 3894a7a51d70c6523c1b7479261c34845ebf7878 \ No newline at end of file