Skip to content

Commit

Permalink
[DEV] Add automatic BT lib replacement for BLE environments (1technop…
Browse files Browse the repository at this point in the history
…hile#1860)

So that the replacement is done locally on the development environments but also with the CI
  • Loading branch information
1technophile authored Jan 9, 2024
1 parent 2c3d987 commit f1f27cc
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 30 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,6 @@ jobs:
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Trigger framework installation
run: platformio run -e esp32dev-all-test
- name: Replace libbtdm_app.a file
run: cp lib/esp32-bt-lib/esp32/libbtdm_app.a $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Verify file replacement
run: |
echo "Listing the file at the target location:"
ls -ltr $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/
echo "Checking file checksum:"
md5sum $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Run PlatformIO
run: platformio run -e ${{ matrix.environments }}
- name: Upload Assets
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/build_and_docs_to_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ jobs:
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Trigger framework installation
run: platformio run -e esp32dev-all-test
- name: Replace libbtdm_app.a file
run: cp lib/esp32-bt-lib/esp32/libbtdm_app.a $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Verify file replacement
run: |
echo "Listing the file at the target location:"
ls -ltr $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/
echo "Checking file checksum:"
md5sum $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Run PlatformIO
run: |
export PLATFORMIO_BUILD_FLAGS="'-DDEVELOPMENTOTA=true'"
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ jobs:
run: |
ESP32_VERSION=$(grep 'esp32_platform\s*=' platformio.ini | cut -d'@' -f2 | tr -d '[:space:]')
echo "ESP32_PLATFORM_VERSION=${ESP32_VERSION}" >> $GITHUB_ENV
- name: Trigger framework installation
run: platformio run -e esp32dev-all-test
- name: Replace libbtdm_app.a file
run: cp lib/esp32-bt-lib/esp32/libbtdm_app.a $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Verify file replacement
run: |
echo "Listing the file at the target location:"
ls -ltr $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/
echo "Checking file checksum:"
md5sum $HOME/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/libbtdm_app.a
- name: Run PlatformIO
run: platformio run
- name: Prepare Release Assets
Expand Down
26 changes: 26 additions & 0 deletions environments.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ custom_hardware = RFBridge v1
[env:theengs-bridge]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -89,6 +90,7 @@ custom_hardware = Theengs Bridge gateway ethernet
[env:esp32dev-all-test]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -279,6 +281,7 @@ custom_description = Infrared (Emitting and receiving) using IRremoteESP8266
[env:esp32dev-ble]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -295,6 +298,7 @@ custom_description = Regular BLE gateway with adaptive scanning activated, autom
[env:esp32dev-ble-mqtt-undecoded]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -312,6 +316,7 @@ custom_description = BLE gateway with the decoding offloaded to Theengs Gateway
[env:esp32dev-ble-aws]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -336,6 +341,7 @@ custom_description = BLE gateway with AWS integration capability
[env:esp32feather-ble]
platform = ${com.esp32_platform}
board = featheresp32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -353,6 +359,7 @@ custom_hardware = ESP32 Feather Adafruit
[env:esp32-lolin32lite-ble]
platform = ${com.esp32_platform}
board = lolin32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -382,6 +389,7 @@ custom_hardware = LOLIN 32 Lite
[env:esp32-olimex-gtw-ble-eth]
platform = ${com.esp32_platform}
board = esp32-gateway
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -401,6 +409,7 @@ custom_hardware = OLIMEX ESP32 Gateway
[env:esp32-olimex-gtw-ble-poe]
platform = ${com.esp32_platform}
board = esp32-poe
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -417,6 +426,7 @@ custom_hardware = OLIMEX ESP32 Gateway with POE
[env:esp32-olimex-gtw-ble-poe-iso]
platform = ${com.esp32_platform}
board = esp32-poe-iso
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -433,6 +443,7 @@ custom_hardware = OLIMEX ESP32 Gateway with POE and ISO
[env:esp32-wt32-eth01-ble-eth]
platform = ${com.esp32_platform}
board = esp32-gateway
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -452,6 +463,7 @@ custom_hardware = WT32
[env:esp32-olimex-gtw-ble-wifi]
platform = ${com.esp32_platform}
board = esp32-gateway
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -470,6 +482,7 @@ custom_hardware = OLIMEX ESP32 Gateway
[env:esp32-m5stick-ble]
platform = ${com.esp32_platform}
board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -493,6 +506,7 @@ custom_hardware = M5Stick Grey
[env:esp32-m5stack-ble]
platform = ${com.esp32_platform}
board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -517,6 +531,7 @@ custom_hardware = M5Stack Core
[env:esp32-m5tough-ble]
platform = ${com.esp32_platform}
board = m5stack-core-esp32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -535,6 +550,7 @@ custom_hardware = M5Tough rugged
[env:esp32-m5stick-c-ble]
platform = ${com.esp32_platform}
board = m5stick-c
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -565,6 +581,7 @@ custom_hardware = M5Stick C
[env:esp32-m5stick-cp-ble]
platform = ${com.esp32_platform}
board = pico32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -595,6 +612,7 @@ custom_hardware = M5Stick CP
[env:esp32-m5atom-matrix]
platform = ${com.esp32_platform}
board = pico32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand All @@ -620,6 +638,7 @@ custom_hardware = M5 ATOM Matrix
[env:esp32-m5atom-lite]
platform = ${com.esp32_platform}
board = pico32
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -826,6 +845,7 @@ custom_hardware = ESP32 HELTEC LORA32 V2
[env:heltec-ble]
platform = ${com.esp32_platform}
board = heltec_wifi_lora_32_V2
extra_scripts = ${com-esp32.extra_scripts}
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv
lib_deps =
Expand Down Expand Up @@ -912,6 +932,7 @@ custom_hardware = ESP32 LILYGO LoRa32 V2.1
[env:lilygo-ble]
platform = ${com.esp32_platform}
board = ttgo-lora32-v21
extra_scripts = ${com-esp32.extra_scripts}
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv
lib_deps =
Expand Down Expand Up @@ -988,6 +1009,7 @@ custom_description = Multi RF library with the possibility to switch between ESP
[env:tinypico-ble]
platform = ${com.esp32_platform}
board = tinypico
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -1051,6 +1073,7 @@ custom_hardware = ESP32 LILYGO LoRa32 V2.1
# https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436
platform = ${com.esp32_platform}
board = ttgo-t-beam
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -1108,6 +1131,7 @@ custom_hardware = ESP32 HELTEC LORA32
[env:shelly-plus1]
platform = ${com.esp32_solo_platform}
board = esp32-solo1
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -1563,6 +1587,7 @@ custom_description = FastLed control
[env:esp32dev-ble-datatest]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down Expand Up @@ -1756,6 +1781,7 @@ custom_hardware = M5Stamp C3
[env:thingpulse-espgateway]
platform = ${com.esp32_platform}
board = esp32dev
extra_scripts = ${com-esp32.extra_scripts}
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ build_flags =
;'-DCORE_DEBUG_LEVEL=4'

[com-esp32] ; Used by all ESP32 based builds
extra_scripts = pre:scripts/replace_lib.py
lib_deps =
${env.lib_deps}
${libraries.wifimanager32}
Expand Down
28 changes: 28 additions & 0 deletions scripts/replace_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import shutil
import os
import hashlib
Import("env")

def calculate_md5(filepath):
md5_hash = hashlib.md5()
with open(filepath, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
md5_hash.update(byte_block)
return md5_hash.hexdigest()

def main():
print(f"Pre build BLE library replacement script")
home_path = os.environ.get('HOME') or os.environ.get('USERPROFILE')
source_file = 'lib/esp32-bt-lib/esp32/libbtdm_app.a'
destination_file = os.path.join(home_path, '.platformio', 'packages', 'framework-arduinoespressif32', 'tools', 'sdk', 'esp32', 'ld', 'libbtdm_app.a')

try:
shutil.copyfile(source_file, destination_file)
md5_hash = calculate_md5(destination_file)
print(f"Successfully copied {source_file} to {destination_file}")
print(f"MD5: {md5_hash}")
except Exception as e:
print(f"Error occurred: {e}")

main()

0 comments on commit f1f27cc

Please sign in to comment.