Skip to content

Commit

Permalink
feat: For Queue (AirCon) ignore low priority polling failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ztalbot2000 committed Jul 24, 2021
1 parent a45bef0 commit f431e41
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Cmd4Accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,15 @@ class Cmd4Accessory
// the CMD4_ACC_TYPE_ENUM.
//
// ***********************************************
getValue( accTypeEnumIndex, characteristicString, timeout, callback, qCallback = null )
getValue( accTypeEnumIndex, characteristicString, timeout, callback, isLowPriority = false, qCallback = null )
{
let self = this;

// Ignore lowPriority queue messages that could be caused by the device being busy.
let nDbg = true;
if ( cmd4Dbg && isLowPriority )
nDbg = false;

let cmd = this.state_cmd_prefix + this.state_cmd + " Get '" + this.displayName + "' '" + characteristicString + "'" + this.state_cmd_suffix;

if ( cmd4Dbg ) self.log.debug( `getValue: accTypeEnumIndex:( ${ accTypeEnumIndex } )-"${ characteristicString }" function for: ${ self.displayName } cmd: ${ cmd }` );
Expand Down Expand Up @@ -882,7 +887,7 @@ class Cmd4Accessory

return;
}
self.log.error( chalk.red( `getValue ${ characteristicString } function failed for ${ self.displayName } cmd: ${ cmd } Failed. Error: ${ code }. ${ constants.DBUSY }` ) );
if ( nDbg ) self.log.error( chalk.red( `getValue ${ characteristicString } function failed for ${ self.displayName } cmd: ${ cmd } Failed. Error: ${ code }. ${ constants.DBUSY }` ) );

callback( code );
if ( qCallback ) qCallback( code );
Expand All @@ -892,7 +897,7 @@ class Cmd4Accessory

if ( reply == "NxN" )
{
self.log.error( `getValue: nothing returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );
if ( nDbg ) self.log.error( `getValue: nothing returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );

// We can call our callback though ;-)
callback( constants.ERROR_NO_DATA_REPLY );
Expand All @@ -903,7 +908,7 @@ class Cmd4Accessory

if ( reply == null )
{
self.log.error( `getValue: null returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );
if ( nDbg ) self.log.error( `getValue: null returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );

// We can call our callback though ;-)
callback( constants.ERROR_NULL_REPLY );
Expand All @@ -924,7 +929,7 @@ class Cmd4Accessory
// to catch this before much string manipulation was done.
if ( trimmedReply.toUpperCase( ) == "NULL" )
{
self.log.error( `getValue: "${ trimmedReply }" returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );
if ( nDbg ) self.log.error( `getValue: "${ trimmedReply }" returned from stdout for ${ characteristicString } ${ self.displayName }. ${ constants.DBUSY }` );
callback( constants.ERROR_NULL_STRING_REPLY );
if ( qCallback ) qCallback( constants.ERROR_NULL_STRING_REPLY );

Expand All @@ -939,7 +944,7 @@ class Cmd4Accessory

if ( unQuotedReply == "" )
{
self.log.error( `getValue: ${ characteristicString } function for: ${ self.displayName } returned an empty string "${ trimmedReply }". ${ constants.DBUSY }` );
if ( nDbg ) self.log.error( `getValue: ${ characteristicString } function for: ${ self.displayName } returned an empty string "${ trimmedReply }". ${ constants.DBUSY }` );

callback( constants.ERROR_EMPTY_STRING_REPLY );
if ( qCallback ) qCallback( constants.ERROR_EMPTY_STRING_REPLY );
Expand All @@ -952,7 +957,7 @@ class Cmd4Accessory
// things I must do for bad data ....
if ( unQuotedReply.toUpperCase( ) == "NULL" )
{
self.log.error( `getValue: ${ characteristicString } function for ${ self.displayName } returned the string "${ trimmedReply }". ${ constants.DBUSY }` );
if ( nDbg ) self.log.error( `getValue: ${ characteristicString } function for ${ self.displayName } returned the string "${ trimmedReply }". ${ constants.DBUSY }` );

callback( constants.ERROR_2ND_NULL_STRING_REPLY );
if ( qCallback ) qCallback( constants.ERROR_2ND_NULL_STRING_REPLY );
Expand Down

0 comments on commit f431e41

Please sign in to comment.