Debug Bluetooth communication? #2137
Replies: 6 comments
-
Posted at 2017-04-19 by @gfwilliams Puck.js can have both an incoming and an outgoing bluetooth connection, so in the example you're trying you should be fine - you can be connected with your PC while also running the code above and seeing the response. But yes, even if you're connected to something else at the same time you have other ways to debug. Serial connectionYou can attach a USB-TTL serial converter to Puck.js: http://www.espruino.com/Puck.js#serial-console That way you can get the command-prompt even when you are connected to something else via bluetooth. Only thing to watch out for is to type If you're doing serious development then I'd recommend just leaving a Puck wired up like that. LoopbackYou can also force the console onto 'Loopback' which means that anything printed to Not tested, but something like the following should work:
Basically you'd connect with the other device, then press the button and from then on, stuff gets logged in 'log'. Next time you connect with your PC (without pressing the button) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-19 by MobiTech This works. I tried to connect the Smartphone with the Puck instead of the connecting Puck with the smartphone. FindDevices also returns an empty array:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-20 by @gfwilliams By default, mobile phones can't be connected to by other Bluetooth LE devices - that's almost certainly your problem. You'll need to make an app for the phone that enables it, and even then it won't work on all phones. The best way to test would be to try anf connect with the nRF Connect app first, and when that works, try with Puck.js |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-21 by MobiTech Thank you for your help. I have tried to connect the smartphone with the Puck. The Puck sets a service and updates it on a click. The NRF Connect app shows the data. Everything works fine. Now I would like to send data from the smartphone (central), which is connected, to the puck (peripheral). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-21 by @gfwilliams Take a look at the examples on http://www.espruino.com/Reference#l_NRF_setServices When specifying a service, you can add an |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-04-21 by MobiTech Thank you so much. I have looked in the API for an own function instead of a handler. I will try it later. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-04-19 by MobiTech
Hello, I try to debug my source code for creating a bluetooth communication. The sourcecode looks like this:
I know that the example above is not valid.
My general question: How can I debug a bluetooth communication? The problem:
I connect the Puck with Windows to transmit the program to the puck. For establishing a connection from another device (e.g. Android Smartphone), I have to disconnect the Puck from Windows to be able to connect the Android Smartphone with the Puck. If I am disconnected, I will not see the console output on my computer. So how can I see the console result after disconnecting the puck? Could it be stored on the device?
Beta Was this translation helpful? Give feedback.
All reactions