xref: /aosp_15_r20/external/curl/docs/internals/MQTT.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker<!--
2*6236dae4SAndroid Build Coastguard WorkerCopyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard Worker
4*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
5*6236dae4SAndroid Build Coastguard Worker-->
6*6236dae4SAndroid Build Coastguard Worker
7*6236dae4SAndroid Build Coastguard Worker# MQTT in curl
8*6236dae4SAndroid Build Coastguard Worker
9*6236dae4SAndroid Build Coastguard Worker## Usage
10*6236dae4SAndroid Build Coastguard Worker
11*6236dae4SAndroid Build Coastguard WorkerA plain "GET" subscribes to the topic and prints all published messages.
12*6236dae4SAndroid Build Coastguard Worker
13*6236dae4SAndroid Build Coastguard WorkerDoing a "POST" publishes the post data to the topic and exits.
14*6236dae4SAndroid Build Coastguard Worker
15*6236dae4SAndroid Build Coastguard Worker
16*6236dae4SAndroid Build Coastguard Worker### Subscribing
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard WorkerCommand usage:
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard Worker    curl mqtt://host/topic
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard WorkerExample subscribe:
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard Worker    curl mqtt://host.home/bedroom/temp
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard WorkerThis will send an MQTT SUBSCRIBE packet for the topic `bedroom/temp` and listen in for incoming PUBLISH packets.
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard Worker### Publishing
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard WorkerCommand usage:
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard Worker    curl -d payload mqtt://host/topic
33*6236dae4SAndroid Build Coastguard Worker
34*6236dae4SAndroid Build Coastguard WorkerExample publish:
35*6236dae4SAndroid Build Coastguard Worker
36*6236dae4SAndroid Build Coastguard Worker    curl -d 75 mqtt://host.home/bedroom/dimmer
37*6236dae4SAndroid Build Coastguard Worker
38*6236dae4SAndroid Build Coastguard WorkerThis will send an MQTT PUBLISH packet to the topic `bedroom/dimmer` with the payload `75`.
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard Worker## What does curl deliver as a response to a subscribe
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerWhenever a PUBLISH packet is received, curl outputs two bytes topic length (MSB | LSB), the topic followed by the
43*6236dae4SAndroid Build Coastguard Workerpayload.
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard Worker## Caveats
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard WorkerRemaining limitations:
48*6236dae4SAndroid Build Coastguard Worker - Only QoS level 0 is implemented for publish
49*6236dae4SAndroid Build Coastguard Worker - No way to set retain flag for publish
50*6236dae4SAndroid Build Coastguard Worker - No TLS (mqtts) support
51*6236dae4SAndroid Build Coastguard Worker - Naive EAGAIN handling does not handle split messages
52