David Fletcher / server

Dependents:   mqtt_V1 cc3100_Test_mqtt_CM3

Embed: (wiki syntax)

« Back to documentation index

The Server Library API(s)

The Server Library API(s)

Data Structures

struct  mqtt_server_msg_cbs
  Working Principle for implementing the call-back services: Implementation of the call-back services should report in return value, only about errors found in the RX processing. More...

Modules

 Helper Macros for RX CONNECT

Functions

int32_t mqtt_vh_msg_send (void *ctx_cl, uint8_t msg_type, enum mqtt_qos qos, bool has_vh, uint16_t vh_data)
 Send a Variable Header only message to the client.
int32_t mqtt_vh_msg_send_locked (void *ctx_cl, uint8_t msg_type, enum mqtt_qos qos, bool has_vh, uint16_t vh_data)
 mqtt_vh_msg_send() with mutual exclusion (in multi-task application).
int32_t mqtt_server_pub_dispatch (void *ctx_cl, struct mqtt_packet *mqp, bool dup)
 Dispatch application constructed PUBLISH message to the client.
int32_t mqtt_server_pub_dispatch_locked (void *ctx_cl, struct mqtt_packet *mqp, bool dup)
 mqtt_server_pub_dispatch() with mutual exclusion (in multi-task application).
int32_t mqtt_server_run (uint32_t wait_secs)
 Run the server packet LIB for the specified wait time.
int32_t mqtt_server_register_net_svc (const struct device_net_services *net)
 Abstraction for the device specific network services Network services for communication with the clients.
int32_t mqtt_server_lib_init (const struct mqtt_server_lib_cfg *cfg, const struct mqtt_server_msg_cbs *cbs)
 Initialize the MQTT Server Packet library This routine initializes the packet and network constructs that are required to manage the multiple network connetions.

Function Documentation

int32_t mqtt_server_lib_init ( const struct mqtt_server_lib_cfg *  cfg,
const struct mqtt_server_msg_cbs *  cbs 
)

Initialize the MQTT Server Packet library This routine initializes the packet and network constructs that are required to manage the multiple network connetions.

The server packet LIB must be initialized prior to invoking of any other routine or service.

Note:
This routine must be invoked only once in an run of the system.

If there are more than one application (tasks) that utilize the services of the server packet library, then certain configuration must be set in the LIB

See also:
struct mqtt_server_lib_cfg

The application should also provision the platform network specific network services into the packet library

See also:
mqtt_server_register_net_svc.

Once, the server LIB has been intialized successfully, it must be put into action, to listen to requests for incoming connections, by invoking the API mqtt_server_run.

Parameters:
[in]cfgconfiguration information for the MQTT server packet library
[in]cbscallback routines that LIB will invoke into the application
Returns:
0 on success otherwise -1.

Definition at line 969 of file server_pkts.cpp.

int32_t mqtt_server_pub_dispatch ( void *  ctx_cl,
struct mqtt_packet *  mqp,
bool  dup 
)

Dispatch application constructed PUBLISH message to the client.

Prior to sending the message to the client, this routine shall update the fixed-header to account for the duplicate flag that has been indicated by the caller.

The caller must populate the payload information of topic and data before invoking this service. In addition, the application must prepare, for the packet, the fix header leaving aside the duplicate flag - this flag shall be included in the fix heder by the LIB.

This service facilitates the application to re-use, iteratively, a single PUBLISH packet for multiple remote clients that have subscribed to the same topic for which the data is being published. The LIB does not free-up the MQTT packet after sending the packet to the remote client and the application is responsible for managing the packet container / memory

Parameters:
[in]ctx_clhandle to the underlying network context in the LIB. This handle is provided to the application by the LIB in the CONNECT callback.
[in]mqpapp created PUBLISH message alongwith the fixed header
[in]dupis this a duplicate message that is being sent to client?
Returns:
on success, the number of bytes transferred. Otherwise, error defined in lib_err_group

Definition at line 269 of file server_pkts.cpp.

int32_t mqtt_server_pub_dispatch_locked ( void *  ctx_cl,
struct mqtt_packet *  mqp,
bool  dup 
)

mqtt_server_pub_dispatch() with mutual exclusion (in multi-task application).

This routine ensures that the LIB sends the specified packet onto the network in a manner that excludes execution of any other control. This API has been enabled to support the scenarios, where the multi-tasked user application has chosen to use a mutex object other than the one provisioned in the packet LIB to streamline / serialize accesses to the services of the packet LIB.

Refer to mqtt_server_pub_dispatch for other details.

Definition at line 275 of file server_pkts.cpp.

int32_t mqtt_server_register_net_svc ( const struct device_net_services *  net )

Abstraction for the device specific network services Network services for communication with the clients.

Parameters:
[in]netrefers to network services supported by the platform
Returns:
on success, 0, otherwise -1

net_ops_group

Note:
all entries in net must be supported by the platform.

Definition at line 958 of file server_pkts.cpp.

int32_t mqtt_server_run ( uint32_t  wait_secs )

Run the server packet LIB for the specified wait time.

This routine yields the control back to the application after the specified duration of wait time. Such an arrangement enable the application to make overall progress to meet it intended functionality.

The wait time implies the maximum intermediate duration between the reception of two successive messages from the server. If no message is received before the expiry of the wait time, the routine returns. However, the routine would continue to block, in case, messages are being received within the successive period of wait time.

Parameters:
[in]wait_secsmaximum time to wait for a message from the server
Note:
if the value of MQP_ERR_LIBQUIT is returned, then system must be restarted.

Definition at line 912 of file server_pkts.cpp.

int32_t mqtt_vh_msg_send ( void *  ctx_cl,
uint8_t  msg_type,
enum mqtt_qos  qos,
bool  has_vh,
uint16_t  vh_data 
)

Send a Variable Header only message to the client.

Application should this routine to send PUBREL and PUBCOMP messages.

Parameters:
[in]ctx_clhandle to the underlying network context in the LIB. This handle is provided to the application by the LIB in the CONNECT callback.
[in]msg_typemessage type that has to be sent to the client
[in]qosQoS with which the message needs to send to server
[in]has_vhdoes this message has data in the variable header?
[in]vh_datadata <MSB:LSB> to be included in the variable header
Returns:
on success, the number of bytes transferred. Otherwise, errors defined in lib_err_group

Definition at line 222 of file server_pkts.cpp.

int32_t mqtt_vh_msg_send_locked ( void *  ctx_cl,
uint8_t  msg_type,
enum mqtt_qos  qos,
bool  has_vh,
uint16_t  vh_data 
)

mqtt_vh_msg_send() with mutual exclusion (in multi-task application).

This routine ensures that the LIB sends the specified VH MSG onto the network in a manner that excludes execution of any other control. This API has been enabled to support the scenarios, where the multi-tasked user application has chosen to use a mutex object other than the one provisioned in the packet LIB to streamline / serialize accesses to the services of the packet LIB.

Refer to mqtt_vh_msg_send for details

Definition at line 228 of file server_pkts.cpp.