42 lines
762 B
Markdown
42 lines
762 B
Markdown
# MQTT Publisher
|
|
|
|
A simple Rust application that publishes messages to an MQTT broker.
|
|
|
|
## Dependencies
|
|
|
|
- tokio (with full features)
|
|
- rumqttc
|
|
- serde
|
|
- serde_json
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
cargo run -- 192.168.1.100 1883
|
|
```
|
|
|
|
Or run the binary directly:
|
|
|
|
```bash
|
|
./target/debug/mqtt-publisher [broker] [port]
|
|
```
|
|
|
|
### Arguments
|
|
|
|
- `broker`: MQTT broker address (default: `localhost`)
|
|
- `port`: MQTT broker port (default: `1883`)
|
|
- `interval`: Interval in seconds between departure data fetches (default: `300`)
|
|
|
|
## Configuration
|
|
|
|
Edit `src/main.rs` to customize:
|
|
- Broker address (default: `localhost:1883`)
|
|
- MQTT topic (default: `test/topic`)
|
|
- Message payload
|
|
|
|
## Example
|
|
|
|
```rust
|
|
client.publish("your/topic", QoS::AtLeastOnce, false, b"Your message").await?;
|
|
```
|