Skip to content

Commit

Permalink
fix: For ticket #111. Oddly node.js is not passing unused arguments i…
Browse files Browse the repository at this point in the history
…n the correct order

This is a quick fix. Check that the qCallback is actually a function.
  • Loading branch information
ztalbot2000 committed Jul 25, 2021
1 parent 28d1e20 commit 1b50675
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Cmd4Accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class Cmd4Accessory
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 );
if ( typeof qCallback == "function" ) qCallback( code );

return;
}
Expand All @@ -901,7 +901,7 @@ class Cmd4Accessory

// We can call our callback though ;-)
callback( constants.ERROR_NO_DATA_REPLY );
if ( qCallback ) qCallback( constants.ERROR_NO_DATA_REPLY );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_NO_DATA_REPLY );

return;
}
Expand All @@ -912,7 +912,7 @@ class Cmd4Accessory

// We can call our callback though ;-)
callback( constants.ERROR_NULL_REPLY );
if ( qCallback ) qCallback( constants.ERROR_NULL_REPLY );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_NULL_REPLY );

return;
}
Expand All @@ -931,7 +931,7 @@ class Cmd4Accessory
{
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 );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_NULL_STRING_REPLY );

return;
}
Expand All @@ -947,7 +947,7 @@ class Cmd4Accessory
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 );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_EMPTY_STRING_REPLY );

return;
}
Expand All @@ -960,7 +960,7 @@ class Cmd4Accessory
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 );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_2ND_NULL_STRING_REPLY );

return;
}
Expand All @@ -985,16 +985,15 @@ class Cmd4Accessory
self.log.warn( `${ self.displayName } ` + chalk.red( `Cannot convert value: ${ unQuotedReply } to ${ CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].props.format } for ${ characteristicString }` ) );

callback( constants.ERROR_NON_CONVERTABLE_REPLY );
if ( qCallback ) qCallback( constants.ERROR_NON_CONVERTABLE_REPLY );
if ( typeof qCallback == "function" ) qCallback( constants.ERROR_NON_CONVERTABLE_REPLY );

return;
}

// Success !!!!
callback( 0, properValue );


if ( qCallback ) qCallback( 0, properValue );
if ( typeof qCallback == "function" ) qCallback( 0, properValue );

// Store history using fakegato if set up
self.updateAccessoryAttribute( accTypeEnumIndex, properValue );
Expand Down

0 comments on commit 1b50675

Please sign in to comment.