77#ifndef CONFIG_ASYMCUTE_DEFAULT_PORT
78#define CONFIG_ASYMCUTE_DEFAULT_PORT (1883U)
84#ifndef CONFIG_ASYMCUTE_BUFSIZE
85#define CONFIG_ASYMCUTE_BUFSIZE (128U)
93#ifndef CONFIG_ASYMCUTE_TOPIC_MAXLEN
94#define CONFIG_ASYMCUTE_TOPIC_MAXLEN (32U)
104#ifndef CONFIG_ASYMCUTE_KEEPALIVE
105#define CONFIG_ASYMCUTE_KEEPALIVE (360)
116#ifndef CONFIG_ASYMCUTE_KEEPALIVE_PING
117#define CONFIG_ASYMCUTE_KEEPALIVE_PING ((CONFIG_ASYMCUTE_KEEPALIVE / 4) * 3)
130#ifndef CONFIG_ASYMCUTE_T_RETRY
131#define CONFIG_ASYMCUTE_T_RETRY (10U)
143#ifndef CONFIG_ASYMCUTE_N_RETRY
144#define CONFIG_ASYMCUTE_N_RETRY (3U)
148#ifndef ASYMCUTE_HANDLER_PRIO
152#define ASYMCUTE_HANDLER_PRIO (THREAD_PRIORITY_MAIN - 2)
155#ifndef ASYMCUTE_HANDLER_STACKSIZE
159#define ASYMCUTE_HANDLER_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
236 const void *data,
size_t len,
void *arg);
326 return (req->
con != NULL);
340 return (sub->
topic != NULL);
368 return (topic->
con != NULL);
410 return (topic->
name[0] !=
'\0');
533 const void *data,
size_t data_len, uint8_t flags);
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Provides a callback-with-argument event type.
Provides functionality to trigger events after timeout.
#define CONFIG_ASYMCUTE_BUFSIZE
Default buffer size used for receive and request buffers.
#define CONFIG_ASYMCUTE_TOPIC_MAXLEN
Maximum topic length.
unsigned(* asymcute_to_cb_t)(asymcute_con_t *con, asymcute_req_t *req)
Context specific timeout callback, only used internally.
int asymcute_unsubscribe(asymcute_con_t *con, asymcute_req_t *req, asymcute_sub_t *sub)
Cancel an active subscription.
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.
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.
static void asymcute_topic_reset(asymcute_topic_t *topic)
Reset the given topic.
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.
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.
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.
static bool asymcute_topic_is_init(const asymcute_topic_t *topic)
Check if a given topic is initialized.
static bool asymcute_topic_is_reg(const asymcute_topic_t *topic)
Check if a given topic is currently registered with a gateway.
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.
static bool asymcute_sub_active(const asymcute_sub_t *sub)
Check if a given subscription is currently active.
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_short(const asymcute_topic_t *topic)
Check if a given topic is a short topic.
static bool asymcute_req_in_use(const asymcute_req_t *req)
Check if a given request context is currently used.
int asymcute_topic_init(asymcute_topic_t *topic, const char *topic_name, uint16_t topic_id)
Initialize the given topic.
int asymcute_register(asymcute_con_t *con, asymcute_req_t *req, asymcute_topic_t *topic)
Register a given topic with the connected gateway.
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.
int asymcute_disconnect(asymcute_con_t *con, asymcute_req_t *req)
Close the given connection.
@ ASYMCUTE_CONNECTED
connected to gateway
@ ASYMCUTE_SUBSCRIBED
client was subscribed to topic
@ ASYMCUTE_DISCONNECTED
connection got disconnected
@ ASYMCUTE_UNSUBSCRIBED
client was unsubscribed from topic
@ ASYMCUTE_REJECTED
request was rejected
@ ASYMCUTE_REGISTERED
topic was registered
@ ASYMCUTE_CANCELED
request was canceled
@ ASYMCUTE_PUBLISHED
data was published
@ ASYMCUTE_TIMEOUT
request timed out
@ ASYMCUTE_NOTSUP
error: feature not supported
@ ASYMCUTE_GWERR
error: bad gateway connection state
@ ASYMCUTE_SUBERR
error: subscription invalid
@ ASYMCUTE_OVERFLOW
error: insufficient buffer space
@ ASYMCUTE_SENDERR
error: unable to sent packet
@ ASYMCUTE_BUSY
error: context already in use
@ ASYMCUTE_REGERR
error: registration invalid
@ MQTTSN_TIT_SHORT
topic ID: short
@ MQTTSN_TIT_PREDEF
topic ID: pre-defined
Generic MQTT-SN definitions.
Common IP-based transport layer end point.
Asymcute connection context.
sock_udp_t sock
socket used by a connections
event_callback_t keepalive_evt
keep alive event
asymcute_evt_cb_t user_cb
event callback provided by user
uint8_t rxbuf[CONFIG_ASYMCUTE_BUFSIZE]
connection specific receive buf
asymcute_req_t * pending
list holding pending requests
char cli_id[MQTTSN_CLI_ID_MAXLEN+1]
buffer to store client ID
event_timeout_t keepalive_timer
keep alive timer
mutex_t lock
synchronization lock
uint8_t keepalive_retry_cnt
keep alive transmission counter
uint16_t last_id
last used message ID for this connection
asymcute_sub_t * subscriptions
list holding active subscriptions
uint8_t state
connection state
Asymcute request context.
asymcute_con_t * con
connection the request is using
mutex_t lock
synchronization lock
asymcute_to_cb_t cb
internally used callback
event_timeout_t to_timer
timeout timer
uint8_t retry_cnt
retransmission counter
void * arg
internally used additional state
event_callback_t to_evt
timeout event
size_t data_len
length of the request packet in byte
uint16_t msg_id
used message id for this request
uint8_t data[CONFIG_ASYMCUTE_BUFSIZE]
buffer holding the request's data
struct asymcute_req * next
the requests list entry
Data-structure holding the state of subscriptions.
asymcute_sub_t * next
the subscriptions list entry
asymcute_sub_cb_t cb
called on incoming data
asymcute_topic_t * topic
topic we subscribe to
void * arg
user supplied callback argument
Data-structure for holding topics and their registration status.
uint8_t flags
normal, short, or pre-defined
asymcute_con_t * con
connection used for registration
char name[CONFIG_ASYMCUTE_TOPIC_MAXLEN+1]
topic string (ASCII only)
Data structure for defining a last will.
size_t msg_len
length of last will message content
void * msg
last will message content
const char * topic
last will topic
Callback Event structure definition.
sock utility function definitions