Asymcute is an asynchronous MQTT-SN implementation. More...
Asymcute is an asynchronous MQTT-SN implementation.
Asymcute is a asynchronous MQTT-SN client implementation, aiming at providing the user a high degree of flexibility. It provides a flexible interface that allows users to issue any number of concurrent requests to one or more different gateways simultaneously.
Implemented features:
Missing features:
Modules | |
| Asymcute (MQTT-SN Client) compile configurations | |
| Compile-time configuration options for Asymcute, an asynchronous MQTT-SN implementation based on the OASIS MQTT-SN protocol. | |
Files | |
| file | asymcute.h |
| Asymcute MQTT-SN interface definition. | |
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 | 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. 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 , 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. 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_short (const asymcute_topic_t *topic) |
| Check if a given topic is a short topic. More... | |
| static bool | asymcute_topic_is_predef (const asymcute_topic_t *topic) |
| Check if a given topic is a pre-defined topic. 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... | |
| 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, asymcute_evt_cb_t callback) |
| 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... | |
| 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.
| [in] | req | pointer to the request context that triggered the event, may be NULL of unsolicited events |
| [in] | evt_type | type of the event |
Definition at line 223 of file asymcute.h.
| 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.
| [in] | sub | pointer to subscription context triggering this event |
| [in] | evt_type | type of the event |
| [in] | data | incoming data for PUBLISHED events, may be NULL |
| [in] | len | length of data in bytes |
| [in] | arg | user supplied argument |
Definition at line 234 of file asymcute.h.
| anonymous enum |
Return values used by public Asymcute functions.
Definition at line 164 of file asymcute.h.
| anonymous enum |
Possible event types passed to the event callback.
Definition at line 178 of file asymcute.h.
| 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.
| [in,out] | con | connection to use |
| [in,out] | req | request context to use for CONNECT procedure |
| [in] | server | UDP endpoint of the target gateway |
| [in] | cli_id | client ID to register with the gateway |
| [in] | clean | set true to start a clean session |
| [in] | will | last will (currently not implemented) |
| [in] | callback | user callback triggered on defined events |
cli_id is larger than ASYMCUTE_ID_MAXLEN | int asymcute_disconnect | ( | asymcute_con_t * | con, |
| asymcute_req_t * | req | ||
| ) |
Close the given connection.
| [in,out] | con | connection to close |
| [in,out] | req | request context to use for DISCONNECT procedure |
| void asymcute_handler_run | ( | void | ) |
Start the global Asymcute handler thread for processing timeouts and keep alive events.
This function is typically called during system initialization.
| bool asymcute_is_connected | ( | const asymcute_con_t * | con | ) |
Check if the given connection context is connected to a gateway.
| [in] | con | connection to check |
| 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.
| [in] | con | connection to use |
| [in,out] | req | request context used for PUBLISH procedure |
| [in] | topic | publish data to this topic |
| [in] | data | actual payload to send |
| [in] | data_len | size of data in bytes |
| [in] | flags | additional flags (QoS level, DUP, and RETAIN) |
| int asymcute_register | ( | asymcute_con_t * | con, |
| asymcute_req_t * | req, | ||
| asymcute_topic_t * | topic | ||
| ) |
Register a given topic with the connected gateway.
| [in] | con | connection to use |
| [in,out] | req | request context to use for REGISTER procedure |
| [in,out] | topic | topic to register |
|
inlinestatic |
Check if a given request context is currently used.
| [in] | req | request context to check |
Definition at line 322 of file asymcute.h.
|
inlinestatic |
Check if a given subscription is currently active.
| [in] | sub | subscription context to check |
Definition at line 336 of file asymcute.h.
| 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.
| [in] | con | connection to use |
| [in,out] | req | request context used for SUBSCRIBE procedure |
| [out] | sub | subscription context to store subscription state |
| [in,out] | topic | topic to subscribe to, must be initialized (see asymcute_topic_init()) |
| [in] | callback | user callback triggered on events for this subscription |
| [in] | arg | user supplied argument passed to the event callback |
| [in] | flags | additional flags (QoS level and DUP) |
|
inlinestatic |
Compare two given topics and check if they are equal.
| [in] | a | topic A |
| [in] | b | topic B |
Definition at line 421 of file asymcute.h.
| int asymcute_topic_init | ( | asymcute_topic_t * | topic, |
| const char * | topic_name, | ||
| uint16_t | topic_id | ||
| ) |
Initialize the given topic.
| [out] | topic | topic to initialize |
| [in] | topic_name | topic name (ASCII), may be NULL if topic should use a pre-defined topic ID |
| [in] | topic_id | pre-defined topic ID, or don't care if topic_name is given |
|
inlinestatic |
Check if a given topic is initialized.
| [in] | topic | topic to check |
Definition at line 406 of file asymcute.h.
|
inlinestatic |
Check if a given topic is a pre-defined topic.
| [in] | topic | topic to check |
Definition at line 392 of file asymcute.h.
|
inlinestatic |
Check if a given topic is currently registered with a gateway.
| [in] | topic | topic to check |
Definition at line 364 of file asymcute.h.
|
inlinestatic |
Check if a given topic is a short topic.
| [in] | topic | topic to check |
Definition at line 378 of file asymcute.h.
|
inlinestatic |
Reset the given topic.
| [out] | topic | topic to reset |
Definition at line 350 of file asymcute.h.
| int asymcute_unsubscribe | ( | asymcute_con_t * | con, |
| asymcute_req_t * | req, | ||
| asymcute_sub_t * | sub | ||
| ) |
Cancel an active subscription.
| [in] | con | connection to use |
| [in,out] | req | request context used for UNSUBSCRIBE procedure |
| [in,out] | sub | subscription to cancel |