Skip to content
Snippets Groups Projects
Commit 7bed7ff4 authored by Dmitry Frank's avatar Dmitry Frank Committed by Marko Mikulicic
Browse files

Docs are generated for Mongoose

Comments in headers are changed a bit: removed adoc-specific stuff,
markdown is used instead

PUBLISHED_FROM=9242cce85cc52a47a197d377e7e23804721a6bb5
parent d38b0dbf
No related branches found
No related tags found
No related merge requests found
Showing
with 338 additions and 0 deletions
---
title: "mbuf_resize()"
decl_name: "mbuf_resize"
symbol_kind: "func"
signature: |
void mbuf_resize(struct mbuf *, size_t new_size);
---
Resize an Mbuf.
If `new_size` is smaller than buffer's `len`, the
resize is not performed.
---
title: "mbuf_trim()"
decl_name: "mbuf_trim"
symbol_kind: "func"
signature: |
void mbuf_trim(struct mbuf *);
---
Shrink an Mbuf by resizing its `size` to `len`.
---
title: "struct mbuf"
decl_name: "struct mbuf"
symbol_kind: "struct"
signature: |
struct mbuf {
char *buf; /* Buffer pointer */
size_t len; /* Data length. Data is located between offset 0 and len. */
size_t size; /* Buffer size allocated by realloc(1). Must be >= len */
};
---
Memory buffer descriptor
---
title: "MQTT Broker"
symbol_kind: "intro"
decl_name: "mqtt-broker.h"
---
{
"items": [
{
"type": "markdown",
"name": "intro.md"
},
{
"type": "markdown",
"name": "mg_mqtt_broker_init.md"
},
{
"type": "markdown",
"name": "mg_mqtt_broker.md"
},
{
"type": "markdown",
"name": "mg_mqtt_next.md"
},
{
"type": "markdown",
"name": "struct_mg_mqtt_session.md"
},
{
"type": "markdown",
"name": "struct_mg_mqtt_broker.md"
}
]
}
---
title: "mg_mqtt_broker()"
decl_name: "mg_mqtt_broker"
symbol_kind: "func"
signature: |
void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data);
---
Process a MQTT broker message.
Listening connection expects a pointer to an initialized `mg_mqtt_broker`
structure in the `user_data` field.
Basic usage:
```c
mg_mqtt_broker_init(&brk, NULL);
if ((nc = mg_bind(&mgr, address, mg_mqtt_broker)) == NULL) {
// fail;
}
nc->user_data = &brk;
```
New incoming connections will receive a `mg_mqtt_session` structure
in the connection `user_data`. The original `user_data` will be stored
in the `user_data` field of the session structure. This allows the user
handler to store user data before `mg_mqtt_broker` creates the session.
Since only the MG_EV_ACCEPT message is processed by the listening socket,
for most events the `user_data` will thus point to a `mg_mqtt_session`.
---
title: "mg_mqtt_broker_init()"
decl_name: "mg_mqtt_broker_init"
symbol_kind: "func"
signature: |
void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data);
---
Initialize a MQTT broker.
---
title: "mg_mqtt_next()"
decl_name: "mg_mqtt_next"
symbol_kind: "func"
signature: |
struct mg_mqtt_session *mg_mqtt_next(struct mg_mqtt_broker *brk,
struct mg_mqtt_session *s);
---
Iterate over all mqtt sessions connections. Example:
```c
struct mg_mqtt_session *s;
for (s = mg_mqtt_next(brk, NULL); s != NULL; s = mg_mqtt_next(brk, s)) {
// Do something
}
```
---
title: "struct mg_mqtt_broker"
decl_name: "struct mg_mqtt_broker"
symbol_kind: "struct"
signature: |
struct mg_mqtt_broker {
struct mg_mqtt_session *sessions; /* Session list */
void *user_data; /* User data */
};
---
MQTT broker.
---
title: "struct mg_mqtt_session"
decl_name: "struct mg_mqtt_session"
symbol_kind: "struct"
signature: |
struct mg_mqtt_session {
struct mg_mqtt_broker *brk; /* Broker */
struct mg_mqtt_session *next, *prev; /* mg_mqtt_broker::sessions linkage */
struct mg_connection *nc; /* Connection with the client */
size_t num_subscriptions; /* Size of `subscriptions` array */
struct mg_mqtt_topic_expression *subscriptions;
void *user_data; /* User data */
};
---
MQTT session (Broker side).
---
title: "MQTT"
symbol_kind: "intro"
decl_name: "mqtt.h"
---
{
"items": [
{
"type": "markdown",
"name": "intro.md"
},
{
"type": "markdown",
"name": "mg_set_protocol_mqtt.md"
},
{
"type": "markdown",
"name": "mg_send_mqtt_handshake.md"
},
{
"type": "markdown",
"name": "mg_send_mqtt_handshake_opt.md"
},
{
"type": "markdown",
"name": "mg_mqtt_publish.md"
},
{
"type": "markdown",
"name": "mg_mqtt_subscribe.md"
},
{
"type": "markdown",
"name": "mg_mqtt_unsubscribe.md"
},
{
"type": "markdown",
"name": "mg_mqtt_disconnect.md"
},
{
"type": "markdown",
"name": "mg_mqtt_connack.md"
},
{
"type": "markdown",
"name": "mg_mqtt_puback.md"
},
{
"type": "markdown",
"name": "mg_mqtt_pubrec.md"
},
{
"type": "markdown",
"name": "mg_mqtt_pubrel.md"
},
{
"type": "markdown",
"name": "mg_mqtt_pubcomp.md"
},
{
"type": "markdown",
"name": "mg_mqtt_suback.md"
},
{
"type": "markdown",
"name": "mg_mqtt_unsuback.md"
},
{
"type": "markdown",
"name": "mg_mqtt_ping.md"
},
{
"type": "markdown",
"name": "mg_mqtt_pong.md"
},
{
"type": "markdown",
"name": "mg_mqtt_next_subscribe_topic.md"
},
{
"type": "markdown",
"name": "struct_mg_mqtt_topic_expression.md"
}
]
}
---
title: "mg_mqtt_connack()"
decl_name: "mg_mqtt_connack"
symbol_kind: "func"
signature: |
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
---
Send a CONNACK command with a given `return_code`.
---
title: "mg_mqtt_disconnect()"
decl_name: "mg_mqtt_disconnect"
symbol_kind: "func"
signature: |
void mg_mqtt_disconnect(struct mg_connection *nc);
---
Send a DISCONNECT command.
---
title: "mg_mqtt_next_subscribe_topic()"
decl_name: "mg_mqtt_next_subscribe_topic"
symbol_kind: "func"
signature: |
int mg_mqtt_next_subscribe_topic(struct mg_mqtt_message *msg,
struct mg_str *topic, uint8_t *qos, int pos);
---
Extract the next topic expression from a SUBSCRIBE command payload.
Topic expression name will point to a string in the payload buffer.
Return the pos of the next topic expression or -1 when the list
of topics is exhausted.
---
title: "mg_mqtt_ping()"
decl_name: "mg_mqtt_ping"
symbol_kind: "func"
signature: |
void mg_mqtt_ping(struct mg_connection *nc);
---
Send a PINGREQ command.
---
title: "mg_mqtt_pong()"
decl_name: "mg_mqtt_pong"
symbol_kind: "func"
signature: |
void mg_mqtt_pong(struct mg_connection *nc);
---
Send a PINGRESP command.
---
title: "mg_mqtt_puback()"
decl_name: "mg_mqtt_puback"
symbol_kind: "func"
signature: |
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBACK command with a given `message_id`.
---
title: "mg_mqtt_pubcomp()"
decl_name: "mg_mqtt_pubcomp"
symbol_kind: "func"
signature: |
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
---
Send a PUBCOMP command with a given `message_id`.
---
title: "mg_mqtt_publish()"
decl_name: "mg_mqtt_publish"
symbol_kind: "func"
signature: |
void mg_mqtt_publish(struct mg_connection *nc, const char *topic,
uint16_t message_id, int flags, const void *data,
size_t len);
---
Publish a message to a given topic.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment