mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +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.setAutomaticReconnect(true);
|
||||
mqttConnectOptions.setCleanSession(false);
|
||||
mqttConnectOptions.setUserName("xwuser");
|
||||
mqttConnectOptions.setPassword("xw4r0cks".toCharArray());
|
||||
|
||||
try {
|
||||
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,
|
||||
exception, mState );
|
||||
ConnStatusHandler
|
||||
.updateStatus( mContext, null, CommsConnType.COMMS_CONN_MQTT, false );
|
||||
}
|
||||
|
||||
private class MsgThread extends Thread {
|
||||
|
|
|
@ -74,12 +74,11 @@ onMessageReceived( struct mosquitto *mosq, void *userdata,
|
|||
}
|
||||
|
||||
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(userdata);
|
||||
XP_USE(result);
|
||||
/* int i; */
|
||||
/* if(!result){ */
|
||||
/* /\* Subscribe to broker information topics on successful connect. *\/ */
|
||||
|
@ -99,13 +98,13 @@ subscribe_callback( struct mosquitto *mosq, void *userdata, int mid,
|
|||
XP_USE(qos_count);
|
||||
XP_USE(granted_qos);
|
||||
XP_LOGFF ("Subscribed (mid: %d): %d", mid, granted_qos[0]);
|
||||
for( int ii=1; ii < qos_count; ii++ ) {
|
||||
for ( int ii = 1; ii < qos_count; ii++ ) {
|
||||
XP_LOGFF(", %d", granted_qos[ii]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
log_callback(struct mosquitto *mosq, void *userdata, int level, const char *str )
|
||||
log_callback( struct mosquitto *mosq, void *userdata, int level, const char *str )
|
||||
{
|
||||
XP_USE(mosq);
|
||||
XP_USE(userdata);
|
||||
|
@ -181,6 +180,9 @@ mqttc_init( LaunchParams* params )
|
|||
struct mosquitto* mosq = storage->mosq =
|
||||
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_connect_callback_set( mosq, connect_callback );
|
||||
mosquitto_message_callback_set( mosq, onMessageReceived );
|
||||
|
|
Loading…
Reference in a new issue