forked from 1technophile/OpenMQTTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV] Add automatic BT lib replacement for BLE environments (1technop…
…hile#1860) So that the replacement is done locally on the development environments but also with the CI
- Loading branch information
1 parent
2c3d987
commit f1f27cc
Showing
6 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |