Morse Micro IoT SDK  2.9.7

Detailed Description

Data Structures

struct  mmagic_core_mqtt_start_agent_cmd_args
 Command arguments structure for mqtt_start_agent. More...
 
struct  mmagic_core_mqtt_start_agent_rsp_args
 Response arguments structure for mqtt_start_agent. More...
 
struct  mmagic_core_mqtt_publish_cmd_args
 Command arguments structure for mqtt_publish. More...
 
struct  mmagic_core_mqtt_subscribe_cmd_args
 Command arguments structure for mqtt_subscribe. More...
 
struct  mmagic_core_mqtt_stop_agent_cmd_args
 Command arguments structure for mqtt_stop_agent. More...
 
struct  mmagic_mqtt_message_received_event_args
 Event arguments structure for mqtt_message_received. More...
 
struct  mmagic_mqtt_broker_connection_event_args
 Event arguments structure for mqtt_broker_connection. More...
 

Typedefs

typedef void(* mmagic_mqtt_message_received_event_handler_t) (const struct mmagic_mqtt_message_received_event_args *event_args, void *arg)
 Handler for the mqtt-message_received event. More...
 
typedef void(* mmagic_mqtt_broker_connection_event_handler_t) (const struct mmagic_mqtt_broker_connection_event_args *event_args, void *arg)
 Handler for the mqtt-broker_connection event. More...
 

Functions

static enum mmagic_status mmagic_controller_mqtt_start_agent (struct mmagic_controller *controller, struct mmagic_core_mqtt_start_agent_cmd_args *cmd_args, struct mmagic_core_mqtt_start_agent_rsp_args *rsp_args)
 Starts the MQTT agent. More...
 
static enum mmagic_status mmagic_controller_mqtt_publish (struct mmagic_controller *controller, struct mmagic_core_mqtt_publish_cmd_args *cmd_args)
 Publishes a message on a topic. More...
 
static enum mmagic_status mmagic_controller_mqtt_subscribe (struct mmagic_controller *controller, struct mmagic_core_mqtt_subscribe_cmd_args *cmd_args)
 Subscribes to a topic. More...
 
static enum mmagic_status mmagic_controller_mqtt_stop_agent (struct mmagic_controller *controller, struct mmagic_core_mqtt_stop_agent_cmd_args *cmd_args)
 Stops the MQTT agent. More...
 
void mmagic_controller_register_mqtt_message_received_handler (struct mmagic_controller *controller, mmagic_mqtt_message_received_event_handler_t handler, void *arg)
 Register a handler for the mqtt-message_received event. More...
 
void mmagic_controller_register_mqtt_broker_connection_handler (struct mmagic_controller *controller, mmagic_mqtt_broker_connection_event_handler_t handler, void *arg)
 Register a handler for the mqtt-broker_connection event. More...
 

Typedef Documentation

◆ mmagic_mqtt_broker_connection_event_handler_t

typedef void(* mmagic_mqtt_broker_connection_event_handler_t) (const struct mmagic_mqtt_broker_connection_event_args *event_args, void *arg)

Handler for the mqtt-broker_connection event.

State of the connection to the broker (see mqtt-start).

Note
This function will be invoked in the context of the controller data link thread and should perform minimal processing.
Warning
This function must not invoke any mmagic API functions.
Parameters
event_argsNotication arguments received from the agent.
argOpaque argument that was provided when the callback was registered.

Definition at line 5708 of file mmagic_controller.h.

◆ mmagic_mqtt_message_received_event_handler_t

typedef void(* mmagic_mqtt_message_received_event_handler_t) (const struct mmagic_mqtt_message_received_event_args *event_args, void *arg)

Handler for the mqtt-message_received event.

Triggered when a message is received on a topic that has been subscribed to.

Note
This function will be invoked in the context of the controller data link thread and should perform minimal processing.
Warning
This function must not invoke any mmagic API functions.
Parameters
event_argsNotication arguments received from the agent.
argOpaque argument that was provided when the callback was registered.

Definition at line 5665 of file mmagic_controller.h.

Function Documentation

◆ mmagic_controller_mqtt_publish()

static enum mmagic_status mmagic_controller_mqtt_publish ( struct mmagic_controller *  controller,
struct mmagic_core_mqtt_publish_cmd_args cmd_args 
)
inlinestatic

Publishes a message on a topic.

Parameters
controllerReference to the controller handle.
[in]cmd_argsCommand arguments
Returns
MMAGIC_STATUS_OK else an appropriate error code.

Definition at line 5547 of file mmagic_controller.h.

◆ mmagic_controller_mqtt_start_agent()

static enum mmagic_status mmagic_controller_mqtt_start_agent ( struct mmagic_controller *  controller,
struct mmagic_core_mqtt_start_agent_cmd_args cmd_args,
struct mmagic_core_mqtt_start_agent_rsp_args rsp_args 
)
inlinestatic

Starts the MQTT agent.

Automatically handles reconnects with a backoff timer and saves up to 10 subscriptions across reconnects. Listen to "broker_connection" events for information about the state of the connection to the broker.

Parameters
controllerReference to the controller handle.
[in]cmd_argsCommand arguments
[out]rsp_argsPointer to the data structure to be filled out with the result. If the If the return code is not MMAGIC_STATUS_OK then the contents of this structure will be undefined.
Returns
MMAGIC_STATUS_OK else an appropriate error code.

Definition at line 5504 of file mmagic_controller.h.

◆ mmagic_controller_mqtt_stop_agent()

static enum mmagic_status mmagic_controller_mqtt_stop_agent ( struct mmagic_controller *  controller,
struct mmagic_core_mqtt_stop_agent_cmd_args cmd_args 
)
inlinestatic

Stops the MQTT agent.

Parameters
controllerReference to the controller handle.
[in]cmd_argsCommand arguments
Returns
MMAGIC_STATUS_OK else an appropriate error code.

Definition at line 5621 of file mmagic_controller.h.

◆ mmagic_controller_mqtt_subscribe()

static enum mmagic_status mmagic_controller_mqtt_subscribe ( struct mmagic_controller *  controller,
struct mmagic_core_mqtt_subscribe_cmd_args cmd_args 
)
inlinestatic

Subscribes to a topic.

Messages will arrive in the "message_received" event.

Parameters
controllerReference to the controller handle.
[in]cmd_argsCommand arguments
Returns
MMAGIC_STATUS_OK else an appropriate error code.

Definition at line 5586 of file mmagic_controller.h.

◆ mmagic_controller_register_mqtt_broker_connection_handler()

void mmagic_controller_register_mqtt_broker_connection_handler ( struct mmagic_controller *  controller,
mmagic_mqtt_broker_connection_event_handler_t  handler,
void *  arg 
)

Register a handler for the mqtt-broker_connection event.

State of the connection to the broker (see mqtt-start).

Note
The handler callbacks will be invoked in the context of the controller data link thread. The handler should perform minimal processing.
Warning
The handler callback must not invoke any mmagic API functions.
Parameters
controllerReference to the the controller handle.
handlerThe handler function to register.
argOpaque argument to be passed to the handler when it is invoked.

◆ mmagic_controller_register_mqtt_message_received_handler()

void mmagic_controller_register_mqtt_message_received_handler ( struct mmagic_controller *  controller,
mmagic_mqtt_message_received_event_handler_t  handler,
void *  arg 
)

Register a handler for the mqtt-message_received event.

Triggered when a message is received on a topic that has been subscribed to.

Note
The handler callbacks will be invoked in the context of the controller data link thread. The handler should perform minimal processing.
Warning
The handler callback must not invoke any mmagic API functions.
Parameters
controllerReference to the the controller handle.
handlerThe handler function to register.
argOpaque argument to be passed to the handler when it is invoked.