-
• #2
It sounds to me like customizing the app in the app loader before installing is what you want: https://www.espruino.com/Bangle.js+Custom
You could also add a textinput dependency and let users use one of the existing watch keyboards: https://banglejs.com/apps/?c=textinput
-
• #3
I think you want to add a
custom.html
: that can open a dialog when uploading the app, ask for those settings, and send them to the watch.Looks like hasensors does pretty much the thing you want: asks for a bunch of values, then replaces
{placeholders}
in the code. (Except you probably don't needboot.js
, and want to adjust yourapp.js
instead of using a separatelib.js
file) -
• #4
thanks for the suggestions! Will have a look through each and figure out which to use, so I can finish this off :)
-
• #5
Or you can use Storage to store a config "file" on the device, that has the required credentials. That way you wouldn't have to put the credentials in code. Not even during development. Just read from flash. As long as the config is the same.
You would have to create a file on the device during development. And I think the custom loader could write that file as well when installing. -
• #6
As other have said really, but just to be clear:
- https://www.espruino.com/Bangle.js+Custom is when you want to customise some part of the app before upload. To update the app it needs re-running, so it's worth using 'local storage' on the web browser to keep track of what was entered
- https://www.espruino.com/Bangle.js+Storage is when you want to be able to read/write from a data file after the app has been uploaded - so you could use that to set the credentials in a JSON file by from the web browser.
- https://www.espruino.com/Bangle.js+Custom is when you want to customise some part of the app before upload. To update the app it needs re-running, so it's worth using 'local storage' on the web browser to keep track of what was entered
I'm nearly finished with an app I've been working on, that allows my bangle JS to work as a TV remote control. I was thinking of learning how to create a mobile app (so the https requests from the watch can go directly to the TV via the app) however for now, I have a node webserver on an rpi and send the https request to that - which then sends commands to the TV.
In order to do this the bangle JS currently has my webservers IP and my login/password for the https server, included as variables inside the code. I obviously can't publish it with my variables but I'm unsure what the best approach here is, if we want to 'generalise' the code, so anyone can then assign their own variables.
I was thinking to comment in the project that you need to write a file to your watch that the code could then reference but wasn't sure if that's the easiest thing to do, to make things generalised for users.
Can someone confirm what the best/easiest approach would be for users to be able to assign their values? Alternatively I could draw some terrible keyboard screen so people can spend 10 minutes typing things in on the watch, but something tells me people won't appreciate that :)