sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
mqtt.h
Go to the documentation of this file.
1
5
6
/*
7
* Copyright (c) 2016 Erik Andersson
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without modification,
11
* are permitted provided that the following conditions are met:
12
*
13
* 1. Redistributions of source code must retain the above copyright notice,
14
* this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright notice,
16
* this list of conditions and the following disclaimer in the documentation
17
* and/or other materials provided with the distribution.
18
* 3. The name of the author may not be used to endorse or promote products
19
* derived from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30
* OF SUCH DAMAGE.
31
*
32
* This file is part of the lwIP TCP/IP stack.
33
*
34
* Author: Erik Andersson
35
*
36
*/
37
#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H
38
#define LWIP_HDR_APPS_MQTT_CLIENT_H
39
40
#include "
lwip/apps/mqtt_opts.h
"
41
#include "
lwip/err.h
"
42
#include "
lwip/ip_addr.h
"
43
#include "
lwip/prot/iana.h
"
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
48
49
typedef
struct
mqtt_client_s
mqtt_client_t;
50
51
#if LWIP_ALTCP && LWIP_ALTCP_TLS
52
struct
altcp_tls_config;
53
#endif
54
57
#define MQTT_PORT LWIP_IANA_PORT_MQTT
60
#define MQTT_TLS_PORT LWIP_IANA_PORT_SECURE_MQTT
61
62
/*---------------------------------------------------------------------------------------------- */
63
/* Connection with server */
64
68
struct
mqtt_connect_client_info_t
{
70
const
char
*
client_id
;
72
const
char
*
client_user
;
74
const
char
*
client_pass
;
76
u16_t
keep_alive
;
79
const
char
*
will_topic
;
81
const
char
*
will_msg
;
83
u8_t
will_msg_len
;
85
u8_t
will_qos
;
87
u8_t
will_retain
;
88
#if LWIP_ALTCP && LWIP_ALTCP_TLS
90
struct
altcp_tls_config *tls_config;
91
#endif
92
};
93
97
typedef
enum
98
{
100
MQTT_CONNECT_ACCEPTED
= 0,
102
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION
= 1,
104
MQTT_CONNECT_REFUSED_IDENTIFIER
= 2,
106
MQTT_CONNECT_REFUSED_SERVER
= 3,
108
MQTT_CONNECT_REFUSED_USERNAME_PASS
= 4,
110
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_
= 5,
112
MQTT_CONNECT_DISCONNECTED
= 256,
114
MQTT_CONNECT_TIMEOUT
= 257
115
}
mqtt_connection_status_t
;
116
128
typedef
void (*
mqtt_connection_cb_t
)(mqtt_client_t *client,
void
*arg,
mqtt_connection_status_t
status);
129
130
134
enum
{
136
MQTT_DATA_FLAG_LAST
= 1
137
};
138
151
typedef
void (*
mqtt_incoming_data_cb_t
)(
void
*arg,
const
u8_t *data, u16_t len, u8_t flags);
152
153
163
typedef
void (*
mqtt_incoming_publish_cb_t
)(
void
*arg,
const
char
*topic, u32_t tot_len);
164
165
175
typedef
void (*
mqtt_request_cb_t
)(
void
*arg, err_t err);
176
177
178
err_t mqtt_client_connect(mqtt_client_t *client,
const
ip_addr_t *ipaddr, u16_t port,
mqtt_connection_cb_t
cb,
void
*arg,
179
const
struct
mqtt_connect_client_info_t
*client_info);
180
181
void
mqtt_disconnect(mqtt_client_t *client);
182
183
mqtt_client_t *mqtt_client_new(
void
);
184
void
mqtt_client_free(mqtt_client_t* client);
185
186
u8_t mqtt_client_is_connected(mqtt_client_t *client);
187
188
void
mqtt_set_inpub_callback(mqtt_client_t *client,
mqtt_incoming_publish_cb_t
pub_cb,
189
mqtt_incoming_data_cb_t
data_cb,
void
*arg);
190
191
err_t mqtt_sub_unsub(mqtt_client_t *client,
const
char
*topic, u8_t qos,
mqtt_request_cb_t
cb,
void
*arg, u8_t sub);
192
195
#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1)
198
#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0)
199
200
err_t mqtt_publish(mqtt_client_t *client,
const
char
*topic,
const
void
*payload, u16_t payload_length, u8_t qos, u8_t retain,
201
mqtt_request_cb_t
cb,
void
*arg);
202
203
#ifdef __cplusplus
204
}
205
#endif
206
207
#endif
/* LWIP_HDR_APPS_MQTT_CLIENT_H */
err.h
mqtt_connection_cb_t
void(*) mqtt_connection_cb_t(mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
Definition
mqtt.h:128
mqtt_connection_status_t
mqtt_connection_status_t
Definition
mqtt.h:98
mqtt_incoming_publish_cb_t
void(*) mqtt_incoming_publish_cb_t(void *arg, const char *topic, u32_t tot_len)
Definition
mqtt.h:163
mqtt_incoming_data_cb_t
void(*) mqtt_incoming_data_cb_t(void *arg, const u8_t *data, u16_t len, u8_t flags)
Definition
mqtt.h:151
mqtt_request_cb_t
void(*) mqtt_request_cb_t(void *arg, err_t err)
Definition
mqtt.h:175
MQTT_CONNECT_ACCEPTED
@ MQTT_CONNECT_ACCEPTED
Definition
mqtt.h:100
MQTT_CONNECT_REFUSED_IDENTIFIER
@ MQTT_CONNECT_REFUSED_IDENTIFIER
Definition
mqtt.h:104
MQTT_CONNECT_REFUSED_USERNAME_PASS
@ MQTT_CONNECT_REFUSED_USERNAME_PASS
Definition
mqtt.h:108
MQTT_CONNECT_DISCONNECTED
@ MQTT_CONNECT_DISCONNECTED
Definition
mqtt.h:112
MQTT_CONNECT_REFUSED_PROTOCOL_VERSION
@ MQTT_CONNECT_REFUSED_PROTOCOL_VERSION
Definition
mqtt.h:102
MQTT_CONNECT_TIMEOUT
@ MQTT_CONNECT_TIMEOUT
Definition
mqtt.h:114
MQTT_CONNECT_REFUSED_SERVER
@ MQTT_CONNECT_REFUSED_SERVER
Definition
mqtt.h:106
MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_
@ MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_
Definition
mqtt.h:110
MQTT_DATA_FLAG_LAST
@ MQTT_DATA_FLAG_LAST
Definition
mqtt.h:136
iana.h
ip_addr.h
mqtt_opts.h
mqtt_client_s
Definition
mqtt_priv.h:72
mqtt_connect_client_info_t
Definition
mqtt.h:68
mqtt_connect_client_info_t::will_qos
u8_t will_qos
Definition
mqtt.h:85
mqtt_connect_client_info_t::will_topic
const char * will_topic
Definition
mqtt.h:79
mqtt_connect_client_info_t::will_retain
u8_t will_retain
Definition
mqtt.h:87
mqtt_connect_client_info_t::will_msg_len
u8_t will_msg_len
Definition
mqtt.h:83
mqtt_connect_client_info_t::client_pass
const char * client_pass
Definition
mqtt.h:74
mqtt_connect_client_info_t::will_msg
const char * will_msg
Definition
mqtt.h:81
mqtt_connect_client_info_t::keep_alive
u16_t keep_alive
Definition
mqtt.h:76
mqtt_connect_client_info_t::client_id
const char * client_id
Definition
mqtt.h:70
mqtt_connect_client_info_t::client_user
const char * client_user
Definition
mqtt.h:72
core
ps2ip
include
lwip_include
lwip
apps
mqtt.h
Generated by
1.18.0