Embedded MQTT client#

Functions#

int32_t
rsi_emb_mqtt_client_init(int8_t *server_ip, uint32_t server_port, uint32_t client_port, uint16_t flags, uint16_t keep_alive_interval, int8_t *clientid, int8_t *username, int8_t *password)

Create MQTT objects. TCP level connection happens in this API. This is a blocking API.

int32_t
rsi_emb_mqtt_connect(uint8_t mqtt_flags, int8_t *will_topic, uint16_t will_message_len, int8_t *will_message)

Connect to MQTT Server/Broker. MQTT level connection happens in this API. This is a blocking API.

int32_t
rsi_emb_mqtt_publish(int8_t *topic, rsi_mqtt_pubmsg_t *publish_msg)

Publish the given message on the topic specified. This is a blocking API.

int32_t
rsi_emb_mqtt_subscribe(uint8_t qos, int8_t *topic)

Subscribe to the topic specified. Thus, MQTT client will receive any data that is published on this topic. This is a blocking API.

int32_t

Unsubscribe to the topic specified.Thus, MQTT client will not receive any data published on this topic. This is a blocking API.

int32_t

Disconnect the client from MQTT Server/Broker. TCP and MQTT level disconnection take place here. This is a blocking API.

int32_t

Delete MQTT clients profile configuration. TCP level disconnection happens here, if required. This is a blocking API.

int32_t
rsi_emb_mqtt_register_call_back(uint32_t callback_id, void(*call_back_handler_ptr)(uint16_t status, uint8_t *buffer, const uint32_t length))

Register callbacks for MQTT Asynchronous messages. This is a non-blocking API.

int32_t
rsi_cal_mqtt_packet_len(int32_t rem_len)

Adjusted length of MQTT packet. This is a non-blocking API.

Function Documentation#

rsi_emb_mqtt_client_init#

int32_t rsi_emb_mqtt_client_init (int8_t * server_ip, uint32_t server_port, uint32_t client_port, uint16_t flags, uint16_t keep_alive_interval, int8_t * clientid, int8_t * username, int8_t * password)

Create MQTT objects. TCP level connection happens in this API. This is a blocking API.

Parameters
[in]server_ip

- MQTT client keep alive interval

[in]server_port

- client_id of MQTT_client which should be unique for different clients.

[in]client_port

- user_name of the MQTT_client which is a credential for logging to MQTT_server as an authentication

[in]flags

- Password of the MQTT_client which is also credential for MQTT_server as an authentication

N/Akeep_alive_interval
N/Aclientid
N/Ausername
N/Apassword

Flags

Description

BIT(0) - Clean Session

1 - Enable clean session for clearing the historic data

0 - Disable clean session

BIT(1) - SSL flag

1 - SSL Enable

0 - SSL Disable

BIT(2) - Server IP version

1 - IPV6

0 - IPV4

Returns

  • Zero - Success Negative Value - Failure -2 - Invalid parameters -3 - Command given in wrong state -4 - Packet allocation failure -5 - Command not supported -32 - Network command in progress -44 - Parameter length exceeds maximum value

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 59 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_connect#

int32_t rsi_emb_mqtt_connect (uint8_t mqtt_flags, int8_t * will_topic, uint16_t will_message_len, int8_t * will_message)

Connect to MQTT Server/Broker. MQTT level connection happens in this API. This is a blocking API.

Parameters
[in]mqtt_flags

- Network flags. Each bit in the flag has its own significance

Flags

Description

BIT(6) - pwdFlag

1 - Enable pwdFlag

0 - Disable pwdFlag

BIT(7) - usrFlag

1 - Enable usrFlag

0 - Disable usrFlag

[in]will_topic

- Will topic that the MQTT client wants the MQTT Server to publish when disconnected unexpectedly.

[in]will_message_len

- Length of will_message

[in]will_message

- Will message issued by the MQTT_Server for a broken client.

Note

  • will_topic and will_message are not supported and should be NULL.

Returns

  • Zero - Success Negative Value - Failure -3 - Command given in wrong state -4 - Packet allocation failure -5 - Command not supported -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.

  • For connecting Embedded_MQTT(emb_mqtt) over SSL : Enable TCP_IP_FEAT_SSL in Opermode parameters as below #define RSI_TCP_IP_FEATURE_BIT_MAP (TCP_IP_FEAT_DHCPV4_CLIENT | TCP_IP_FEAT_SSL | TCP_IP_FEAT_DNS_CLIENT) Load the related SSL Certificates in the module using rsi_wlan_set_certificate() API.


Definition at line 227 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_publish#

int32_t rsi_emb_mqtt_publish (int8_t * topic, rsi_mqtt_pubmsg_t * publish_msg)

Publish the given message on the topic specified. This is a blocking API.

Parameters
[in]topic

- Topic string on which MQTT client wants to publish data

[in]publish_msg

- Publish message

Returns

  • Zero - Success Negative Value - Failure -5 - Command not supported -2 - Invalid parameters -3 - Command given in wrong state -4 - Packet allocation failure -44 - Parameter length exceeds maximum value -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 327 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_subscribe#

int32_t rsi_emb_mqtt_subscribe (uint8_t qos, int8_t * topic)

Subscribe to the topic specified. Thus, MQTT client will receive any data that is published on this topic. This is a blocking API.

Parameters
[in]qos

- Quality of service of message at MQTT protocol level. Valid values are 0, 1, 2.

[in]topic

- Topic string on which MQTT client wants to subscribe.

Returns

  • Zero - Success Negative Value - Failure -5 - Command not supported -2 - Invalid parameters -3 - Command given in wrong state -4 - Packet allocation failure -44 - Parameter length exceeds maximum value -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 454 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_unsubscribe#

int32_t rsi_emb_mqtt_unsubscribe (int8_t * topic)

Unsubscribe to the topic specified.Thus, MQTT client will not receive any data published on this topic. This is a blocking API.

Parameters
[in]topic

- Topic string to which MQTT client wants to unsubscribe.

Returns

  • Zero - Success Negative Value - Failure -5 - Command not supported -2 - Invalid parameters -3 - Command given in wrong state -4 - Packet allocation failure -44 - Parameter length exceeds maximum value -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 556 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_disconnect#

int32_t rsi_emb_mqtt_disconnect ( Void)

Disconnect the client from MQTT Server/Broker. TCP and MQTT level disconnection take place here. This is a blocking API.

Parameters
[in]Void

Returns

  • Zero - Success Negative Value - Failure -5 - Command not supported -3 - Command given in wrong state -4 - Packet allocation failure -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 655 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_destroy#

int32_t rsi_emb_mqtt_destroy ( Void)

Delete MQTT clients profile configuration. TCP level disconnection happens here, if required. This is a blocking API.

Parameters
[in]Void

Returns

  • Zero - Success Negative Value - Failure -5 - Command not supported -3 - Command given in wrong state -4 - Packet allocation failure -32 - Network command in progress

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 737 of file network/protocols/rsi_emb_mqtt_client.c

rsi_emb_mqtt_register_call_back#

int32_t rsi_emb_mqtt_register_call_back (uint32_t callback_id, void(*)(uint16_t status, uint8_t *buffer, const uint32_t length) call_back_handler_ptr, status, buffer, length)

Register callbacks for MQTT Asynchronous messages. This is a non-blocking API.

Parameters
[in]callback_id

- Callback id for MQTT responses

[in]call_back_handler_ptr

- Callback function pointer

[out]status

- Success - RSI_SUCCESS Failure - Possible error codes are : 0x0030, 0x0036, 0x0065, 0xBBF1, 0xBBF2, 0xBBF3, 0xFFF6

[out]buffer

- Pointer to buffer which hold data

[out]length

- Length of the buffer

Returns

  • Status of the call_back_handler_ptr is returned


Definition at line 812 of file network/protocols/rsi_emb_mqtt_client.c

rsi_cal_mqtt_packet_len#

int32_t rsi_cal_mqtt_packet_len (int32_t rem_len)

Adjusted length of MQTT packet. This is a non-blocking API.

Parameters
[in]rem_len

- Length

Returns

  • adjusted rem_len - Success


Definition at line 847 of file network/protocols/rsi_emb_mqtt_client.c