@@ -65,7 +65,7 @@ class clientMqtt{
6565
6666 // Connect establishes a connection with mqtt, using token as the password, and returns a promise
6767// of a Symbol identifying the mqtt client
68- connect = options => new Promise ( ( resolve , reject ) => {
68+ connect ( options ) { return new Promise ( ( resolve , reject ) => {
6969 let ssl = false ;
7070 if ( options . ssl !== false ) {
7171 ssl = true ;
@@ -223,8 +223,8 @@ class clientMqtt{
223223
224224 client . connect ( connectionOpts ) ;
225225 } ) ;
226-
227- disconnect = ( ) => new Promise ( ( resolve , reject ) => {
226+ }
227+ disconnect ( ) { return new Promise ( ( resolve , reject ) => {
228228 if ( ! this . connection ) {
229229 return reject ( new Error ( 'disconnection failed: connection closed' ) ) ;
230230 }
@@ -252,8 +252,8 @@ class clientMqtt{
252252
253253 return resolve ( ) ;
254254 } ) ;
255-
256- updateToken = async function updateToken ( token ) {
255+ }
256+ async updateToken ( token ) {
257257 // This infinite loop will exit once the reconnection is successful -
258258 // and will pause between each reconnection tentative, every 5 secs.
259259 // eslint-disable-next-line no-constant-condition
@@ -296,7 +296,7 @@ class clientMqtt{
296296 }
297297 } ;
298298
299- subscribe = ( topic , cb ) => new Promise ( ( resolve , reject ) => {
299+ subscribe ( topic , cb ) { return new Promise ( ( resolve , reject ) => {
300300 if ( ! this . connection ) {
301301 return reject ( new Error ( 'subscription failed: connection closed' ) ) ;
302302 }
@@ -312,8 +312,8 @@ class clientMqtt{
312312 onFailure : error => reject ( new Error ( `subscription failed: ${ error . errorMessage } ` ) ) ,
313313 } ) ;
314314 } ) ;
315-
316- unsubscribe = topic => new Promise ( ( resolve , reject ) => {
315+ }
316+ unsubscribe ( topic ) { return new Promise ( ( resolve , reject ) => {
317317 if ( ! this . connection ) {
318318 return reject ( new Error ( 'disconnection failed: connection closed' ) ) ;
319319 }
@@ -323,8 +323,8 @@ class clientMqtt{
323323 onFailure : ( ) => reject ( ) ,
324324 } ) ;
325325 } ) ;
326-
327- arrayBufferToBase64 = ( buffer ) => {
326+ }
327+ arrayBufferToBase64 ( buffer ) {
328328 let binary = '' ;
329329 const bytes = new Uint8Array ( buffer ) ;
330330 const len = bytes . byteLength ;
@@ -334,32 +334,33 @@ class clientMqtt{
334334 return window . btoa ( binary ) ;
335335 } ;
336336
337- sendMessage = ( topic , message ) => new Promise ( ( resolve , reject ) => {
337+ sendMessage ( topic , message ) { return new Promise ( ( resolve , reject ) => {
338338 if ( ! this . connection ) {
339339 return reject ( new Error ( 'disconnection failed: connection closed' ) ) ;
340340 }
341341
342342 this . connection . publish ( topic , message , 1 , false ) ;
343343 return resolve ( ) ;
344344 } ) ;
345+ }
345346
346- openCloudMonitor = ( deviceId , cb ) => {
347+ openCloudMonitor ( deviceId , cb ) {
347348 const cloudMonitorOutputTopic = `/a/d/${ deviceId } /s/o` ;
348349 return subscribe ( cloudMonitorOutputTopic , cb ) ;
349350 } ;
350351
351352
352- writeCloudMonitor = ( deviceId , message ) => {
353+ writeCloudMonitor ( deviceId , message ) {
353354 const cloudMonitorInputTopic = `/a/d/${ deviceId } /s/i` ;
354355 return sendMessage ( cloudMonitorInputTopic , message ) ;
355356 } ;
356357
357- closeCloudMonitor = ( deviceId ) => {
358+ closeCloudMonitor ( deviceId ) {
358359 const cloudMonitorOutputTopic = `/a/d/${ deviceId } /s/o` ;
359360 return unsubscribe ( cloudMonitorOutputTopic ) ;
360361 } ;
361362
362- toCloudProtocolV2 = ( cborValue ) => {
363+ toCloudProtocolV2 ( cborValue ) {
363364 const cloudV2CBORValue = { } ;
364365 let cborLabel = null ;
365366
@@ -420,7 +421,7 @@ class clientMqtt{
420421 return cloudV2CBORValue ;
421422 } ;
422423
423- sendProperty = ( thingId , name , value , timestamp ) => {
424+ sendProperty ( thingId , name , value , timestamp ) {
424425 const propertyInputTopic = `/a/t/${ thingId } /e/i` ;
425426
426427 if ( timestamp && ! Number . isInteger ( timestamp ) ) {
@@ -495,7 +496,7 @@ class clientMqtt{
495496 return sendMessage ( propertyInputTopic , CBOR . encode ( [ cborValue ] , true ) ) ;
496497 } ;
497498
498- getSenml = ( deviceId , name , value , timestamp ) => {
499+ getSenml ( deviceId , name , value , timestamp ) {
499500 if ( timestamp && ! Number . isInteger ( timestamp ) ) {
500501 throw new Error ( 'Timestamp must be Integer' ) ;
501502 }
@@ -577,12 +578,12 @@ class clientMqtt{
577578 return senMl ;
578579 } ;
579580
580- getCborValue = ( senMl ) => {
581+ getCborValue ( senMl ) {
581582 const cborEncoded = CBOR . encode ( senMl ) ;
582583 return arrayBufferToBase64 ( cborEncoded ) ;
583584 } ;
584585
585- onPropertyValue = ( thingId , name , cb ) => {
586+ onPropertyValue ( thingId , name , cb ) {
586587 if ( ! name ) {
587588 throw new Error ( 'Invalid property name' ) ;
588589 }
@@ -610,7 +611,7 @@ class clientMqtt{
610611 } ;
611612
612613
613- removePropertyValueCallback = ( thingId , name ) => {
614+ removePropertyValueCallback ( thingId , name ) {
614615 if ( ! name ) {
615616 throw new Error ( 'Invalid property name' ) ;
616617 }
0 commit comments