asymcute.h File Reference

Asymcute MQTT-SN interface definition. More...

Detailed Description

Asymcute 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 asymcute.h.

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "assert.h"
#include "event/timeout.h"
#include "event/callback.h"
#include "net/mqttsn.h"
#include "net/sock/udp.h"
#include "net/sock/util.h"
+ Include dependency graph for asymcute.h:

Go to the source code of this file.

Data Structures

struct  asymcute_req
 Asymcute request context. More...
 
struct  asymcute_con
 Asymcute connection context. More...
 
struct  asymcute_topic
 Data-structure for holding topics and their registration status. More...
 
struct  asymcute_sub
 Data-structure holding the state of subscriptions. More...
 
struct  asymcute_will
 Data structure for defining a last will. More...
 

Macros

#define CONFIG_ASYMCUTE_BUFSIZE_EXP   (7U)
 Default buffer size for Asymcute client (as exponent of 2^n) More...
 
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN   (32U)
 Maximum topic length. More...
 
#define CONFIG_ASYMCUTE_KEEPALIVE   (360)
 Keep alive interval [in s] communicated to the gateway. More...
 
#define CONFIG_ASYMCUTE_KEEPALIVE_PING   ((CONFIG_ASYMCUTE_KEEPALIVE / 4) * 3)
 Interval to use for sending periodic ping messages. More...
 
#define CONFIG_ASYMCUTE_T_RETRY   (10U)
 Resend interval [in seconds]. More...
 
#define CONFIG_ASYMCUTE_N_RETRY   (3U)
 Number of retransmissions until requests time out. More...
 
#define ASYMCUTE_BUFSIZE   (1 << CONFIG_ASYMCUTE_BUFSIZE_EXP)
 Default buffer size used for receive and request buffers.
 
#define ASYMCUTE_HANDLER_PRIO   (THREAD_PRIORITY_MAIN - 2)
 Default priority for Asymcute's handler thread.
 
#define ASYMCUTE_HANDLER_STACKSIZE   (THREAD_STACKSIZE_DEFAULT)
 Default stack size for Asymcute's handler thread.
 
#define ASYMCUTE_LISTENER_PRIO   (THREAD_PRIORITY_MAIN - 3)
 Default priority for an Asymcute listener thread. More...
 
#define ASYMCUTE_LISTENER_STACKSIZE   (THREAD_STACKSIZE_DEFAULT)
 Default stack size for an Asymcute listener thread.
 

Typedefs

typedef struct asymcute_con asymcute_con_t
 Forward type declaration for connections contexts.
 
typedef struct asymcute_req asymcute_req_t
 Forward type declaration for request contexts.
 
typedef struct asymcute_sub asymcute_sub_t
 Forward type declaration for subscription contexts.
 
typedef struct asymcute_topic asymcute_topic_t
 Forward type declaration for topic definitions.
 
typedef struct asymcute_will asymcute_will_t
 Forward type declaration for last will definitions.
 
typedef void(* asymcute_evt_cb_t) (asymcute_req_t *req, unsigned evt_type)
 Event callback used for communicating connection and request related events to the user. More...
 
typedef void(* asymcute_sub_cb_t) (const asymcute_sub_t *sub, unsigned evt_type, const void *data, size_t len, void *arg)
 Callback triggered on events for active subscriptions. More...
 
typedef unsigned(* asymcute_to_cb_t) (asymcute_con_t *con, asymcute_req_t *req)
 Context specific timeout callback, only used internally.
 

Enumerations

enum  {
  ASYMCUTE_OK = 0, ASYMCUTE_OVERFLOW = -1, ASYMCUTE_GWERR = -2, ASYMCUTE_NOTSUP = -3,
  ASYMCUTE_BUSY = -4, ASYMCUTE_REGERR = -5, ASYMCUTE_SUBERR = -6
}
 Return values used by public Asymcute functions. More...
 
enum  {
  ASYMCUTE_TIMEOUT, ASYMCUTE_CANCELED, ASYMCUTE_REJECTED, ASYMCUTE_CONNECTED,
  ASYMCUTE_DISCONNECTED, ASYMCUTE_REGISTERED, ASYMCUTE_PUBLISHED, ASYMCUTE_SUBSCRIBED,
  ASYMCUTE_UNSUBSCRIBED
}
 Possible event types passed to the event callback. More...
 

Functions

static bool asymcute_req_in_use (const asymcute_req_t *req)
 Check if a given request context is currently used. More...
 
static bool asymcute_sub_active (const asymcute_sub_t *sub)
 Check if a given subscription is currently active. More...
 
static void asymcute_topic_reset (asymcute_topic_t *topic)
 Reset the given topic. More...
 
static bool asymcute_topic_is_reg (const asymcute_topic_t *topic)
 Check if a given topic is currently registered with a gateway. More...
 
static bool asymcute_topic_is_init (const asymcute_topic_t *topic)
 Check if a given topic is initialized. More...
 
static bool asymcute_topic_equal (const asymcute_topic_t *a, const asymcute_topic_t *b)
 Compare two given topics and check if they are equal. More...
 
int asymcute_topic_init (asymcute_topic_t *topic, const char *topic_name, uint16_t topic_id)
 Initialize the given topic. More...
 
int asymcute_listener_run (asymcute_con_t *con, char *stack, size_t stacksize, char priority, asymcute_evt_cb_t callback)
 Start a listener thread. More...
 
void asymcute_handler_run (void)
 Start the global Asymcute handler thread for processing timeouts and keep alive events. More...
 
bool asymcute_is_connected (const asymcute_con_t *con)
 Check if the given connection context is connected to a gateway. More...
 
int asymcute_connect (asymcute_con_t *con, asymcute_req_t *req, sock_udp_ep_t *server, const char *cli_id, bool clean, asymcute_will_t *will)
 Connect to the given MQTT-SN gateway. More...
 
int asymcute_disconnect (asymcute_con_t *con, asymcute_req_t *req)
 Close the given connection. More...
 
int asymcute_register (asymcute_con_t *con, asymcute_req_t *req, asymcute_topic_t *topic)
 Register a given topic with the connected gateway. More...
 
int asymcute_publish (asymcute_con_t *con, asymcute_req_t *req, const asymcute_topic_t *topic, const void *data, size_t data_len, uint8_t flags)
 Publish the given data to the given topic. More...
 
int asymcute_subscribe (asymcute_con_t *con, asymcute_req_t *req, asymcute_sub_t *sub, asymcute_topic_t *topic, asymcute_sub_cb_t callback, void *arg, uint8_t flags)
 Subscribe to a given topic. More...
 
int asymcute_unsubscribe (asymcute_con_t *con, asymcute_req_t *req, asymcute_sub_t *sub)
 Cancel an active subscription. More...