Go to the documentation of this file.
43 #ifndef NET_ASYMCUTE_H
44 #define NET_ASYMCUTE_H
72 #ifndef CONFIG_ASYMCUTE_BUFSIZE_EXP
73 #define CONFIG_ASYMCUTE_BUFSIZE_EXP (7U)
81 #ifndef CONFIG_ASYMCUTE_TOPIC_MAXLEN
82 #define CONFIG_ASYMCUTE_TOPIC_MAXLEN (32U)
92 #ifndef CONFIG_ASYMCUTE_KEEPALIVE
93 #define CONFIG_ASYMCUTE_KEEPALIVE (360)
104 #ifndef CONFIG_ASYMCUTE_KEEPALIVE_PING
105 #define CONFIG_ASYMCUTE_KEEPALIVE_PING ((CONFIG_ASYMCUTE_KEEPALIVE / 4) * 3)
118 #ifndef CONFIG_ASYMCUTE_T_RETRY
119 #define CONFIG_ASYMCUTE_T_RETRY (10U)
131 #ifndef CONFIG_ASYMCUTE_N_RETRY
132 #define CONFIG_ASYMCUTE_N_RETRY (3U)
136 #ifndef ASYMCUTE_BUFSIZE
140 #define ASYMCUTE_BUFSIZE (1 << CONFIG_ASYMCUTE_BUFSIZE_EXP)
143 #ifndef ASYMCUTE_HANDLER_PRIO
147 #define ASYMCUTE_HANDLER_PRIO (THREAD_PRIORITY_MAIN - 2)
150 #ifndef ASYMCUTE_HANDLER_STACKSIZE
154 #define ASYMCUTE_HANDLER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
157 #ifndef ASYMCUTE_LISTENER_PRIO
163 #define ASYMCUTE_LISTENER_PRIO (THREAD_PRIORITY_MAIN - 3)
166 #ifndef ASYMCUTE_LISTENER_STACKSIZE
170 #define ASYMCUTE_LISTENER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
246 const void *data,
size_t len,
void *arg);
337 return (req->
con != NULL);
351 return (sub->
topic != NULL);
379 return (topic->
con != NULL);
393 return (topic->
name[0] !=
'\0');
534 const void *data,
size_t data_len, uint8_t flags);
Data structure for defining a last will.
Generic MQTT-SN definitions.
@ ASYMCUTE_CANCELED
request was canceled
unsigned(* asymcute_to_cb_t)(asymcute_con_t *con, asymcute_req_t *req)
Context specific timeout callback, only used internally.
@ ASYMCUTE_BUSY
error: context already in use
uint8_t flags
normal, short, or pre-defined
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.
size_t msg_len
length of last will message content
int asymcute_disconnect(asymcute_con_t *con, asymcute_req_t *req)
Close the given connection.
asymcute_sub_t * subscriptions
list holding active subscriptions
uint8_t keepalive_retry_cnt
keep alive transmission counter
#define assert(cond)
abort the program if assertion is false
int asymcute_register(asymcute_con_t *con, asymcute_req_t *req, asymcute_topic_t *topic)
Register a given topic with the connected gateway.
@ ASYMCUTE_PUBLISHED
data was published
sock_udp_ep_t server_ep
the gateway's UDP endpoint
int asymcute_unsubscribe(asymcute_con_t *con, asymcute_req_t *req, asymcute_sub_t *sub)
Cancel an active subscription.
asymcute_sub_cb_t cb
called on incoming data
POSIX.1-2008 compliant version of the assert macro.
Provides functionality to trigger events after timeout.
event_timeout_t to_timer
timeout timer
@ ASYMCUTE_DISCONNECTED
connection got disconnected
Provides a callback-with-argument event type.
static bool asymcute_req_in_use(const asymcute_req_t *req)
Check if a given request context is currently used.
uint8_t state
connection state
static bool asymcute_topic_is_reg(const asymcute_topic_t *topic)
Check if a given topic is currently registered with a gateway.
@ ASYMCUTE_UNSUBSCRIBED
client was unsubscribed from topic
@ ASYMCUTE_SUBSCRIBED
client was subscribed to topic
char name[CONFIG_ASYMCUTE_TOPIC_MAXLEN+1]
topic string (ACSII only)
@ ASYMCUTE_CONNECTED
connected to gateway
Callback Event structure definition.
int asymcute_topic_init(asymcute_topic_t *topic, const char *topic_name, uint16_t topic_id)
Initialize the given topic.
mutex_t lock
synchronization lock
char cli_id[MQTTSN_CLI_ID_MAXLEN+1]
buffer to store client ID
void * msg
last will message content
asymcute_sub_t * next
the subscriptions list entry
asymcute_to_cb_t cb
internally used callback
struct asymcute_req * next
the requests list entry
size_t data_len
length of the request packet in byte
asymcute_con_t * con
connection used for registration
uint8_t data[ASYMCUTE_BUFSIZE]
buffer holding the request's data
asymcute_topic_t * topic
topic we subscribe to
Asymcute request context.
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.
event_timeout_t keepalive_timer
keep alive timer
@ ASYMCUTE_REGERR
error: registration invalid
static bool asymcute_topic_is_init(const asymcute_topic_t *topic)
Check if a given topic is initialized.
Common IP-based transport layer end point.
Asymcute connection context.
uint8_t retry_cnt
retransmission counter
void * arg
internally used additional state
static bool asymcute_sub_active(const asymcute_sub_t *sub)
Check if a given subscription is currently active.
mutex_t lock
synchronization lock
static void asymcute_topic_reset(asymcute_topic_t *topic)
Reset the given topic.
@ ASYMCUTE_OVERFLOW
error: insufficient buffer space
uint16_t last_id
last used message ID for this connection
uint16_t msg_id
used message id for this request
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.
void asymcute_handler_run(void)
Start the global Asymcute handler thread for processing timeouts and keep alive events.
@ ASYMCUTE_REGISTERED
topic was registered
asymcute_evt_cb_t user_cb
event callback provided by user
@ ASYMCUTE_GWERR
error: bad gateway connection state
@ ASYMCUTE_NOTSUP
error: feature not supported
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.
event_callback_t keepalive_evt
keep alive event
uint8_t rxbuf[ASYMCUTE_BUFSIZE]
connection specific receive buf
@ ASYMCUTE_REJECTED
request was rejected
Data-structure for holding topics and their registration status.
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.
void * arg
user supplied callback argument
event_callback_t to_evt
timeout event
bool asymcute_is_connected(const asymcute_con_t *con)
Check if the given connection context is connected to a gateway.
Data-structure holding the state of subscriptions.
const char * topic
last will topic
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.
#define ASYMCUTE_BUFSIZE
Default buffer size used for receive and request buffers.
asymcute_req_t * pending
list holding pending requests
sock utility function definitions
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN
Maximum topic length.
sock_udp_t sock
socket used by a connections
@ ASYMCUTE_TIMEOUT
request timed out
asymcute_con_t * con
connection the request is using
@ ASYMCUTE_SUBERR
error: subscription invalid
int asymcute_listener_run(asymcute_con_t *con, char *stack, size_t stacksize, char priority, asymcute_evt_cb_t callback)
Start a listener thread.