@@ -538,14 +538,14 @@ module.exports = function (RED) {
538538 // }
539539 async write ( dataObj ) {
540540 if ( ! dataObj ) {
541- return ;
541+ throw new Error ( `Nothing to write` ) ;
542542 }
543543 const state = await this . connectPeripheral ( ) ;
544544 if ( state !== 'connected' ) {
545545 debugCfg (
546546 `[write] Peripheral:${ this . uuid } is NOT ready. state=>${ state } `
547547 ) ;
548- return ;
548+ throw new Error ( `Not yet connected.` ) ;
549549 }
550550 let writables = this . characteristics . filter (
551551 ( c ) => c . writable || c . writeWithoutResponse
@@ -603,7 +603,7 @@ module.exports = function (RED) {
603603 debugCfg (
604604 `[read] Peripheral:${ this . uuid } is NOT ready. state=>${ state } `
605605 ) ;
606- return null ;
606+ throw new Error ( `Not yet connected.` ) ;
607607 }
608608 uuids = uuids
609609 . split ( ',' )
@@ -671,7 +671,7 @@ module.exports = function (RED) {
671671 this . log (
672672 `[subscribe] Peripheral:${ this . uuid } is NOT ready. state=>${ state } `
673673 ) ;
674- return Promise . resolve ( ) ;
674+ throw new Error ( `Not yet connected.` ) ;
675675 }
676676 uuids = uuids
677677 . split ( ',' )
@@ -700,7 +700,7 @@ module.exports = function (RED) {
700700 ) ;
701701 debugCfg ( `notifiables.length => ${ notifiables . length } ` ) ;
702702 if ( notifiables . length === 0 ) {
703- return false ;
703+ return ;
704704 }
705705 await Promise . all (
706706 notifiables . map ( ( r ) => {
@@ -818,7 +818,7 @@ module.exports = function (RED) {
818818 debugOut ( `<${ this . genericBleNode . uuid } > read: OK` ) ;
819819 if ( ! readObj ) {
820820 this . warn (
821- `<${ this . genericBleNode . uuid } > read [${ msg . topic } ]: (no data)`
821+ `<${ this . genericBleNode . uuid } > tpoic [${ msg . topic } ]: (no data)`
822822 ) ;
823823 return ;
824824 }
@@ -835,7 +835,7 @@ module.exports = function (RED) {
835835 }
836836 } catch ( err ) {
837837 this . error (
838- `<${ this . genericBleNode . uuid } > read [${ msg . topic } ]: (err:${ err } , stack:${ err . stack } )`
838+ `<${ this . genericBleNode . uuid } > tpoic [${ msg . topic } ]: (err:${ err } , stack:${ err . stack } )`
839839 ) ;
840840 }
841841 } ) ;
0 commit comments