SendDataOverMQTT username/password?
응답
19. 4. 5 오전 11:01

Hi,

I would like to use username/password when connecting to a MQTT Borker.

Looking at the latest sample of the sample SendDataOverMQTT I miss an option to specify username/password for mqtt login.

In the sample I can follow the AppController.c invoking

Retcode_T MQTT_ConnectToBroker(MQTT_Connect_T * mqttConnect, uint32_t timeout)

Inside of MQTT_ConnectToBroker an internal MqttSession is generated. This MqttSession allows to specify:

	/// username for the connection, see MQTT spec 3.1.3.4.
	StringDescr_T username;
	/// password for the connection, see MQTT spec 3.1.3.5
	StringDescr_T password;

But this is not accessible from MQTT_ConnectToBroker.

Do I have to write my on implementation of MQTT_ConnectToBroker?

Retcode_T MQTT_ConnectToBroker(MQTT_Connect_T * mqttConnect, uint32_t timeout, MQTT_Credentials_T * cred)
{
...

    if (RC_OK != Mqtt_initializeInternalSession(&MqttSession))
	{
		retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_MQTT_INIT_INTERNAL_SESSION_FAILED);
	}
	MqttSession.username = cred->username;
	MqttSession.password = cred->password;
...
}

Will this work? Can I modify the MqttSession after its initialization?

 

--Christof

 

+1 (1 투표)
RE: SendDataOverMQTT username/password?
응답
19. 4. 8 오전 6:11 as a reply to Christof Strack.

Hi Christof

You can add username and password inxdk110/Apps/SendDataOverMQTT/source/ AppController.h

#define WLAN_SSID                           "YourWifiNetwork"

#define WLAN_PSK                            "YourWifiPassword"

Thanks

Priyashi

0 (0 투표)
RE: SendDataOverMQTT username/password?
응답
19. 4. 8 오전 8:33 as a reply to Priyashi Yadav.

Hi, Priyashi,

I meant the credentials for the mqtt session.

You pointed out how to set the credentials for the WIFI network, this is different.

 

--Christof

0 (0 투표)
RE: SendDataOverMQTT username/password?
응답
19. 4. 11 오전 9:15 as a reply to Christof Strack.

Hello Christof,

a little while ago i implemented a MQTT API for the XDK. You can connect your MQTT client to a public or custom MQTT broker with username and password.

To do that i recommend to use the API "Serval_Mqtt.h". You can find the API in the following path:

YourProject/SDK/xdk110/Libraries/ServalStack/3rd-party/ServalStack/api/ServalMqtt.h

This API allows you to implement the username and password functionality.

Best regards,

Christian

0 (0 투표)
RE: SendDataOverMQTT username/password?
응답
19. 8. 27 오전 10:22 as a reply to Christian Köhler.

Hi Christian,

I tried to use secured MQTT over workbench 3.6.  I found the API as you suggested.

----------------------------------------------------------------------------------------------------

struct MqttSession_S

{

/// Version of MQTT to be used 3 for 3.1, 4 for 3.1.1. See MQTT spec 3.1.2.2 Protocol Level.

uint8_t MQTTVersion;

/// Identifier of the client, see MQTT spec 3.1.3.1.

StringDescr_T clientID;

/// username for the connection, see MQTT spec 3.1.3.4.

StringDescr_T username;

/// password for the connection, see MQTT spec 3.1.3.5

StringDescr_T password;

 

Where and how do I set the username and password?

Do I need to change the #define APP_MQTT_SECURE_ENABLE  0 in AppController.h to 1 too?

I am very new to RTOS programming. Please advise.

Best regards,

Sran S.

0 (0 투표)
RE: SendDataOverMQTT username/password?
응답
19. 9. 30 오후 2:41 as a reply to Sran Sribhibhadh.

Hello Sran,

as a starting point in the usage of MQTT i would recommend the example project "SendDataOverMQTT". In this project there is an already configured structure and you just need to add your specific data like username and password.

Normally you don't need to change the value of the define APP_MQTT_SECURE_ENABLE. This define configures if you want to use a connection to a TLS client.

I hope this was helpfull.

Best regards,

Christian

0 (0 투표)