mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-23 23:46:58 +01:00
[DEV] Add automatic BT lib replacement for BLE environments (#1860)
So that the replacement is done locally on the development environments but also with the CI
This commit is contained in:
28
scripts/replace_lib.py
Normal file
28
scripts/replace_lib.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user