mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add a basic password for mqtt
This commit is contained in:
parent
c3c041864d
commit
e4f213470c
2 changed files with 11 additions and 5 deletions
|
@ -271,6 +271,8 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
|
||||||
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
|
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
|
||||||
mqttConnectOptions.setAutomaticReconnect(true);
|
mqttConnectOptions.setAutomaticReconnect(true);
|
||||||
mqttConnectOptions.setCleanSession(false);
|
mqttConnectOptions.setCleanSession(false);
|
||||||
|
mqttConnectOptions.setUserName("xwuser");
|
||||||
|
mqttConnectOptions.setPassword("xw4r0cks".toCharArray());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setState( State.CONNECTING );
|
setState( State.CONNECTING );
|
||||||
|
@ -507,6 +509,8 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
|
||||||
{
|
{
|
||||||
Log.d( TAG, "%H.onFailure(%s, %s); cur state: %s", this, asyncActionToken,
|
Log.d( TAG, "%H.onFailure(%s, %s); cur state: %s", this, asyncActionToken,
|
||||||
exception, mState );
|
exception, mState );
|
||||||
|
ConnStatusHandler
|
||||||
|
.updateStatus( mContext, null, CommsConnType.COMMS_CONN_MQTT, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MsgThread extends Thread {
|
private class MsgThread extends Thread {
|
||||||
|
|
|
@ -74,12 +74,11 @@ onMessageReceived( struct mosquitto *mosq, void *userdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_callback( struct mosquitto *mosq, void *userdata, int result )
|
connect_callback( struct mosquitto *mosq, void *userdata, int err )
|
||||||
{
|
{
|
||||||
LOG_FUNC();
|
XP_LOGFF( "(err=%s)", mosquitto_strerror(err) );
|
||||||
XP_USE(mosq);
|
XP_USE(mosq);
|
||||||
XP_USE(userdata);
|
XP_USE(userdata);
|
||||||
XP_USE(result);
|
|
||||||
/* int i; */
|
/* int i; */
|
||||||
/* if(!result){ */
|
/* if(!result){ */
|
||||||
/* /\* Subscribe to broker information topics on successful connect. *\/ */
|
/* /\* Subscribe to broker information topics on successful connect. *\/ */
|
||||||
|
@ -181,6 +180,9 @@ mqttc_init( LaunchParams* params )
|
||||||
struct mosquitto* mosq = storage->mosq =
|
struct mosquitto* mosq = storage->mosq =
|
||||||
mosquitto_new( storage->clientIDStr, cleanSession, storage );
|
mosquitto_new( storage->clientIDStr, cleanSession, storage );
|
||||||
|
|
||||||
|
err = mosquitto_username_pw_set( mosq, "xwuser", "xw4r0cks" );
|
||||||
|
XP_LOGFF( "mosquitto_username_pw_set() => %s", mosquitto_strerror(err) );
|
||||||
|
|
||||||
mosquitto_log_callback_set( mosq, log_callback );
|
mosquitto_log_callback_set( mosq, log_callback );
|
||||||
mosquitto_connect_callback_set( mosq, connect_callback );
|
mosquitto_connect_callback_set( mosq, connect_callback );
|
||||||
mosquitto_message_callback_set( mosq, onMessageReceived );
|
mosquitto_message_callback_set( mosq, onMessageReceived );
|
||||||
|
|
Loading…
Add table
Reference in a new issue