@@ -346,7 +346,7 @@ export class CoreHandler {
346346
347347 const devices : any [ ] = [ ]
348348 if ( this . _tsrHandler ) {
349- for ( const device of this . _tsrHandler . tsr . getDevices ( ) ) {
349+ for ( const device of this . _tsrHandler . tsr . connectionManager . getConnections ( ) ) {
350350 devices . push ( {
351351 instanceId : device . instanceId ,
352352 deviceId : device . deviceId ,
@@ -416,24 +416,17 @@ export class CoreTSRDeviceHandler {
416416 public _deviceId : string
417417 public _device ! : BaseRemoteDeviceIntegration < DeviceOptionsAny >
418418 private _coreParentHandler : CoreHandler
419- private _tsrHandler : TSRHandler
420419 private _hasGottenStatusChange = false
421420 private _deviceStatus : PeripheralDeviceAPI . PeripheralDeviceStatusObject = {
422421 statusCode : StatusCode . BAD ,
423422 messages : [ 'Starting up...' ] ,
424423 }
425424 private disposed = false
426425
427- constructor (
428- parent : CoreHandler ,
429- device : Promise < BaseRemoteDeviceIntegration < DeviceOptionsAny > > ,
430- deviceId : string ,
431- tsrHandler : TSRHandler
432- ) {
426+ constructor ( parent : CoreHandler , device : Promise < BaseRemoteDeviceIntegration < DeviceOptionsAny > > , deviceId : string ) {
433427 this . _coreParentHandler = parent
434428 this . _devicePr = device
435429 this . _deviceId = deviceId
436- this . _tsrHandler = tsrHandler
437430 }
438431 async init ( ) : Promise < void > {
439432 this . _device = await this . _devicePr
@@ -455,10 +448,11 @@ export class CoreTSRDeviceHandler {
455448 )
456449 } )
457450
451+ console . log ( 'has got status? ' + this . _hasGottenStatusChange )
458452 if ( ! this . _hasGottenStatusChange ) {
459453 this . _deviceStatus = await this . _device . device . getStatus ( )
460- this . sendStatus ( )
461454 }
455+ this . sendStatus ( )
462456 if ( this . disposed ) throw new Error ( 'CoreTSRDeviceHandler cant init, is disposed' )
463457 await this . setupSubscriptionsAndObservers ( )
464458 if ( this . disposed ) throw new Error ( 'CoreTSRDeviceHandler cant init, is disposed' )
@@ -490,8 +484,9 @@ export class CoreTSRDeviceHandler {
490484 // setup observers
491485 this . _coreParentHandler . setupObserverForPeripheralDeviceCommands ( this )
492486 }
493- statusChanged ( deviceStatus : Partial < PeripheralDeviceAPI . PeripheralDeviceStatusObject > ) : void {
494- this . _hasGottenStatusChange = true
487+ statusChanged ( deviceStatus : Partial < PeripheralDeviceAPI . PeripheralDeviceStatusObject > , fromDevice = true ) : void {
488+ console . log ( 'device ' + this . _deviceId + ' status set to ' + deviceStatus . statusCode )
489+ if ( fromDevice ) this . _hasGottenStatusChange = true
495490
496491 this . _deviceStatus = {
497492 ...this . _deviceStatus ,
@@ -545,7 +540,8 @@ export class CoreTSRDeviceHandler {
545540 async dispose ( subdevice : 'keepSubDevice' | 'removeSubDevice' = 'keepSubDevice' ) : Promise < void > {
546541 this . _observers . forEach ( ( obs ) => obs . stop ( ) )
547542
548- await this . _tsrHandler . tsr . removeDevice ( this . _deviceId )
543+ if ( ! this . core ) return
544+
549545 await this . core . setStatus ( {
550546 statusCode : StatusCode . BAD ,
551547 messages : [ 'Uninitialized' ] ,
0 commit comments