BSB Developer Docs
Loading...
Searching...
No Matches
mqtt_config.h File Reference

Mqtt backend configuration strcuture types and APIs. More...

#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  MqttConfig
 Mqtt backend configuration structure. More...
 

Macros

#define MQTT_CONFIG_SERVER_URL_LEN   (64)
 Maximum server URL length (not counting the termination byte)
 
#define MQTT_CONFIG_SERVER_URL_DEFAULT   "default"
 Special value for the default server URL (determined by firmware)
 

Enumerations

enum  MqttClientCertType { MqttClientCertTypeDefault , MqttClientCertTypeCustom , MqttClientCertTypeNone , MqttClientCertTypeMax }
 Enumeration of supported client certificate types. More...
 

Functions

char * mqtt_config_serialize (const MqttConfig *config)
 Convert the MqttConfig object to a JSON representation.
 
bool mqtt_config_deserialize (MqttConfig *config, const char *json_text, size_t json_text_len)
 Construct a MqttConfig object from its JSON representation.
 
bool mqtt_config_is_valid (const MqttConfig *config)
 Check whether a MqttConfig object has valid field values.
 

Detailed Description

Mqtt backend configuration strcuture types and APIs.

Enumeration Type Documentation

◆ MqttClientCertType

Enumeration of supported client certificate types.

Note
To use custom certificates, put the files into the following locations:
  • /ext/apps_assets/mqtt/device.crt : custom certificate
  • /ext/apps_assets/mqtt/device.key : private key
Enumerator
MqttClientCertTypeDefault 

Built-in certificate.

MqttClientCertTypeCustom 

User-specified certificate.

MqttClientCertTypeNone 

No certificate.

MqttClientCertTypeMax 

Special value, internal use.

Function Documentation

◆ mqtt_config_deserialize()

bool mqtt_config_deserialize ( MqttConfig * config,
const char * json_text,
size_t json_text_len )

Construct a MqttConfig object from its JSON representation.

Note
Data pointed to by json_text may either be 0-terminated or not, provided that json_text_len is correct.
Parameters
[out]configpointer to the config to be constructed (must be allocated)
[in]json_textpointer to a character array containing the JSON representation
[in]json_text_lenlength of the json_text

◆ mqtt_config_is_valid()

bool mqtt_config_is_valid ( const MqttConfig * config)

Check whether a MqttConfig object has valid field values.

Parameters
[in]configpointer to the config to be checked
Returns
true if the config is valid, false otherwise

◆ mqtt_config_serialize()

char * mqtt_config_serialize ( const MqttConfig * config)

Convert the MqttConfig object to a JSON representation.

Note
The calling code is responsible for deleting the returned value when it is done with it
Parameters
[in]configpointer to the config to be serialized
Returns
pointer to a 0-terminated string on success, NULL on failure