Build script now sets paths to lmic config
This commit is contained in:
parent
3f3b26ab43
commit
5a3a5e2969
41
build.py
41
build.py
@ -13,33 +13,43 @@ Import("env")
|
|||||||
# get platformio environment variables
|
# get platformio environment variables
|
||||||
project_config = util.load_project_config()
|
project_config = util.load_project_config()
|
||||||
|
|
||||||
# check if file loraconf.h is present in source directory
|
# get platformio source path
|
||||||
keyfile = str(env.get("PROJECTSRC_DIR")) + "/loraconf.h"
|
srcdir = str(env.get("PROJECTSRC_DIR")).replace("\\", "/") + "/"
|
||||||
if os.path.isfile(keyfile) and os.access(keyfile, os.R_OK):
|
|
||||||
print "Parsing LORAWAN keys from " + keyfile
|
|
||||||
else:
|
|
||||||
sys.exit("Missing file loraconf.h, please create it using template loraconf.sample.h! Aborting.")
|
|
||||||
|
|
||||||
# check if file ota.conf is present in source directory
|
# check if lmic config file is present in source directory
|
||||||
keyfile = str(env.get("PROJECTSRC_DIR")) + "/" + project_config.get("common", "keyfile")
|
lmicconfigfile = srcdir.lower() + project_config.get("common", "lmicconfigfile")
|
||||||
if os.path.isfile(keyfile) and os.access(keyfile, os.R_OK):
|
if os.path.isfile(lmicconfigfile) and os.access(lmicconfigfile, os.R_OK):
|
||||||
print "Parsing OTA keys from " + keyfile
|
print "Parsing LMIC configuration from " + lmicconfigfile
|
||||||
else:
|
else:
|
||||||
sys.exit("Missing file ota.conf, please create it using template ota.sample.conf! Aborting.")
|
sys.exit("Missing file " + lmicconfigfile + ", please create it! Aborting.")
|
||||||
|
|
||||||
# parse file ota.conf
|
# check if lora key file is present in source directory
|
||||||
|
lorakeyfile = srcdir + project_config.get("common", "lorakeyfile")
|
||||||
|
if os.path.isfile(lorakeyfile) and os.access(lorakeyfile, os.R_OK):
|
||||||
|
print "Parsing LORAWAN keys from " + lorakeyfile
|
||||||
|
else:
|
||||||
|
sys.exit("Missing file " + lorakeyfile + ", please create it! Aborting.")
|
||||||
|
|
||||||
|
# check if ota key file is present in source directory
|
||||||
|
otakeyfile = srcdir + project_config.get("common", "otakeyfile")
|
||||||
|
if os.path.isfile(otakeyfile) and os.access(otakeyfile, os.R_OK):
|
||||||
|
print "Parsing OTA keys from " + otakeyfile
|
||||||
|
else:
|
||||||
|
sys.exit("Missing file " + otakeyfile + ", please create it! Aborting.")
|
||||||
|
|
||||||
|
# parse ota key file
|
||||||
mykeys = {}
|
mykeys = {}
|
||||||
with open(keyfile) as myfile:
|
with open(otakeyfile) as myfile:
|
||||||
for line in myfile:
|
for line in myfile:
|
||||||
key, value = line.partition("=")[::2]
|
key, value = line.partition("=")[::2]
|
||||||
mykeys[key.strip()] = str(value).strip()
|
mykeys[key.strip()] = str(value).strip()
|
||||||
|
|
||||||
# get bintray user credentials
|
# get bintray user credentials from ota key file
|
||||||
user = mykeys["BINTRAY_USER"]
|
user = mykeys["BINTRAY_USER"]
|
||||||
repository = mykeys["BINTRAY_REPO"]
|
repository = mykeys["BINTRAY_REPO"]
|
||||||
apitoken = mykeys["BINTRAY_API_TOKEN"]
|
apitoken = mykeys["BINTRAY_API_TOKEN"]
|
||||||
|
|
||||||
# get bintray upload parameters
|
# get bintray upload parameters from platformio environment
|
||||||
version = project_config.get("common", "release_version")
|
version = project_config.get("common", "release_version")
|
||||||
package = str(env.get("PIOENV"))
|
package = str(env.get("PIOENV"))
|
||||||
|
|
||||||
@ -54,6 +64,7 @@ env.Replace(CPPDEFINES=[
|
|||||||
('WIFI_PASS', '\\"' + mykeys["OTA_WIFI_PASS"] + '\\"'),
|
('WIFI_PASS', '\\"' + mykeys["OTA_WIFI_PASS"] + '\\"'),
|
||||||
('BINTRAY_USER', '\\"' + mykeys["BINTRAY_USER"] + '\\"'),
|
('BINTRAY_USER', '\\"' + mykeys["BINTRAY_USER"] + '\\"'),
|
||||||
('BINTRAY_REPO', '\\"' + mykeys["BINTRAY_REPO"] + '\\"'),
|
('BINTRAY_REPO', '\\"' + mykeys["BINTRAY_REPO"] + '\\"'),
|
||||||
|
('ARDUINO_LMIC_PROJECT_CONFIG_H', '\"' + lmicconfigfile + '\"')
|
||||||
])
|
])
|
||||||
|
|
||||||
# function for pushing new firmware to bintray storage using API
|
# function for pushing new firmware to bintray storage using API
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
; ---> SELECT TARGET PLATFORM HERE! <---
|
; ---> SELECT TARGET PLATFORM HERE! <---
|
||||||
[platformio]
|
[platformio]
|
||||||
env_default = generic
|
;env_default = generic
|
||||||
;env_default = ebox
|
;env_default = ebox
|
||||||
;env_default = eboxtube
|
;env_default = eboxtube
|
||||||
;env_default = ecopower
|
;env_default = ecopower
|
||||||
@ -16,7 +16,7 @@ env_default = generic
|
|||||||
;env_default = ttgov2
|
;env_default = ttgov2
|
||||||
;env_default = ttgov21old
|
;env_default = ttgov21old
|
||||||
;env_default = ttgov21new
|
;env_default = ttgov21new
|
||||||
;env_default = ttgobeam
|
env_default = ttgobeam
|
||||||
;env_default = ttgofox
|
;env_default = ttgofox
|
||||||
;env_default = lopy
|
;env_default = lopy
|
||||||
;env_default = lopy4
|
;env_default = lopy4
|
||||||
@ -40,7 +40,9 @@ debug_level = 3
|
|||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
;upload_protocol = custom
|
;upload_protocol = custom
|
||||||
extra_scripts = pre:build.py
|
extra_scripts = pre:build.py
|
||||||
keyfile = ota.conf
|
otakeyfile = ota.conf
|
||||||
|
lorakeyfile = loraconf.h
|
||||||
|
lmicconfigfile = lmic_config.h
|
||||||
platform_espressif32 = espressif32@1.8.0
|
platform_espressif32 = espressif32@1.8.0
|
||||||
;platform_espressif32 = https://github.com/platformio/platform-espressif32.git#develop
|
;platform_espressif32 = https://github.com/platformio/platform-espressif32.git#develop
|
||||||
board_build.partitions = min_spiffs.csv
|
board_build.partitions = min_spiffs.csv
|
||||||
@ -74,13 +76,9 @@ build_flags_basic =
|
|||||||
-include "src/hal/${PIOENV}.h"
|
-include "src/hal/${PIOENV}.h"
|
||||||
-include "src/paxcounter.conf"
|
-include "src/paxcounter.conf"
|
||||||
-w
|
-w
|
||||||
;use this is you have platformio version >= 4.0.0a15
|
|
||||||
'-DARDUINO_LMIC_PROJECT_CONFIG_H=../../../../../src/lmic_config.h'
|
|
||||||
;use this is you have platformio version < 4.0.0a15
|
|
||||||
;'-DARDUINO_LMIC_PROJECT_CONFIG_H=../../../src/lmic_config.h'
|
|
||||||
'-DCORE_DEBUG_LEVEL=${common.debug_level}'
|
'-DCORE_DEBUG_LEVEL=${common.debug_level}'
|
||||||
'-DLOG_LOCAL_LEVEL=${common.debug_level}'
|
'-DLOG_LOCAL_LEVEL=${common.debug_level}'
|
||||||
'-DBINTRAY_PACKAGE="${PIOENV}"'
|
'-DBINTRAY_PACKAGE="$PIOENV"'
|
||||||
'-DPROGVERSION="${common.release_version}"'
|
'-DPROGVERSION="${common.release_version}"'
|
||||||
build_flags_sensors =
|
build_flags_sensors =
|
||||||
-Llib/Bosch-BSEC/src/esp32/
|
-Llib/Bosch-BSEC/src/esp32/
|
||||||
|
Loading…
Reference in New Issue
Block a user