emcute.h File Reference

emCute MQTT-SN interface definition More...

Detailed Description

emCute MQTT-SN interface definition

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file emcute.h.

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "net/sock/udp.h"
+ Include dependency graph for emcute.h:

Go to the source code of this file.

Data Structures

struct  emcute_topic_t
 MQTT-SN topic. More...
 
struct  emcute_sub
 Data-structure for keeping track of topics we register to. More...
 

Macros

#define EMCUTE_DEFAULT_PORT   (1883U)
 Default UDP port to listen on (also used as SRC port)
 
#define EMCUTE_BUFSIZE   (512U)
 Buffer size used for emCute's transmit and receive buffers. More...
 
#define EMCUTE_TOPIC_MAXLEN   (196U)
 Maximum topic length. More...
 
#define EMCUTE_KEEPALIVE   (360) /* -> 6 min*/
 Keep-alive interval [in s]. More...
 
#define EMCUTE_T_RETRY   (15U) /* -> 15 sec */
 Re-send interval [in seconds]. More...
 
#define EMCUTE_N_RETRY   (3U)
 Number of retries when sending packets. More...
 

Typedefs

typedef void(* emcute_cb_t) (const emcute_topic_t *topic, void *data, size_t len)
 Signature for callbacks fired when publish messages are received. More...
 
typedef struct emcute_sub emcute_sub_t
 Data-structure for keeping track of topics we register to.
 

Enumerations

enum  {
  EMCUTE_DUP = 0x80, EMCUTE_QOS_MASK = 0x60, EMCUTE_QOS_2 = 0x40, EMCUTE_QOS_1 = 0x20,
  EMCUTE_QOS_0 = 0x00, EMCUTE_RETAIN = 0x10, EMCUTE_WILL = 0x08, EMCUTE_CS = 0x04,
  EMCUTE_TIT_MASK = 0x03, EMCUTE_TIT_SHORT = 0x02, EMCUTE_TIT_PREDEF = 0x01, EMCUTE_TIT_NORMAL = 0x00
}
 MQTT-SN flags. More...
 
enum  {
  EMCUTE_OK = 0, EMCUTE_NOGW = -1, EMCUTE_REJECT = -2, EMCUTE_OVERFLOW = -3,
  EMCUTE_TIMEOUT = -4, EMCUTE_NOTSUP = -5
}
 Possible emCute return values. More...
 

Functions

int emcute_con (sock_udp_ep_t *remote, bool clean, const char *will_topic, const void *will_msg, size_t will_msg_len, unsigned flags)
 Connect to a given MQTT-SN gateway (CONNECT) More...
 
int emcute_discon (void)
 Disconnect from the gateway we are currently connected to. More...
 
int emcute_reg (emcute_topic_t *topic)
 Get a topic ID for the given topic name from the gateway. More...
 
int emcute_pub (emcute_topic_t *topic, const void *buf, size_t len, unsigned flags)
 Publish data on the given topic. More...
 
int emcute_sub (emcute_sub_t *sub, unsigned flags)
 Subscribe to the given topic. More...
 
int emcute_unsub (emcute_sub_t *sub)
 Unsubscripbe the given topic. More...
 
int emcute_willupd_topic (const char *topic, unsigned flags)
 Update the last will topic. More...
 
int emcute_willupd_msg (const void *data, size_t len)
 Update the last will message. More...
 
void emcute_run (uint16_t port, const char *id)
 Run emCute, will 'occupy' the calling thread. More...
 
const char * emcute_type_str (uint8_t type)
 Return the string representation of the given type value. More...