bangle.js 2 - simple BLE example #7873
-
|
Hello everyone, I am looking for a very simple BLE example. I want to program an app that sends random integer values via BLE. I have the LightBlue app on my smartphone to receive them. So I want to start LightBlue on my smartphone and then connect to the bangle app. Now I want to subscribe to a characteristic in LightBlue and see the respective random value from the bangle App. I've tried many things, but I always fail because the console.log output is included in the packet to be sent. I have no idea why. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Do you have the code you're using? If you are using the default Nordic uart characteristic then that's what the console is on by default so yes, console.log will appear on there. You could just not log though, and use Bluetooth.println to write directly, or swap the console to somewhere else with something like Terminal.setConsole() (the screen) But if you want a new characteristic that you have complete control of writing to, check out the example at https://www.espruino.com/Reference#l_NRF_updateServices - that should work fine |
Beta Was this translation helpful? Give feedback.
You might be better off just outputtiing on the same characteristic, but tagging your output line:
JSON.stringify({ type: "val1", v: val });JSON.stringify({ type: "val2", v: val });then it's easy enough to pull apart at the other end, and very extensible.
You actually want to use the code you had previously where UUIDs are explicitly defined, and just replace the UUIDs in it with your own (you can find 'random uuid generators' online) and replace chars 5..8 with 0001/0002/etc like is done already.