Rover API Documentation
rover::RoverMQTTCommand Class Reference

RoverMQTTCommand class is an implementation class extending RoverPahoMQTT for rover-specific topic subscription and publishing using JSON for parsing and using predefined type variables such as RoverControlData_t and RoverSensorData_t. More...

#include <rover_mqttcommand.hpp>

Inheritance diagram for rover::RoverMQTTCommand:
rover::RoverPahoMQTT

Public Member Functions

 RoverMQTTCommand (char *host, const int port, const int roverID, const int qos, char *username, char *password, char *clientID)
 Copy constructor for RoverMQTTCommand class that uses username and password. More...
 
 RoverMQTTCommand (char *host, const int port, const int roverID, const int qos, char *clientID)
 Copy constructor for RoverMQTTCommand class that doesn't use credentials. More...
 
 ~RoverMQTTCommand ()
 Destructor for RoverMQTTCommand class. More...
 
int publishToTelemetryTopic (RoverSensorData_t sensor_data)
 Publishes a message to rover's telemetry topic (using redirected topic method) More...
 
int publishToTelemetryTopicNonRedirected (RoverSensorData_t sensor_data)
 Publishes a message to rover's telemetry topic (using unredirected topic method) More...
 
int subscribeToDrivingTopic (void)
 Subscribes to rover's driving topic. More...
 
int unsubscribeToDrivingTopic (void)
 Unsubscribes to rover's driving topic. More...
 
int connectRover (void)
 connectRover connects to the MQTT broker. Each rover ideally should have only one client, instantiated internally within RoverMQTTCommand class. More...
 
int getRoverConnected (void)
 Returns rover connected flag. More...
 
RoverControlData_t readFromDrivingTopic (void)
 Returns the retrieved driving information. More...
 
char * getTopicName (void)
 Retrieves topic name. More...
 
int getRoverID (void)
 Retrieves Rover ID. More...
 
void setRoverID (const int rover_id)
 Sets Rover ID. More...
 

Private Attributes

int ROVER_ID
 Given rover identification for multi-agent MQTT communication with a single cloud. More...
 
- Private Attributes inherited from rover::RoverPahoMQTT
char * HOST_NAME
 Host name used for connecting to the Eclipse Paho MQTT server. More...
 
int PORT
 Port used for connecting to the Eclipse Paho MQTT server. More...
 
RoverMQTT_SubscribeData_t defaultRoverSubscribeData
 Member attribute for subscribed data. More...
 
RoverMQTT_Configure_t defaultRoverMQTTConfigure
 Member attribute for configuration data. More...
 
RoverMQTT_StatusFlags_t defaultRoverMQTTFlags
 Member attribute for flags. More...
 
RoverMQTT_ReturnCodes_t defaultReturnCodes
 Member attribute for return codes. More...
 
MQTTAsync client = NULL
 Client object from MQTTAsync. More...
 
MQTTClient client2
 Client object from MQTTClient. More...
 
MQTTAsync_connectOptions conn_opts
 Connect options. More...
 
MQTTAsync_disconnectOptions disc_opts
 Disconnect options. More...
 
volatile MQTTAsync_token deliveredtoken
 Delivered token. More...
 

Additional Inherited Members

- Private Member Functions inherited from rover::RoverPahoMQTT
 ~RoverPahoMQTT ()
 Destructor for RoverPahoMQTT class. More...
 
 RoverPahoMQTT ()
 Default constructor for RoverPahoMQTT class. More...
 
 RoverPahoMQTT (char *host_name, int port, RoverMQTT_Configure_t MQTT_Configure)
 Copy constructor for RoverPahoMQTT. More...
 
void setHostName (char *host_name)
 Sets private attribute HOST_NAME. More...
 
void setPort (const int port)
 Sets private attribute PORT. More...
 
void setPayload (const char *payload, int payloadLen)
 Sets payload. More...
 
void setTopic (char *topic)
 Sets topic name. More...
 
int read (char *data)
 Public member function for reading subscribed data. This function requires the RoverPahoMQTT to be subscribed first. More...
 
int isDataReady (void)
 Public member function checking if the subscribed data is ready. 0-> data ready -1-> data not ready. More...
 
int publish (void)
 Used for publishing to a topic in an MQTT-broker using asynchronous method. More...
 
int connect (void)
 Used for connecting to MQTT broker asynchronously. More...
 
int subscribe (void)
 Used for subscribing to a topic in an MQTT-broker. To unsubscribe use: RoverPahoMQTT::unsubscribe() More...
 
int unsubscribe (void)
 Used for unsubscribing and disconnecting from a subscription to a topic in an MQTT-broker. More...
 
int getConnected (void)
 Returns connected flag. More...
 
void createClient (void)
 Create the MQTT client object. More...
 
void destroyClient (void)
 Destroy the MQTT client object. More...
 
void flushFlags (void)
 Private member function to flush the connection flags for new operation. More...
 
void constructAddress (void)
 Used for constructing the connection address by writing to private attribute my_address. More...
 
void onConnect (MQTTAsync_successData *response)
 Member callback function for onPublisherConnect actions. More...
 
void onPublisherSend (MQTTAsync_successData *response)
 Member callback function for onPublisherSend actions. More...
 
int onSubscriberMessageArrived (char *topicName, int topicLen, MQTTAsync_message *message)
 Member callback function for onSubscriberMessageArrived actions. More...
 
void onSubscribe (MQTTAsync_successData *response)
 Member callback function for onSubscribe actions. More...
 
void onSubscribeFailure (MQTTAsync_failureData *response)
 Member callback function for onSubscribeFailure actions. More...
 
void onConnectFailure (MQTTAsync_failureData *response)
 Member callback function for onConnectFailure actions. More...
 
void onConnectionLost (char *cause)
 Member callback function for onConnectionLost actions. More...
 
void onDisconnect (MQTTAsync_successData *response)
 Member callback function for onDisconnect actions. More...
 
- Private Member Functions inherited from rover::RoverCloud
virtual ~RoverCloud ()
 Virtual destructor. More...
 
- Static Private Member Functions inherited from rover::RoverPahoMQTT
static void onConnect_Redirect (void *context, MQTTAsync_successData *response)
 Static function responsible for calling RoverPahoMQTT::onPublisherConnect in a given RoverPahoMQTT context. More...
 
static void onPublisherSend_Redirect (void *context, MQTTAsync_successData *response)
 Static function responsible for calling RoverPahoMQTT::onPublisherSend in a given RoverPahoMQTT context. More...
 
static int onSubscriberMessageArrived_Redirect (void *context, char *topicName, int topicLen, MQTTAsync_message *message)
 Static function responsible for calling RoverPahoMQTT::onSubscriberMessageArrived in a given RoverPahoMQTT context. More...
 
static void onSubscribe_Redirect (void *context, MQTTAsync_successData *response)
 Static function responsible for calling RoverPahoMQTT::onSubscribe in a given RoverPahoMQTT context. More...
 
static void onSubscribeFailure_Redirect (void *context, MQTTAsync_failureData *response)
 Static function responsible for calling RoverPahoMQTT::onSubscribeFailure in a given RoverPahoMQTT context. More...
 
static void onConnectFailure_Redirect (void *context, MQTTAsync_failureData *response)
 Static function responsible for calling RoverPahoMQTT::onConnectFailure in a given RoverPahoMQTT context. More...
 
static void onConnectionLost_Redirect (void *context, char *cause)
 Static function responsible for calling RoverPahoMQTT::onConnectionLost in a given RoverPahoMQTT context. More...
 
static void onDisconnect_Redirect (void *context, MQTTAsync_successData *response)
 Static function responsible for calling RoverPahoMQTT::onDisconnect in a given RoverPahoMQTT context. More...
 

Detailed Description

RoverMQTTCommand class is an implementation class extending RoverPahoMQTT for rover-specific topic subscription and publishing using JSON for parsing and using predefined type variables such as RoverControlData_t and RoverSensorData_t.

Constructor & Destructor Documentation

rover::RoverMQTTCommand::RoverMQTTCommand ( char *  host,
const int  port,
const int  roverID,
const int  qos,
char *  username,
char *  password,
char *  clientID 
)

Copy constructor for RoverMQTTCommand class that uses username and password.

rover::RoverMQTTCommand::RoverMQTTCommand ( char *  host,
const int  port,
const int  roverID,
const int  qos,
char *  clientID 
)

Copy constructor for RoverMQTTCommand class that doesn't use credentials.

rover::RoverMQTTCommand::~RoverMQTTCommand ( )

Destructor for RoverMQTTCommand class.

Member Function Documentation

int rover::RoverMQTTCommand::connectRover ( void  )

connectRover connects to the MQTT broker. Each rover ideally should have only one client, instantiated internally within RoverMQTTCommand class.

Returns
Return code 0-> success, non-zero -> fail 1: Connection refused: Unacceptable protocol version
2: Connection refused: Identifier rejected
3: Connection refused: Server unavailable
4: Connection refused: Bad user name or password
5: Connection refused: Not authorized
6-255: Reserved for future use
Reference: [paho.mqtt.c] Asynchronous MQTT Client Documentation
int rover::RoverMQTTCommand::getRoverConnected ( void  )

Returns rover connected flag.

Returns
connected flag 1:connected 0: not connected
int rover::RoverMQTTCommand::getRoverID ( void  )

Retrieves Rover ID.

Returns
rover_id Rover ID
char * rover::RoverMQTTCommand::getTopicName ( void  )

Retrieves topic name.

Returns
topic_name Topic name
int rover::RoverMQTTCommand::publishToTelemetryTopic ( RoverSensorData_t  sensor_data)

Publishes a message to rover's telemetry topic (using redirected topic method)

Publishing with redirected topics Rover —>telemetry—> EclipseHono —> rover/<roverid>/telemetry —> Rover Telemetry UI

Parameters
sensor_dataSensor data to be used in the message
Returns
Return code 0-> success; others-> fail sreturn codes 1: Connection refused: Unacceptable protocol version
2: Connection refused: Identifier rejected
3: Connection refused: Server unavailable
4: Connection refused: Bad user name or password
5: Connection refused: Not authorized
6-255: Reserved for future use
Reference: [paho.mqtt.c] Asynchronous MQTT Client Documentation
int rover::RoverMQTTCommand::publishToTelemetryTopicNonRedirected ( RoverSensorData_t  sensor_data)

Publishes a message to rover's telemetry topic (using unredirected topic method)

Publishing with non- redirected topics Rover –> rover/<roverid>/telemetry –> EclipseHono –> rover/<roverid>/telemetry –> Rover Telemetry UI

Parameters
sensor_dataSensor data to be used in the message
Returns
Return code 0-> success; others-> fail sreturn codes 1: Connection refused: Unacceptable protocol version
2: Connection refused: Identifier rejected
3: Connection refused: Server unavailable
4: Connection refused: Bad user name or password
5: Connection refused: Not authorized
6-255: Reserved for future use
Reference: [paho.mqtt.c] Asynchronous MQTT Client Documentation
rover::RoverControlData_t rover::RoverMQTTCommand::readFromDrivingTopic ( void  )

Returns the retrieved driving information.

Returns
control_data control data that is retrieved
void rover::RoverMQTTCommand::setRoverID ( const int  rover_id)

Sets Rover ID.

Parameters
rover_idRover ID
int rover::RoverMQTTCommand::subscribeToDrivingTopic ( void  )

Subscribes to rover's driving topic.

Returns
Return code 0-> success; others-> fail sreturn codes 1: Connection refused: Unacceptable protocol version
2: Connection refused: Identifier rejected
3: Connection refused: Server unavailable
4: Connection refused: Bad user name or password
5: Connection refused: Not authorized
6-255: Reserved for future use
Reference: [paho.mqtt.c] Asynchronous MQTT Client Documentation
int rover::RoverMQTTCommand::unsubscribeToDrivingTopic ( void  )

Unsubscribes to rover's driving topic.

Returns
Return code 0-> success; others-> fail sreturn codes 1: Connection refused: Unacceptable protocol version
2: Connection refused: Identifier rejected
3: Connection refused: Server unavailable
4: Connection refused: Bad user name or password
5: Connection refused: Not authorized
6-255: Reserved for future use
Reference: [paho.mqtt.c] Asynchronous MQTT Client Documentation

Member Data Documentation

int rover::RoverMQTTCommand::ROVER_ID
private

Given rover identification for multi-agent MQTT communication with a single cloud.


The documentation for this class was generated from the following files: