-
• #2
Hi, I just tried your code and it showed up once in the phone when connected to gadgetbridge like you said. However, when checking the log it does show multiple presses. So it does seem to be receiving them from the bangle, just not showing them in Android every time.
I believe you only need the Android app for getting notifications, music control, find my phone, alarm syncing, battery status syncing, or forwarding your phones gps to the bangle. For Bluetooth print line you shouldn't need it, but I could be wrong.
-
• #3
However, when checking the log it does show multiple presses. So it does seem to be receiving them from the bangle, just not showing them in Android every time.
Thanks for confirming. This is sort of what I suspected. Like maybe android is debouncing them somehow to avoid spamming the end user or something.
For Bluetooth print line you shouldn't need it, but I could be wrong.
Yeah that's what I thought but it doesn't seem to work at all if I uninstall the android integration app from the Bangle. Admittedly I am in a little over my head with this right now, but will probably understand it better after learning a bit more about how everything works.
I agree that simple transmission seems to work without the app on the Bangle side, but gadget bridge doesn't seem to acknowledge them (even once, like when the app is installed). I'm guessing there's something in the integration app that might facilitate that.
-
• #4
Oh, I forgot to mention it also handles the navigation messages from Google maps, which after Gordon's latest fixes works fantastic and is a killer feature to have when traveling around.
And I suppose it's possible the android app is required to establish more than just a simple Bluetooth connection with gadgetbridge.
-
• #5
So actually I may have solved my problem entirely, but I'd be happy to hear from people as to why I solved it, because I think I Maxwell Smart'ed / Mr. Magoo'ed my way through it.
The code I am running now
Bangle.setUI({mode: "custom", btn: () => { Bluetooth.println(""); Bluetooth.println(JSON.stringify({t:"info",msg:"Hello World"+getTime()})) console.log("HELLO"); }}) function GB(argumentados) { g.clear(); g.drawString(JSON.stringify(argumentados),0,0,true) }
with the android integration uninstalled works PERFECTLY. I noticed that in the android integration there was a random looking
Bluetooth.println("")
hanging out above thesend stuff to gadgetbridge
code so I added that to mine, and that made it work. TAH DAH.I get the info popup every time on the phone. I get the simulated notifications from GadgetBridge drawn on the screen. It's magnificently simple. I'm very happy.
Edit: okay it's not EVERY time I press the button that I see the toast message, but it's like 80%. Which is good enough.
-
• #6
Glad you got it sorted! Right, I think I know what the problem was then. Gadgetbridge is looking for lines of data sent to it of the form
{....}
.However by default Bangle.js/Espruino has a REPL on the same Bluetooth UART, so it's got a
>
prompt displayed at the start of the line.Normally when you do
Bluetooth.println
you bypass all that, but because you callconsole.log("HELLO");
that outputsHELLO
plus>
on the new line, so next time you send you're sending>{...}
which Gadgetbridge ignores.Sending a newline before like you're doing solves it :)
Did I actually need the full android integration app with all the message and message icon dependencies to send info messages to the phone?
No, but Gadgetbridge sends messages of the form
GB({...})
and it complains if there's an error. So it's worth definingfunction GB() {}
to at least stop that error.I'd still recommend the Android Integration stuff though as it does do quite a lot for you, including handling HTTP requests.
Hey folks! Have been fiddling with the integration aspect of my BangleJS and have been struggling a little bit to figure out what's what. I have been following this:
https://www.espruino.com/Gadgetbridge
I installed the bangle version of gadgetbridge on my phone, then installed the android integration on my BangleJS (not 100% sure if this was required for transmit only, but I did it anyway).
Then I loaded this code into ram in the web IDE:
disconnected from the web IDE, then connected to GadgetBridge. I then hit the side button on my watch, and saw the little info toast pop up on my phone. Wohoo! Then I hit the button again... Nothing! Strange.
I hit the button a few more times over the course of about 10 minutes and it seemed to work maybe once or twice more. I proceeded to disconnect from gadgetbridge then reconnect, hit the button again, and it works again - but only once.
Wonder if anyone with a little more familiarity with these things could weigh in.
My interest right now is just getting the most minimalistic possible setup and get a little bit of hello world data to reliably go both ways, even just to log it to the console.