pax.express migration 2 (work in progress)

This commit is contained in:
cyberman54 2021-03-22 23:10:07 +01:00
parent 6a3fcd9191
commit 8c9325320a
4 changed files with 28 additions and 28 deletions

View File

@ -86,35 +86,35 @@ with open(otakeyfile) as myfile:
key, value = line.partition("=")[::2] key, value = line.partition("=")[::2]
mykeys[key.strip()] = str(value).strip() 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 # get paxexpress credentials from ota key file
user = mykeys["BINTRAY_USER"] user = mykeys["PAXEXPRESS_USER"]
repository = mykeys["BINTRAY_REPO"] repository = mykeys["PAXEXPRESS_REPO"]
apitoken = mykeys["BINTRAY_API_TOKEN"] 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") version = config.get("common", "release_version")
package, dummy = halconfig.partition(".")[::2] package, dummy = halconfig.partition(".")[::2]
# put bintray user credentials to platformio environment # put paxexpress user credentials to platformio environment
env.Replace(BINTRAY_USER=user) env.Replace(PAXEXPRESS_USER=user)
env.Replace(BINTRAY_REPO=repository) env.Replace(PAXEXPRESS_REPO=repository)
env.Replace(BINTRAY_API_TOKEN=apitoken) env.Replace(PAXEXPRESS_API_TOKEN=apitoken)
# get runtime credentials and put them to compiler directive # get runtime credentials and put them to compiler directive
env.Append(BUILD_FLAGS=[ env.Append(BUILD_FLAGS=[
u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"', u'-DWIFI_SSID=\\"' + mykeys["OTA_WIFI_SSID"] + '\\"',
u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"', u'-DWIFI_PASS=\\"' + mykeys["OTA_WIFI_PASS"] + '\\"',
u'-DBINTRAY_USER=\\"' + mykeys["BINTRAY_USER"] + '\\"', u'-DPAXEXPRESS_USER=\\"' + mykeys["PAXEXPRESS_USER"] + '\\"',
u'-DBINTRAY_REPO=\\"' + mykeys["BINTRAY_REPO"] + '\\"', u'-DPAXEXPRESS_REPO=\\"' + mykeys["PAXEXPRESS_REPO"] + '\\"',
u'-DBINTRAY_PACKAGE=\\"' + package + '\\"', u'-DPAXEXPRESS_PACKAGE=\\"' + package + '\\"',
u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig, u'-DARDUINO_LMIC_PROJECT_CONFIG_H=' + lmicconfig,
u'-I \"' + srcdir + '\"' u'-I \"' + srcdir + '\"'
]) ])
# function for pushing new firmware to bintray storage using API # function for pushing new firmware to paxexpress storage using API
def publish_bintray(source, target, env): def publish_paxexpress(source, target, env):
firmware_path = str(source[0]) firmware_path = str(source[0])
firmware_name = basename(firmware_path) firmware_name = basename(firmware_path)
url = "/".join([ url = "/".join([
@ -122,7 +122,7 @@ def publish_bintray(source, target, env):
user, repository, package, version, firmware_name 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)) firmware_name, version))
print(url) 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))) ("%s\n%s" % (r.status_code, r.text) if r else str(e)))
env.Exit(1) 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 # put build file name and upload command to platformio environment
env.Replace( env.Replace(
PROGNAME="firmware_" + package + "_v%s" % version, PROGNAME="firmware_" + package + "_v%s" % version,
UPLOADCMD=publish_bintray) UPLOADCMD=publish_paxexpress)

View File

@ -16,7 +16,7 @@
"include": "bintray-secure-ota/lib/BintrayClient" "include": "bintray-secure-ota/lib/BintrayClient"
}, },
"dependencies": { "dependencies": {
"ArduinoJson": "^5.13.1" "ArduinoJson": "^6"
}, },
"version": "1.0.0", "version": "1.0.0",
"frameworks": "arduino", "frameworks": "arduino",

View File

@ -21,8 +21,8 @@
using namespace std; using namespace std;
const BintrayClient bintray(BINTRAY_USER, BINTRAY_REPO, BINTRAY_PACKAGE); const BintrayClient paxexpress(PAXEXPRESS_USER, PAXEXPRESS_REPO, PAXEXPRESS_PACKAGE);
// usage of bintray: see https://github.com/r0oland/bintray-secure-ota // usage of paxexpress: see https://github.com/paxexpress/docs
// Connection port (HTTPS) // Connection port (HTTPS)
const int port = 443; const int port = 443;
@ -121,7 +121,7 @@ int do_ota_update() {
if (WiFi.status() != WL_CONNECTED) if (WiFi.status() != WL_CONNECTED)
return 1; return 1;
const String latest = bintray.getLatestVersion(); const String latest = paxexpress.getLatestVersion();
if (latest.length() == 0) { if (latest.length() == 0) {
ESP_LOGI(TAG, "Could not fetch info on latest firmware"); ESP_LOGI(TAG, "Could not fetch info on latest firmware");
@ -138,14 +138,14 @@ int do_ota_update() {
ota_display(3, "**", ""); ota_display(3, "**", "");
if (WiFi.status() != WL_CONNECTED) if (WiFi.status() != WL_CONNECTED)
return 1; return 1;
String firmwarePath = bintray.getBinaryPath(latest); String firmwarePath = paxexpress.getBinaryPath(latest);
if (!firmwarePath.endsWith(".bin")) { if (!firmwarePath.endsWith(".bin")) {
ESP_LOGI(TAG, "Unsupported binary format"); ESP_LOGI(TAG, "Unsupported binary format");
ota_display(3, " E", "file type error"); ota_display(3, " E", "file type error");
return -1; return -1;
} }
String currentHost = bintray.getStorageHost(); String currentHost = paxexpress.getStorageHost();
String prevHost = currentHost; String prevHost = currentHost;
WiFiClientSecure client; WiFiClientSecure client;

View File

@ -2,7 +2,7 @@
OTA_WIFI_SSID = MyHomeWifi OTA_WIFI_SSID = MyHomeWifi
OTA_WIFI_PASS = FooBar42! OTA_WIFI_PASS = FooBar42!
[bintray] [paxexpress]
BINTRAY_USER = MyBintrayUser PAXEXPRESS_USER = MyPaxexpressUser
BINTRAY_REPO = MyBintrayRepo PAXEXPRESS_REPO = MyPaxexpressRepo
BINTRAY_API_TOKEN = 3894a7a51d70c6523c1b7479261c34845ebf7878 PAXEXPRESS_API_TOKEN = 3894a7a51d70c6523c1b7479261c34845ebf7878