meshttpd is a simple REST API that enables interaction with a Meshtastic node via TCP. It provides endpoints to send messages, retrieve device and environment telemetry data, fetch cached messages, list seen nodes, and check connection status.
To configure the main Python file `meshttpd.py`, you need to specify the IP address or hostname of your Meshtastic device. Modify the `hostname` parameter in the `MeshAPI` class initialization according to your device's network configuration. If your network does not support local domain resolution, use the IP address of the device instead.
```python
# Change the IP address of the meshtastic device here.
mesh_api = MeshAPI(hostname='meshtastic.local')
```
## Usage
Start the server by running `meshttpd.py`:
```bash
python meshttpd.py
```
This will start the server locally. To expose it to the internet, it's recommended to use a reverse proxy.
## Endpoints
-`/api/mesh/send_message`: POST endpoint to send a message.
- Parameters:
-`message` (str): The message to be sent.
-`node_id` (optional, str): The ID of the node to which the message should be sent.
-`/api/mesh/get_device_telemetry`: GET endpoint to retrieve device telemetry data.
-`/api/mesh/get_environment_telemetry`: GET endpoint to retrieve environment telemetry data.
-`/api/mesh/get_last_messages`: GET endpoint to retrieve the last cached messages.