# MQTT
## Features
- mqtt client init and start against a configurable broker URI
- publish, subscribe and unsubscribe helpers with QoS level support
- connection/publish/subscribe event logging
- optional c++ wrapper
## Menuconfig
```bash
idf.py menuconfig
```
### Path
Component config -> MQTT
### Default Configs
| MQTT | Type | Macro | Values |
| ---------- | ------ | ----------------------- | ---------------------------------- |
| Broker URI | string | CONFIG_MQTT_BROKER_URI | "mqtt://broker.mqttdashboard.com" |
## Installation
### IDF Component Registry
```bash
idf.py add-dependency thewesdev/mqtt
```
### Github
```bash
git clone https://github.com/thewesdev/mqtt
```
## Code Examples
### C
```c
#include "mqtt.h"
void app_main(void) {
mqtt_start();
mqtt_sub("test/topic", 0);
mqtt_pub("test/topic", "hello", 0);
}
```
### Cpp
```cpp
#include "mqtt.hpp"
extern "C" void app_main(void) {
mqtt::start();
mqtt::sub("test/topic", 0);
mqtt::pub("test/topic", "hello", 0);
}
```
idf.py add-dependency "thewesdev/mqtt^0.0.2"