35 lines
608 B
Markdown
35 lines
608 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 -- --broker 192.168.1.100 --port 1883
|
|
```
|
|
|
|
### Arguments
|
|
|
|
- `broker`: MQTT broker address (default: `localhost`)
|
|
- `port`: MQTT broker port (default: `1883`)
|
|
|
|
## 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?;
|
|
```
|