Last active
December 6, 2024 12:26
-
-
Save Staars/0547d8a0a1b57db6d62c073368537e03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# run in lib/libesp32_div/esp-nimble-cpp/src/ | |
import os | |
excludes = ["mega_header.h","NimBLEBeacon.h","NimBLEBeacon.cpp","HIDKeyboardTypes.h","HIDTypes.h","NimBLEHIDDevice.h","NimBLEHIDDevice.cpp","NimBLEEddystoneURL.h","NimBLEEddystoneURL.cpp","NimBLEEddystoneTLM.h","NimBLEEddystoneTLM.cpp"] | |
src_dir = os.path.join("./") | |
src_files=os.listdir(src_dir) | |
headers = [f for f in src_files if (f.endswith(".h") and f not in excludes)] | |
cpp_files = [f for f in src_files if (f.endswith(".cpp") and f not in excludes)] | |
print(headers) | |
print(cpp_files) | |
#exit() | |
# sort by hand | |
headers = ['nimconfig.h', 'nimconfig_rename.h', 'NimBLELog.h', 'NimBLEUUID.h','NimBLEAddress.h', 'NimBLEAdvertisedDevice.h', 'NimBLEAdvertising.h', 'NimBLEAttValue.h', 'NimBLEConnInfo.h', 'NimBLEUtils.h','NimBLECharacteristic.h', 'NimBLEClient.h', 'NimBLEDescriptor.h', 'NimBLEServer.h', 'NimBLEDevice.h', 'NimBLEExtAdvertising.h', 'NimBLERemoteCharacteristic.h', 'NimBLERemoteDescriptor.h', 'NimBLERemoteService.h', 'NimBLEScan.h', 'NimBLEService.h', 'NimBLE2904.h'] | |
new_header = open("mega_header.h", "w") | |
for header in headers: | |
with open(header,"r") as file: | |
while line := file.readline(): | |
if line.startswith('#include "NimBLE'): | |
continue | |
if line.startswith('#include "nimconfig.h'): | |
continue | |
new_header.write(line) | |
wait_for_first_LOG = True | |
for cpp_file in cpp_files: | |
suffix = cpp_file[6:10] | |
with open(cpp_file,"r") as file: | |
while line := file.readline(): | |
if line.startswith('#include "NimBLE'): | |
continue | |
elif line.startswith('#include "nimconfig.h'): | |
continue | |
if line.startswith('static const char* LOG_TAG ='): | |
if wait_for_first_LOG == False: | |
continue | |
else: | |
line = 'static const char* LOG_TAG = "Tasmota Big Header";' | |
wait_for_first_LOG = False | |
if "defaultCallbacks" in line: | |
line = line.replace("defaultCallbacks", ("defaultCallbacks" + "_" + suffix)) | |
if line[-1] != "\n": | |
line += "\n" | |
new_header.write(line) | |
new_header.close() | |
# in tasmota/include/xsns_62_esp32_mi.h change | |
# //#include <NimBLEDevice.h> | |
# #include "../lib/libesp32_div/esp-nimble-cpp/src/mega_header.h" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment