mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-08-01 11:45:11 +02:00
Update document
This commit is contained in:
39
README.md
39
README.md
@@ -33,15 +33,20 @@ make flash monitor
|
|||||||
### URI
|
### URI
|
||||||
|
|
||||||
- Curently support `mqtt`, `mqtts`, `ws`, `wss` schemes
|
- Curently support `mqtt`, `mqtts`, `ws`, `wss` schemes
|
||||||
- MQTT over HTTP, default port `1883`: `mqtt://iot.eclipse.org`
|
- MQTT over TCP samples:
|
||||||
- MQTT over HTTP, port `1884`: `mqtt://iot.eclipse.org:1884`
|
+ `mqtt://iot.eclipse.org`: MQTT over TCP, default port 1883:
|
||||||
- MQTT over HTTP, port `1884`, username and password: `mqtt://username:password@iot.eclipse.org:1884`
|
+ `mqtt://iot.eclipse.org:1884` MQTT over TCP, port 1884:
|
||||||
- MQTT over HTTPS, default port `8883`: `mqtts://iot.eclipse.org`
|
+ `mqtt://username:password@iot.eclipse.org:1884` MQTT over TCP, port 1884, with username and password
|
||||||
- MQTT over Websocket: `ws://iot.eclipse.org:80/ws`
|
- MQTT over SSL samples:
|
||||||
- MQTT over Websocket Secure: `wss://iot.eclipse.org:443/ws`
|
+ `mqtts://iot.eclipse.org`: MQTT over SSL, port 8883
|
||||||
|
+ `mqtts://iot.eclipse.org:8884`: MQTT over SSL, port 8884
|
||||||
|
- MQTT over Websocket samples:
|
||||||
|
+ `ws://iot.eclipse.org:80/ws`
|
||||||
|
- MQTT over Websocket Secure samples:
|
||||||
|
+ `wss://iot.eclipse.org:443/ws`
|
||||||
- Minimal configurations:
|
- Minimal configurations:
|
||||||
|
|
||||||
```cpp
|
```c
|
||||||
const esp_mqtt_client_config_t mqtt_cfg = {
|
const esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
.uri = "mqtt://iot.eclipse.org",
|
.uri = "mqtt://iot.eclipse.org",
|
||||||
.event_handle = mqtt_event_handler,
|
.event_handle = mqtt_event_handler,
|
||||||
@@ -49,6 +54,18 @@ const esp_mqtt_client_config_t mqtt_cfg = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- If there are any options related to the URI in `esp_mqtt_client_config_t`, the option defined by the URI will be overridden. Sample:
|
||||||
|
|
||||||
|
```c
|
||||||
|
const esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
|
.uri = "mqtt://iot.eclipse.org:1234",
|
||||||
|
.event_handle = mqtt_event_handler,
|
||||||
|
.port = 4567,
|
||||||
|
};
|
||||||
|
//MQTT client will connect to iot.eclipse.org using port 4567
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### SSL
|
### SSL
|
||||||
|
|
||||||
- Get Certification from server, example: `iot.eclipse.org` `openssl s_client -showcerts -connect iot.eclipse.org:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >iot_eclipse_org.pem`
|
- Get Certification from server, example: `iot.eclipse.org` `openssl s_client -showcerts -connect iot.eclipse.org:8883 </dev/null 2>/dev/null|openssl x509 -outform PEM >iot_eclipse_org.pem`
|
||||||
@@ -67,12 +84,12 @@ const esp_mqtt_client_config_t mqtt_cfg = {
|
|||||||
### More options for `esp_mqtt_client_config_t`
|
### More options for `esp_mqtt_client_config_t`
|
||||||
|
|
||||||
- `event_handle` for MQTT events
|
- `event_handle` for MQTT events
|
||||||
- `host`: replace `uri` host
|
- `host`: MQTT server domain (ipv4 as string)
|
||||||
- `port`: replace `uri` port
|
- `port`: MQTT server port
|
||||||
- `client_id`: replace default client id is `ESP32_%CHIPID%`
|
- `client_id`: default client id is `ESP32_%CHIPID%`
|
||||||
- `username`: MQTT username
|
- `username`: MQTT username
|
||||||
- `password`: MQTT password
|
- `password`: MQTT password
|
||||||
- `lwt_topic, lwt_msg, lwt_qos, lwt_retain`: are mqtt lwt options, default NULL
|
- `lwt_topic, lwt_msg, lwt_qos, lwt_retain, lwt_msg_len`: are mqtt lwt options, default NULL
|
||||||
- `disable_clean_session`: mqtt clean session, default clean_session is true
|
- `disable_clean_session`: mqtt clean session, default clean_session is true
|
||||||
- `keepalive`: (value in seconds) mqtt keepalive, default is 120 seconds
|
- `keepalive`: (value in seconds) mqtt keepalive, default is 120 seconds
|
||||||
- `disable_auto_reconnect`: this mqtt client will reconnect to server (when errors/disconnect). Set `disable_auto_reconnect=true` to disable
|
- `disable_auto_reconnect`: this mqtt client will reconnect to server (when errors/disconnect). Set `disable_auto_reconnect=true` to disable
|
||||||
|
Reference in New Issue
Block a user