The Cayenne MQTT mbed Library provides functions to easily connect to the Cayenne IoT project builder.

Fork of Cayenne-MQTT-mbed by myDevicesIoT

Revision:
6:82e142a864ad
Parent:
4:421366004b5d
Child:
8:aec9cfdd4c8e
diff -r 421366004b5d -r 82e142a864ad src/CayenneMQTTClient/CayenneMQTTClient.h
--- a/src/CayenneMQTTClient/CayenneMQTTClient.h	Fri Oct 07 22:44:16 2016 +0000
+++ b/src/CayenneMQTTClient/CayenneMQTTClient.h	Tue Oct 25 16:19:29 2016 -0600
@@ -81,12 +81,14 @@
 		* @param[in] password Password
 		* @return success code
 		*/
-		int connect(char* username, char* clientID, char* password) {
+		int connect(const char* username, const char* clientID, const char* password) {
 			MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
 			data.MQTTVersion = 3;
-			data.clientID.cstring = _clientID = clientID;
-			data.username.cstring = _username = username;
-			data.password.cstring = password;
+			_clientID = clientID;
+			_username = username;
+			data.clientID.cstring = const_cast<char*>(_clientID);
+			data.username.cstring = const_cast<char*>(_username);
+			data.password.cstring = const_cast<char*>(password);
 			return Base::connect(data);
 		};
 
@@ -393,8 +395,8 @@
 		}
 
 	private:
-		char* _username;
-		char* _clientID;
+		const char* _username;
+		const char* _clientID;
 		struct CayenneMessageHandlers
 		{
 			const char* clientID;