question: public void connectionLost ( java . lang . Throwable cause ) { int rc = - 1 ; led . setAmber ( ) ; led . setFlash ( ) ; setTitleText ( "Connection Lost!....Reconnecting" ) ; synchronized ( this ) { writeLogln ( "MQTT Connection Lost!....Reconnecting to " + mqtt . getServerURI ( ) ) ; } try { while ( ( rc == - 1 ) && connected ) { try { synchronized ( connLostWait ) { connLostWait . wait ( 10000 ) ; } } catch ( InterruptedException iex ) { } synchronized ( this ) { if ( connected ) { writeLog ( "MQTT reconnecting......" ) ; try { connect ( mqtt . getServerURI ( ) , optionsComp . isPersistenceSelected ( ) ) ; rc = 0 ; } catch ( MqttException mqte ) { rc = - 1 ; } if ( rc == - 1 ) { writeLogln ( "failed" ) ; } else { writeLogln ( "success !" ) ; } } } } setTitleText ( "" ) ; } catch ( Exception ex ) { setTitleText ( "MQTT connection broken !" ) ; ex . printStackTrace ( ) ; disconnect ( ) ; } finally { if ( led . isFlashing ( ) ) { led . setFlash ( ) ; } } if ( connected ) { led . setGreen ( ) ; setConnected ( true ) ; } else { led . setRed ( ) ; setConnected ( false ) ; } }
target:  The method is part of the MqttSimpleCallback interface <BR>In the event of the MQTT connection being broken the LED is set to colour amber and made to flash. The code then keeps trying to reconnect until either a successful reconnect occurs or the disconnect button is pressed. Finally the LED is stopped flashing and set to  green or red depending upon whether the connect was successful or not.