@@ -3,7 +3,7 @@ import { DeferredMessage, PromiseBasedQueue } from './promise-queue';
33import { generateUUID } from './utils' ;
44import dgram , { RemoteInfo } from 'dgram' ;
55import { AddressInfo } from 'net' ;
6- import { ConsoleLike , DeviceData , HomeIndex } from './types' ;
6+ import { ConsoleLike , DeviceData , HomeIndex } from './types' ;
77import Timeout = NodeJS . Timeout ;
88
99export const ROOT_ID = 'GEN#17#13#1' ;
@@ -145,16 +145,16 @@ function bytesToHex(byteArray: Buffer): String {
145145const DEFAULT_TIMEOUT = 5000 ;
146146
147147export interface ClientConfig {
148- host : string ,
149- port ?: number ,
150- username ?: string ,
151- password ?: string ,
148+ host : string ;
149+ port ?: number ;
150+ username ?: string ;
151+ password ?: string ;
152152}
153153
154154export interface HUBClientConfig extends ClientConfig {
155- hub_username ?: string ,
156- hub_password ?: string ,
157- clientId ?: string
155+ hub_username ?: string ;
156+ hub_password ?: string ;
157+ clientId ?: string ;
158158}
159159
160160export class ComelitClient extends PromiseBasedQueue < MqttMessage , MqttIncomingMessage > {
@@ -165,13 +165,14 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
165165 private txTopic : string ;
166166 private rxTopic : string ;
167167 private clientId : string ;
168- private readonly onUpdate : ( objId : string , data : Readonly < DeviceData > , oldData ?: Readonly < DeviceData > ) => void ;
168+ private readonly onUpdate : (
169+ objId : string ,
170+ data : Readonly < DeviceData > ,
171+ oldData ?: Readonly < DeviceData >
172+ ) => void ;
169173 private readonly logger : ConsoleLike ;
170174
171- constructor (
172- onUpdate ?: ( objId : string , device : DeviceData ) => void ,
173- log ?: ConsoleLike
174- ) {
175+ constructor ( onUpdate ?: ( objId : string , device : DeviceData ) => void , log ?: ConsoleLike ) {
175176 super ( ) ;
176177 this . props = {
177178 client : null ,
@@ -187,7 +188,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
187188 ) : boolean {
188189 const deferredMqttMessage = response . seq_id
189190 ? messages . find (
190- message =>
191+ ( message ) =>
191192 message . message . seq_id == response . seq_id &&
192193 message . message . req_type == response . req_type
193194 )
@@ -219,7 +220,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
219220 }
220221
221222 scan ( ) : Promise < void > {
222- return new Promise ( resolve => {
223+ return new Promise ( ( resolve ) => {
223224 const server = dgram . createSocket ( 'udp4' ) ;
224225 let timeout : Timeout ;
225226 function sendScan ( ) {
@@ -246,7 +247,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
246247 this . logger . info ( `server listening ${ address . address } :${ address . port } ` ) ;
247248 } ) ;
248249
249- server . on ( 'error' , err => {
250+ server . on ( 'error' , ( err ) => {
250251 this . logger . info ( `server error:\n${ err . stack } ` ) ;
251252 clearInterval ( timeout ) ;
252253 server . close ( ) ;
@@ -416,7 +417,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
416417 obj_id : id ,
417418 } ;
418419 const response = await this . publish ( packet ) ;
419- return ComelitClient . evalResponse ( response ) . then ( value => value ) ;
420+ return ComelitClient . evalResponse ( response ) . then ( ( value ) => value ) ;
420421 }
421422
422423 async ping ( ) : Promise < boolean > {
@@ -427,7 +428,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
427428 sessiontoken : this . props . sessiontoken ,
428429 } ;
429430 const response = await this . publish ( packet ) ;
430- return ComelitClient . evalResponse ( response ) . then ( value => value ) ;
431+ return ComelitClient . evalResponse ( response ) . then ( ( value ) => value ) ;
431432 }
432433
433434 async device ( objId : string = ROOT_ID , detailLevel ?: number ) : Promise < DeviceData > {
@@ -505,7 +506,7 @@ export class ComelitClient extends PromiseBasedQueue<MqttMessage, MqttIncomingMe
505506 act_params : [ value ] ,
506507 } ;
507508 const response = await this . publish ( packet ) ;
508- return ComelitClient . evalResponse ( response ) . then ( value => value ) ;
509+ return ComelitClient . evalResponse ( response ) . then ( ( value ) => value ) ;
509510 }
510511
511512 private static evalResponse ( response : MqttIncomingMessage ) : Promise < boolean > {
0 commit comments