4.5 KiB
Development Guide
This guide provides instructions for setting up a development environment, running tests, and contributing to the Akita Meshtastic-Meshcore Bridge (AMMB) project.
Setting Up Development Environment
-
Clone the repository:
git clone [https://github.com/YOUR_USERNAME/akita-meshtastic-meshcore-bridge.git](https://github.com/YOUR_USERNAME/akita-meshtastic-meshcore-bridge.git) cd akita-meshtastic-meshcore-bridge -
Create and activate a Python virtual environment:
python -m venv venv # On Windows: .\venv\Scripts\activate # On Linux/macOS: source venv/bin/activateUsing a virtual environment isolates project dependencies.
-
Install runtime and development dependencies:
pip install -r requirements-dev.txtThis installs
meshtastic,pyserial,pypubsub,pytest,pytest-cov,flake8, andmypy.
Running Tests
The project uses pytest for automated testing.
-
Ensure your virtual environment is active.
-
Navigate to the project root directory.
-
Run pytest:
pytestThis will discover and run all tests located in the
tests/directory. -
Run tests with coverage report:
pytest --cov=ammb --cov-report term-missingThis runs the tests and generates a report showing which lines of the source code in the
ammb/directory were executed by the tests.
Code Style and Linting
We use flake8 for checking code style against PEP 8 guidelines and common errors.
- Ensure your virtual environment is active.
- Navigate to the project root directory.
- Run flake8:
This will report any style violations or potential errors. Aim for zero reported issues.
flake8 ammb/ tests/ run_bridge.py
Static Type Checking
We use mypy for static type checking to catch potential type-related errors before runtime.
- Ensure your virtual environment is active.
- Navigate to the project root directory.
- Run mypy:
This will analyze the type hints in the code and report any inconsistencies or errors. Aim for zero reported issues.
mypy ammb/ run_bridge.py
Contribution Guidelines
We welcome contributions! Please follow these steps:
- Fork the repository on GitHub.
- Clone your fork locally:
git clone https://github.com/YOUR_FORK_USERNAME/akita-meshtastic-meshcore-bridge.git - Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-nameorgit checkout -b fix/issue-description. - Set up your development environment as described above.
- Make your changes. Ensure you:
- Follow the existing code style.
- Add tests for new features or bug fixes.
- Update documentation (
README.md,docs/*.md) if necessary. - Ensure all tests pass (
pytest). - Ensure linters pass (
flake8 ammb/ tests/ run_bridge.py). - Ensure type checks pass (
mypy ammb/ run_bridge.py).
- Commit your changes with clear and descriptive commit messages.
- Push your branch to your fork:
git push origin feature/your-feature-name. - Open a Pull Request (PR) from your fork's branch to the
mainbranch of the original repository. - Clearly describe the changes made in the PR description and link to any relevant issues.
- Respond to feedback or requested changes during the code review process.
Adding New Meshcore Protocols
To support a different serial protocol for Meshcore:
- Create a new class in
ammb/protocol.pythat inherits fromMeshcoreProtocolHandler. - Implement the
encode(self, data: dict) -> bytes | Nonemethod to convert the bridge's standard message dictionary into bytes according to your protocol. - Implement the
decode(self, line: bytes) -> dict | Nonemethod to parse incoming bytes (likely read line-by-line or based on delimiters/length depending on the protocol) into a dictionary that includes at leastdestination_meshtastic_idandpayloadkeys for successful forwarding to Meshtastic. - Update the
get_protocol_handlerfactory function inammb/protocol.pyto recognize a new protocol name (e.g.,your_protocol_name) and return an instance of your new class. - Add the new protocol name as an option for the
MESHCORE_PROTOCOLsetting indocs/configuration.mdandexamples/config.ini.example. - Add tests for your new protocol handler in
tests/test_protocol.py.