@@ -2496,7 +2496,7 @@ Paho.MQTT = (function (global) {
24962496} ) ( window ) ;
24972497
24982498var webduino = webduino || {
2499- version : '0.5.2 '
2499+ version : '0.5.3 '
25002500} ;
25012501
25022502if ( typeof exports !== 'undefined' ) {
@@ -3154,34 +3154,40 @@ if (typeof exports !== 'undefined') {
31543154 proto ;
31553155
31563156 var TransportEvent = {
3157-
31583157 /**
31593158 * Fires when a transport is opened.
3160- *
3159+ *
31613160 * @event TransportEvent.OPEN
31623161 */
3163- OPEN : ' open' ,
3162+ OPEN : " open" ,
31643163
31653164 /**
31663165 * Fires when a transport receives a message.
3167- *
3166+ *
31683167 * @event TransportEvent.MESSAGE
31693168 */
3170- MESSAGE : ' message' ,
3169+ MESSAGE : " message" ,
31713170
31723171 /**
31733172 * Fires when a transport get an error.
3174- *
3173+ *
31753174 * @event TransportEvent.ERROR
31763175 */
3177- ERROR : ' error' ,
3176+ ERROR : " error" ,
31783177
31793178 /**
31803179 * Fires when a transport is closed.
3181- *
3180+ *
31823181 * @event TransportEvent.CLOSE
31833182 */
3184- CLOSE : 'close'
3183+ CLOSE : "close" ,
3184+
3185+ /**
3186+ * Fires when a transport is re-opened.
3187+ *
3188+ * @event TransportEvent.REOPEN
3189+ */
3190+ REOPEN : "reopen"
31853191 } ;
31863192
31873193 /**
@@ -3348,6 +3354,10 @@ if (typeof exports !== 'undefined') {
33483354
33493355 function detectStatusChange ( self , newStatus , oldStatus ) {
33503356 if ( newStatus === oldStatus ) {
3357+ if ( newStatus === STATUS . OK ) {
3358+ // Device reconnected
3359+ self . emit ( TransportEvent . REOPEN ) ;
3360+ }
33513361 return ;
33523362 }
33533363
@@ -4039,7 +4049,8 @@ if (typeof exports !== 'undefined') {
40394049 READY : 'ready' ,
40404050 ERROR : 'error' ,
40414051 BEFOREDISCONNECT : 'beforeDisconnect' ,
4042- DISCONNECT : 'disconnect'
4052+ DISCONNECT : 'disconnect' ,
4053+ RECONNECT : 'reconnect'
40434054 } ;
40444055
40454056 /**
@@ -4110,6 +4121,7 @@ if (typeof exports !== 'undefined') {
41104121
41114122 this . _initialVersionResultHandler = onInitialVersionResult . bind ( this ) ;
41124123 this . _openHandler = onOpen . bind ( this ) ;
4124+ this . _reOpenHandler = onReOpen . bind ( this ) ;
41134125 this . _messageHandler = onMessage . bind ( this ) ;
41144126 this . _errorHandler = onError . bind ( this ) ;
41154127 this . _closeHandler = onClose . bind ( this ) ;
@@ -4137,6 +4149,11 @@ if (typeof exports !== 'undefined') {
41374149 this . begin ( ) ;
41384150 }
41394151
4152+ function onReOpen ( ) {
4153+ this . _logger . info ( "onReOpen" , "Device re-online" ) ;
4154+ this . emit ( BoardEvent . RECONNECT ) ;
4155+ }
4156+
41404157 function onMessage ( data ) {
41414158 try {
41424159 this . _logger . info ( 'onMessage' , data ) ;
@@ -4568,7 +4585,7 @@ if (typeof exports !== 'undefined') {
45684585 proto . sendDigitalData = function ( pin , value ) {
45694586 try {
45704587 var portNum = Math . floor ( pin / 8 ) ;
4571-
4588+
45724589 if ( value === Pin . HIGH ) {
45734590 // Set the bit
45744591 this . _digitalPort [ portNum ] |= ( value << ( pin % 8 ) ) ;
@@ -4626,6 +4643,7 @@ if (typeof exports !== 'undefined') {
46264643 trsp . on ( TransportEvent . MESSAGE , this . _messageHandler ) ;
46274644 trsp . on ( TransportEvent . ERROR , this . _errorHandler ) ;
46284645 trsp . on ( TransportEvent . CLOSE , this . _closeHandler ) ;
4646+ trsp . on ( TransportEvent . REOPEN , this . _reOpenHandler ) ;
46294647 this . _transport = trsp ;
46304648 }
46314649 } ;
0 commit comments