abandonware / bleno

A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals
https://mastodon.social/@rzr/106068437787315146#bleno
MIT License
149 stars 52 forks source link

Fix insufficient permission/capability check. #14

Closed ptx2 closed 4 years ago

ptx2 commented 4 years ago

Check the error code instead of the error message as the message is not guaranteed to be stable.

ptx2 commented 4 years ago

Same issue and fix as this one on noble: https://github.com/abandonware/noble/pull/111

ptx2 commented 4 years ago

Note there is another similar check on the next line:

https://github.com/abandonware/bleno/pull/14/files#diff-cd3778d99958c91fd4b08c0b91c0dd7aL627

  } else if (error.message === 'Network is down') {
    // no-op
  }

That looks like it should change to error.code === 'ENETDOWN'. Although it doesn't actually do anything so perhaps it could just be removed?