|
int16_t | MQTTServer_delete (MQTTServer_Handle handle) |
|
MQTTServer_Handle | MQTTServer_create (MQTTServer_CallBack defaultCallback, MQTTServer_Params *attrib) |
|
int16_t | MQTTServer_run (MQTTServer_Handle handle) |
|
int16_t | MQTTServer_subscribe (MQTTServer_Handle handle, MQTTServer_SubscribeParams *value, uint8_t numberOfTopics) |
|
int16_t | MQTTServer_unsubscribe (MQTTServer_Handle handle, MQTTServer_UnSubscribeParams *value, uint8_t numberOfTopics) |
|
int16_t | MQTTServer_publish (MQTTServer_Handle handle, char *topic, uint16_t topicLen, char *msg, uint16_t msgLen, uint32_t flags) |
|
int16_t | MQTTServer_set (MQTTServer_Handle handle, uint16_t option, void *value, uint16_t valueLength) |
|
Library Usage
To use the MQTTServer APIs, the application should include its header file as follows:
And, add the following MQTT library to the link line:
.../source/ti/net/mqtt/{toolchain}/{isa}/mqtt_{profile}.a
§ MQTTServer_CallBack
typedef void(* MQTTServer_CallBack) (int32_t event, void *metaData, uint32_t metaDateLen, void *data, uint32_t dataLen) |
§ MQTTServer_Handle
§ MQTTServer_SubscribeParams
§ MQTTServer_UnSubscribeParams
§ MQTTServer_LocalAuthenticationData
§ MQTTServer_ConnectMetaDataCB
§ MQTTServer_RecvMetaDataCB
§ MQTTServer_DisconnectMetaDataCB
§ MQTTServer_ConnParams
Secure Socket Parameters to open a secure connection
§ MQTTServer_Option
Enumerator |
---|
MQTTServer_USER_NAME | |
MQTTServer_PASSWORD | |
§ MQTTServer_EventCB
Enumerator |
---|
MQTTServer_RECV_CB_EVENT | |
MQTTServer_CONNECT_CB_EVENT | |
MQTTServer_DISCONNECT_CB_EVENT | |
§ MQTTServer_delete()
Delete the MQTTServer
Disconnect and remove all MQTT Server connections and data.
- Parameters
-
[in] | handle | Instance of the MQTTServer |
- Returns
- 0 on success or error code on failure.
- See also
- MQTTServer_create()
§ MQTTServer_create()
Create an MQTTServer instance
A caller must initialize the MQTT Server implementation prior to using its services.
- Parameters
-
[in] | attrib | parameters |
[in] | defaultCallback | async event handler |
- Returns
- Success Handle or Failure NULL
- See also
- MQTTServer_delete()
§ MQTTServer_run()
Start an MQTTServer instance
Main Task loop function that will start the MQTT server Connect and wait for data received
- Parameters
-
[in] | handle | MQTTServer instance handle |
- Returns
- Success (0) or Failure (Negative number)
- See also
- MQTTServer_create()
§ MQTTServer_subscribe()
SUBSCRIBE a set of topics. To receive data about a set of topics from the server, the app through this routine must subscribe to those topic names with the server. The caller can indicate whether the routine should block until a time, the message has been acknowledged by the server.
In case, the app has chosen not to await for the ACK from the server, the SL MQTT implementation will notify the app about the subscription through the callback routine.
- Parameters
-
[in] | handle | refers to the handle to the client context |
[in] | value | a pointer to a struct of subscribe parameters which hold:
Topic name to subscribe. It is a pointer to NUL terminated strings.
Qos value for the topic.
persistent session flag in order to enable or disable persistent session.
callback function which is optional - if NULL use the default callback
|
[in] | numberOfTopics | number of such topics |
- Returns
- Success(transaction Message ID) or Failure(Negative number)
§ MQTTServer_unsubscribe()
UNSUBSCRIBE a set of topics. The app should use this service to stop receiving data for the named topics from the server.
- Parameters
-
[in] | handle | refers to the handle to the client context |
[in] | value | topics set of topics to be unsubscribed. It is an array of pointers to NUL terminated strings. |
[in] | numberOfTopics | count number of topics to be unsubscribed |
- Returns
- Success(transaction Message ID) or Failure(Negative number)
§ MQTTServer_publish()
int16_t MQTTServer_publish |
( |
MQTTServer_Handle |
handle, |
|
|
char * |
topic, |
|
|
uint16_t |
topicLen, |
|
|
char * |
msg, |
|
|
uint16_t |
msgLen, |
|
|
uint32_t |
flags |
|
) |
| |
PUBLISH a named message to the server. In addition to the PUBLISH specific parameters, the caller can indicate whether the routine should block until the time, the message has been acknowledged by the server. This is applicable only for non-QoS0 messages.
In case, the app has chosen not to await for the ACK from the server, the SL MQTT implementation will notify the app about the subscription through the callback routine.
- Parameters
-
[in] | handle | refers to the handle to the client context |
[in] | topic | topic of the data to be published. It is NULL terminated. |
[in] | topicLen | topic length. |
[in] | msg | binary data to be published |
[in] | msgLen | length of the msg |
[in] | flags | QOS define MQTT_PUBLISH_QOS_0, MQTT_PUBLISH_QOS_1 or MQTT_PUBLISH_QOS_2 use MQTT_PUBLISH_RETAIN is message should be retained |
- Returns
- Success(transaction Message ID) or Failure(Negative number)
§ MQTTServer_set()
int16_t MQTTServer_set |
( |
MQTTServer_Handle |
handle, |
|
|
uint16_t |
option, |
|
|
void * |
value, |
|
|
uint16_t |
valueLength |
|
) |
| |
Setting Server parameters. This function can set different parameters to the server. User name and password - for Clients Authentication
- Parameters
-
[in] | handle | refers to the handle to the client context |
[in] | option | Define the actual option to set. Applicable values:
|
[in] | value | Specifies a value for the option |
[in] | valueLength | Specifies the length of the value |
- Returns
- Success(0) or Failure(Negative number)