Loading...
Searching...
No Matches
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_DEFAULT_PORT   (1883U)
 Default UDP port to listen on.
 
#define CONFIG_ASYMCUTE_BUFSIZE   (128U)
 Default buffer size used for receive and request buffers.
 
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN   (32U)
 Maximum topic length.
 
#define CONFIG_ASYMCUTE_KEEPALIVE   (360)
 Keep alive interval [in s] communicated to the gateway.
 
#define CONFIG_ASYMCUTE_KEEPALIVE_PING   ((CONFIG_ASYMCUTE_KEEPALIVE / 4) * 3)
 Interval to use for sending periodic ping messages.
 
#define CONFIG_ASYMCUTE_T_RETRY   (10U)
 Resend interval [in seconds].
 
#define CONFIG_ASYMCUTE_N_RETRY   (3U)
 Number of retransmissions until requests time out.
 
#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.
 

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.
 
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.
 
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 , ASYMCUTE_SENDERR = -7
}
 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.
 
static bool asymcute_sub_active (const asymcute_sub_t *sub)
 Check if a given subscription is currently active.
 
static void asymcute_topic_reset (asymcute_topic_t *topic)
 Reset the given topic.
 
static bool asymcute_topic_is_reg (const asymcute_topic_t *topic)
 Check if a given topic is currently registered with a gateway.
 
static bool asymcute_topic_is_short (const asymcute_topic_t *topic)
 Check if a given topic is a short topic.
 
static bool asymcute_topic_is_predef (const asymcute_topic_t *topic)
 Check if a given topic is a pre-defined topic.
 
static bool asymcute_topic_is_init (const asymcute_topic_t *topic)
 Check if a given topic is initialized.
 
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.
 
int asymcute_topic_init (asymcute_topic_t *topic, const char *topic_name, uint16_t topic_id)
 Initialize the given topic.
 
void asymcute_handler_run (void)
 Start the global Asymcute handler thread for processing timeouts and keep alive events.
 
bool asymcute_is_connected (const asymcute_con_t *con)
 Check if the given connection context is connected to a gateway.
 
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, asymcute_evt_cb_t callback)
 Connect to the given MQTT-SN gateway.
 
int asymcute_disconnect (asymcute_con_t *con, asymcute_req_t *req)
 Close the given connection.
 
int asymcute_register (asymcute_con_t *con, asymcute_req_t *req, asymcute_topic_t *topic)
 Register a given topic with the connected gateway.
 
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.
 
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.
 
int asymcute_unsubscribe (asymcute_con_t *con, asymcute_req_t *req, asymcute_sub_t *sub)
 Cancel an active subscription.