You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/mosquitto/examples/serverless_mqtt/README.md
+139-8Lines changed: 139 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,19 @@
3
3
MQTT served by (two) mosquitto's running on two ESP chips.
4
4
5
5
* Leverages MQTT connectivity between two private networks without cloud premisses.
6
-
* Creates two local MQTT servers (on ESP32x's) which are being synchronized over peer to peer connection (established via ICE protocol, by [libjuice](https://github.com/paullouisageneau/libjuice)).
6
+
* Creates two local MQTT servers (on ESP32x's) which are being synchronized over peer to peer connection (established via ICE/WebRTC protocol)
7
+
8
+
## Peer to peer connection
9
+
10
+
Could be established either by [libjuice](https://github.com/paullouisageneau/libjuice) or [esp-webRTC](https://github.com/espressif/esp-webrtc-solution). While `juice` is just a low level implementation of ICE-UDP, we need to provide some signalling and synchronization, the `WebRTC` is full-fledged solution to establish a peer connection using standardized signalling, security and transfer protocols.
11
+
7
12
8
13
## How it works
9
14
10
15
This example needs two ESP32 chipsets, that will create two separate Wi-Fi networks (IoT networks) used for IoT devices.
11
16
Each IoT network is served by an MQTT server (using mosquitto component).
12
17
This example will also synchronize these two MQTT brokers, as if there was only one IoT network with one broker.
13
-
This example creates a peer to peer connection between two chipsets to keep them synchronize. This connection utilizes libjuice (which implements a simplified ICE-UDP) to traverse NATs, which enabling direct connection between two private networks behind NATs.
18
+
This example creates a peer to peer connection between two chipsets to keep them synchronize. This connection utilizes libjuice (which implements a simplified ICE-UDP) or esp-webRTC (which implements WebRTC) to traverse NATs, which enabling direct connection between two private networks behind NATs.
14
19
15
20
* Diagram
16
21
@@ -19,12 +24,16 @@ This example creates a peer to peer connection between two chipsets to keep them
19
24
Here's a step-by-step procedure of establishing this remote connection:
20
25
1) Initialize and start Wi-Fi AP (for IoT networks) and Wi-Fi station (for internet connection)
21
26
2) Start mosquitto broker on IoT network
22
-
3) Start libjuice to gather connection candidates
23
-
4) Synchronize using a public MQTT broker and exchange ICE descriptors
24
-
5) Establish ICE UDP connection between the two ESP32 chipsets
27
+
3) Start peer to peer connection
28
+
- In case of `libjuice`
29
+
- gather connection candidates
30
+
- synchronize using a public MQTT broker and exchange ICE descriptors
31
+
- establish ICE UDP connection between the two ESP32 chipsets
32
+
- In case of `webRTC` simply start the connection.
25
33
6) Start forwarding mqtt messages
26
34
- Each remote datagram (received from ICE-UDP channel) is re-published to the local MQTT server
27
-
- Each local MQTT message (received from mosquitto on_message callback) is sent in ICE-UDP datagram
35
+
- Each local MQTT message (received from mosquitto on_message callback) is sent in a peer message
36
+
28
37
29
38
## How to use this example
30
39
@@ -33,7 +42,9 @@ You need two ESP32 devices that support Wi-Fi station and Wi-Fi software access
33
42
* Configure Wi-Fi credentials for both devices on both interfaces
34
43
* These devices would be deployed in distinct Wi-Fi environments, so the Wi-Fi station credentials would likely be different.
35
44
* They also create their own IoT network (on the soft-AP interface) Wi-Fi, so the AP credentials would likely be the same, suggesting the IoT networks will be keep synchronized (even though these are two distict Wi-Fi networks).
36
-
* Choose `CONFIG_EXAMPLE_SERVERLESS_ROLE_PEER1` for one device and `CONFIG_EXAMPLE_SERVERLESS_ROLE_PEER2` for another. It's not important which device is PEER1, since the code is symmetric, but these two devices need to have different role.
45
+
* Choose the peer library
46
+
* Only for `libjuice`:
47
+
- Choose `CONFIG_EXAMPLE_SERVERLESS_ROLE_PEER1` for one device and `CONFIG_EXAMPLE_SERVERLESS_ROLE_PEER2` for another. It's not important which device is PEER1, since the code is symmetric, but these two devices need to have different role.
37
48
* Optionally: You can use `idf.py``-D` and `-B` flag to keep separate build directories and sdkconfigs for these two roles
0 commit comments