Morse Micro IoT SDK  2.9.7
Morse M2M Interface Controller Data Link API

Detailed Description

This API provides the interface between the Controller library and the underlying data link implementation, which is platform and transport specific.

Modules

 

Data Structures

struct  mmagic_datalink_controller_init_args
 Initialization structure for mmagic_datalink_controller. More...
 

Macros

#define MMAGIC_DATALINK_CONTROLLER_ARGS_INIT   { 0 }
 Initializer for mmagic_datalink_controller_init_args. More...
 

Typedefs

typedef void(* mmagic_datalink_controller_rx_buffer_cb_t) (struct mmagic_datalink_controller *controller_dl, void *arg, struct mmbuf *buf)
 Prototype for callback function invoked when the mmagic_datalink_controller receives a data payload. More...
 

Functions

struct mmagic_datalink_controller * mmagic_datalink_controller_init (const struct mmagic_datalink_controller_init_args *args)
 Initialize the mmagic_datalink_controller. More...
 
void mmagic_datalink_controller_deinit (struct mmagic_datalink_controller *controller_dl)
 Deinitialize the mmagic_datalink_controller. More...
 
struct mmbufmmagic_datalink_controller_alloc_buffer_for_tx (struct mmagic_datalink_controller *controller_dl, size_t header_size, size_t payload_size)
 Allocates a buffer that can subsequently used with mmagic_datalink_controller_tx_buffer(). More...
 
int mmagic_datalink_controller_tx_buffer (struct mmagic_datalink_controller *controller_dl, struct mmbuf *buf)
 Transmits the given buffer as a packet to the agent. More...
 

Macro Definition Documentation

◆ MMAGIC_DATALINK_CONTROLLER_ARGS_INIT

#define MMAGIC_DATALINK_CONTROLLER_ARGS_INIT   { 0 }

Initializer for mmagic_datalink_controller_init_args.

Definition at line 92 of file mmagic_datalink_controller.h.

Typedef Documentation

◆ mmagic_datalink_controller_rx_buffer_cb_t

typedef void(* mmagic_datalink_controller_rx_buffer_cb_t) (struct mmagic_datalink_controller *controller_dl, void *arg, struct mmbuf *buf)

Prototype for callback function invoked when the mmagic_datalink_controller receives a data payload.

Note
The callback function will executed in a thread context.
Parameters
controller_dlThe datalink handle.
argUser argument that was given when the callback was registered.
bufmmbuf containing the received data. The callback takes ownership of the buffer and is responsible for releasing it.

Definition at line 74 of file mmagic_datalink_controller.h.

Function Documentation

◆ mmagic_datalink_controller_alloc_buffer_for_tx()

struct mmbuf * mmagic_datalink_controller_alloc_buffer_for_tx ( struct mmagic_datalink_controller *  controller_dl,
size_t  header_size,
size_t  payload_size 
)

Allocates a buffer that can subsequently used with mmagic_datalink_controller_tx_buffer().

The allocated buffer may also include additional space at the end of the payload to allow for things like CRC bits.

Parameters
controller_dlReference to the datalink handle.
header_sizeThe size of any headers that may be required.
payload_sizeThe size of the payload.
Returns
An mmbuf with the required space pre allocated. NULL on error.

◆ mmagic_datalink_controller_deinit()

void mmagic_datalink_controller_deinit ( struct mmagic_datalink_controller *  controller_dl)

Deinitialize the mmagic_datalink_controller.

Any resources used will be freed.

Parameters
controller_dlReference to the datalink handle.

◆ mmagic_datalink_controller_init()

struct mmagic_datalink_controller * mmagic_datalink_controller_init ( const struct mmagic_datalink_controller_init_args args)

Initialize the mmagic_datalink_controller.

Parameters
argsReference to the initialization arguments for the mmagic_datalink_controller.
Returns
Reference to the create controller_dl handle on success. Null on error.

◆ mmagic_datalink_controller_tx_buffer()

int mmagic_datalink_controller_tx_buffer ( struct mmagic_datalink_controller *  controller_dl,
struct mmbuf buf 
)

Transmits the given buffer as a packet to the agent.

This function will block until the whole packet has been transmitted or an error occurs. mmagic_datalink_controller_alloc_buffer_for_tx() should be used to allocated the buffer.

Parameters
controller_dlReference to the datalink handle.
bufThe buffer containing the data to be framed and sent to the agent. This function takes ownership of the buffer and is responsible for releasing it.
Returns
The number of bytes transmitted on success. Negative value on error.