JBWOPR
Loading...
Searching...
No Matches
MQTT related methods

Functions

bool JBWoprMqttDevice::mqttPublishMessage (const std::string &topic, JsonDocument &jsonDoc, bool retain=false)
 MQTT publish message.
 
bool JBWoprMqttDevice::mqttPublishMessage (const std::string &topic, const std::string &value, bool retain=false)
 MQTT publish message.
 
bool JBWoprMqttDevice::mqttPublishMessage (const char *topic, const char *value, bool retain=false)
 MQTT publish message.
 
bool JBWoprMqttDevice::_mqttStart ()
 Start MQTT.
 
void JBWoprMqttDevice::_mqttStop ()
 Stop MQTT.
 
bool JBWoprMqttDevice::_mqttReconnect ()
 Reconnect MQTT.
 
virtual bool JBWoprMqttDevice::_onMqttConnect ()
 Called when MQTT client get connected.
 
void JBWoprMqttDevice::_mqttCallback (const char *topic, const byte *payload, unsigned int length)
 MQTT callback.
 
virtual void JBWoprMqttDevice::_handleCommand (const std::string &entity, const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT command message.
 
virtual void JBWoprMqttDevice::_handleDeviceCommand (const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT device command message.
 
virtual void JBWoprMqttDevice::_handleConfigCommand (const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT config command message.
 
virtual void JBWoprMqttDevice::_handleEffectCommand (const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT effect command message.
 
virtual void JBWoprMqttDevice::_handleDisplayCommand (const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT display command message.
 
virtual void JBWoprMqttDevice::_handleDefconCommand (const std::string &subEntity, const std::string &command, const std::string &payload)
 Handle MQTT defcon command message.
 
virtual std::string JBWoprMqttDevice::_getTopic (const char *entityId, const char *subEntityId)
 Get publish topic for specified entity.
 
virtual std::string JBWoprMqttDevice::_getTopic (const std::string &entityId, const std::string &subEntityId)
 Get publish topic for specified entity.
 
virtual std::string JBWoprMqttDevice::_getSubscriptionTopic ()
 Get subscription topic.
 
virtual std::string JBWoprMqttDevice::_getAvailabilityTopic ()
 Get availability topic.
 

Detailed Description

Function Documentation

◆ _getAvailabilityTopic()

std::string JBWoprMqttDevice::_getAvailabilityTopic ( )
protectedvirtual

Get availability topic.

Returns
Availability topic

◆ _getSubscriptionTopic()

std::string JBWoprMqttDevice::_getSubscriptionTopic ( )
protectedvirtual

Get subscription topic.

Returns
Subscription topic

◆ _getTopic() [1/2]

std::string JBWoprMqttDevice::_getTopic ( const char *  entityId,
const char *  subEntityId 
)
protectedvirtual

Get publish topic for specified entity.

Parameters
entityIdEntity ID
subEntityIdSub entity ID
Returns
Topic

◆ _getTopic() [2/2]

std::string JBWoprMqttDevice::_getTopic ( const std::string &  entityId,
const std::string &  subEntityId 
)
protectedvirtual

Get publish topic for specified entity.

Parameters
entityIdEntity ID
subEntityIdSub entity ID
Returns
Topic

◆ _handleCommand()

void JBWoprMqttDevice::_handleCommand ( const std::string &  entity,
const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT command message.

This method will handle incoming MQTT command messages.

Parameters
entityEntity name
subEntitySub entity name
commandCommand
payloadPayload

◆ _handleConfigCommand()

void JBWoprMqttDevice::_handleConfigCommand ( const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT config command message.

This method will handle incoming MQTT config command messages.

Parameters
subEntitySub entity name
commandCommand
payloadPayload

◆ _handleDefconCommand()

void JBWoprMqttDevice::_handleDefconCommand ( const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT defcon command message.

This method will handle incoming MQTT defcon command messages.

Parameters
subEntitySub entity name
commandCommand
payloadPayload

◆ _handleDeviceCommand()

void JBWoprMqttDevice::_handleDeviceCommand ( const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT device command message.

This method will handle incoming MQTT device command messages.

Parameters
subEntitySub entity name
commandCommand
payloadPayload

◆ _handleDisplayCommand()

void JBWoprMqttDevice::_handleDisplayCommand ( const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT display command message.

This method will handle incoming MQTT display command messages.

Parameters
subEntitySub entity name
commandCommand
payloadPayload

◆ _handleEffectCommand()

void JBWoprMqttDevice::_handleEffectCommand ( const std::string &  subEntity,
const std::string &  command,
const std::string &  payload 
)
protectedvirtual

Handle MQTT effect command message.

This method will handle incoming MQTT effect command messages.

Parameters
subEntitySub entity name
commandCommand
payloadPayload

◆ _mqttCallback()

void JBWoprMqttDevice::_mqttCallback ( const char *  topic,
const byte *  payload,
unsigned int  length 
)
protected

MQTT callback.

This method is the callback for the MQTT client, and will handle incoming messages.

Parameters
topicMQTT topic
payloadMQTT payload
lengthMQTT payload length

◆ _mqttReconnect()

bool JBWoprMqttDevice::_mqttReconnect ( )
protected

Reconnect MQTT.

This method will check if connection is lost and try to reconnect the MQTT client as needed.

◆ _mqttStart()

bool JBWoprMqttDevice::_mqttStart ( )
protected

Start MQTT.

This method will initialize the MQTT client.

Returns
True if successful

◆ _mqttStop()

void JBWoprMqttDevice::_mqttStop ( )
protected

Stop MQTT.

This method will stop the MQTT client.

◆ _onMqttConnect()

bool JBWoprMqttDevice::_onMqttConnect ( )
protectedvirtual

Called when MQTT client get connected.

This method will be called when the MQTT client is connected.

Reimplemented in JBWoprHADevice.

◆ mqttPublishMessage() [1/3]

bool JBWoprMqttDevice::mqttPublishMessage ( const char *  topic,
const char *  value,
bool  retain = false 
)

MQTT publish message.

This method will publish a message to the MQTT broker.

Parameters
topicMQTT topic
valueMQTT payload value
retainRetain message, default value is false
Returns
True if successful

◆ mqttPublishMessage() [2/3]

bool JBWoprMqttDevice::mqttPublishMessage ( const std::string &  topic,
const std::string &  value,
bool  retain = false 
)

MQTT publish message.

This method will publish a message to the MQTT broker.

Parameters
topicMQTT topic
valueMQTT payload value
retainRetain message, default value is false
Returns
True if successful

◆ mqttPublishMessage() [3/3]

bool JBWoprMqttDevice::mqttPublishMessage ( const std::string &  topic,
JsonDocument &  jsonDoc,
bool  retain = false 
)

MQTT publish message.

This method will publish a message to the MQTT broker.

Parameters
topicMQTT topic
jsonDocJSON document
retainRetain message, default value is false
Returns
True if successful