How vulptex1234/esp32-networksys works
The project is a Python-based system meant to run on an ESP32 (as suggested by the README’s “Import this folder to your esp32” note) and appears to implement a clustering protocol where each node can be either a cluster head (CH) or a cluster member (CM). In addition, there’s a monitoring component (CM_monitor) and a set of functionalities for data collection and calculation (e.g., normalization and Euclidean distance computation) provided by calc.py. The structure is split across multiple folders (CH, CM, CM_monitor, and integrated) that mirror similar code but may be used for different node roles or integrated testing.
Main Components Identification
• Boot Module: Every folder has a boot.py which initializes the device. This module covers:
• Establishing a Wi-Fi connection (via connect_*_wifi() after performing a Wi-Fi scan).
• Deciding the node’s role by reading from flag.txt (the flag function chooses whether to launch ch_main.py or cm_main.py).
• Cluster Head Components (CH):
• The CH folder includes boot.py, calc.py (for data processing and sim_score calculation), and ch_main.py which likely manages operations when the node is a cluster head.
• Cluster Member Components (CM and CM_monitor):
• The CM folder contains boot.py and cm_main.py.
• The CM_monitor folder extends this by providing additional debugging, monitoring (get_current), and logging functionalities.
• Integrated Folder:
• Consolidates files from both CH and CM (including boot.py, calc.py, ch_main.py, cm_main.py, and several monitoring or data files). It acts as an all-in-one version for the ESP32 deployment, using files like ID.txt, cumulative_energy.txt, normalized_node_data.csv, and others to maintain node state and experiment data.
• Data Calculation Module (calc.py):
• normalize(): Reads battery and connectivity data from node_data.csv, normalizes these values, and writes to normalized_node_data.csv.
• extract_from_csv() and sim_score(): Processes normalized results to calculate a Euclidean distance which may contribute to role selection or performance evaluation.
Architectural Patterns & Design Principles
• Modularity: Each folder (CH, CM, CM_monitor, integrated) encapsulates a role with its specific set of functionalities.
• Data Flow: Emphasize the sequential data processing from reading raw sensor/node data to normalization and then to calculation of a similarity score.
Technologies and Frameworks
• Python is the primary language.
• The project runs on an ESP32 device (embedded target) – highlight the microcontroller environment.
• CSV files as primary data storage for node data and calculated results.
Final Advice
• Be very detailed—don’t hesitate to break down boot.py into its constituent responsibilities (network configuration, connection establishment, role decision).
• Dependency file interactions (like reading/writing CSVs, ID.txt, flag.txt) are shown so that it is clear how runtime configuration and state persist across sessions.
• Remember that the visual representation should map closely to the project’s physical file structure while clearly depicting the logical flow of control and data.