espruino / winnus

Windows 8.1 and above BLE NUS support for Node.js
3 stars 5 forks source link

possible problems with sending "Hello"'s without \r causing unresponsive puck.js #2

Closed OwenBrotherwood closed 7 years ago

OwenBrotherwood commented 7 years ago

using hellowsinnus.js but WITHOUT the \r for Hello and sending over 10 times, the puck.js does advertises but does not respond to a connect.

{\"VERSION\":\"1v91.60\",\"BUILD_DATE\":\"Feb 9 2017\",\"BUILD_TIME\":\"16:51:25\",\"GIT_COMMIT\":\"f7d49465787e574d56f7aec98949002ed099c9d2\",\"BOARD\":\"PUCKJS\",\"CHIP\":\"NRF52832\",\"CHIP_FAMILY\":\"NRF52\",\"FLASH\":524288,\"RAM\":65536,\"SERIAL\":\"aabca59d-3fd340e6\",\"CONSOLE\":\"Bluetooth\"}

Example, about 7 times after another produced the following and a puck.js that did not respond to connect and the running program, RGB led blink on button, did not respond

(POWER ON puck.js)
C:\source\repos\github\OwenBrotherwood\winnus\examples\hellowinnusnode>node hellowinnus.js
[ { name: 'Puck.js 431b',
    address: 'df:f5:a5:ec:43:1b',
    path: '\\\\?\\bthledevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_dff5a5ec431b#8&17558516&0&000b#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}' } ]
{ name: 'Puck.js 431b',
  address: 'df:f5:a5:ec:43:1b',
  path: '\\\\?\\bthledevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_dff5a5ec431b#8&17558516&0&000b#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}' }
Connect
Got data "Hello"
(REPEATED sucess of above removed)
C:\source\repos\github\OwenBrotherwood\winnus\examples\hellowinnusnode>node hellowinnus.js
[ { name: 'Puck.js 431b',
    address: 'df:f5:a5:ec:43:1b',
    path: '\\\\?\\bthledevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_dff5a5ec431b#8&17558516&0&000b#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}' } ]
{ name: 'Puck.js 431b',
  address: 'df:f5:a5:ec:43:1b',
  path: '\\\\?\\bthledevice#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}_dff5a5ec431b#8&17558516&0&000b#{6e400001-b5a3-f393-e0a9-e50e24dcca9e}' }
Connect
Error: BluetoothGATTSetDescriptorValue
    at Error (native)
    at Object.exports.connect (C:\source\repos\github\OwenBrotherwood\winnus\examples\hellowinnusnode\node_modules\winnus\winnus.js:34:10)
    at Object.<anonymous> (C:\source\repos\github\OwenBrotherwood\winnus\examples\hellowinnusnode\hellowinnus.js:24:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)

Same result on release firmware

{\"VERSION\":\"1v91\",\"BUILD_DATE\":\"Jan 12 2017\",\"BUILD_TIME\":\"10:56:11\",\"GIT_COMMIT\":\"a6300790b771b7afffdb2bb2d8c5d0607f7977ef\",\"BOARD\":\"PUCKJS\",\"CHIP\":\"NRF52832\",\"CHIP_FAMILY\":\"NRF52\",\"FLASH\":524288,\"RAM\":65536,\"SERIAL\":\"aabca59d-3fd340e6\",\"CONSOLE\":\"Bluetooth\"}


Note: http://forum.espruino.com/conversations/300527/#13480709 was with the puck.js with insert old battery, and observe advertisement and immediate connection error with first attempt ie no repetition of sending "Hello".

gfwilliams commented 7 years ago

I guess it's possible that the output buffer got full in Puck.js. Basically all you're doing is entering one long line of code saying HelloHelloHello...

I don't see how this is a winnus problem though as I guess it would happen with any connection method?

OwenBrotherwood commented 7 years ago

yes: any connection method. The example, with no \r could conceivably put other devices connected to by winnus at risk (by showing a possible bug) so better to have in example with \r

I believe the buffer flow is an issue in Espruino code and I was going to create a issuethere when I was sure of the results that I have seen: I leave the creating of a issue to you if you feel there is an issue

Example changed in my PR to adding \r to avoid winnus causing problems for non Espruino if someone just tries it and crashes the device they are connecting to.

OwenBrotherwood commented 7 years ago

contained in docExample PR tracked by https://github.com/espruino/winnus/issues/3