-
-
For sure, sorry for any confusion.
- I install "default apps" -> this already installs my app as clock app, then you get prompted to "reload" or set it in the apploader to automatically reload. No further install from the WebIDE.
- Connect with the WebIDE - "Download from RAM" shows this duplicated code.
- Prints in the WebIDEs console are also duplicated, so is behaviour of the app, e.g. buzzing executed twice (multiple times?)
I will try what @Ganblejs suggested now and report back.
edit: this showed no different behaviour.Edit: the duplication is only present for
setInterval() setTimeout() Bangle.on() NRF.on()
2x my code, 1x code from the widget?
var bleServiceOptions = { "uart": true }; NRF.on("connect", function () {WIDGETS["bluetooth"].draw();}); NRF.on("connect", function () {connected=true;uiLog("connected");}); NRF.on("connect", function () {connected=true;uiLog("connected");}); NRF.on("disconnect", function () {WIDGETS["bluetooth"].draw();}); NRF.on("disconnect", function () {connected=false;uiLog("disconnected");NRF.eraseBonds(onBondErased);}); NRF.on("disconnect", function () {connected=false;uiLog("disconnected");NRF.eraseBonds(onBondErased);}); NRF.on("bond", function (status) {uiLog("bond: "+status);if(status=="success"){connected=true;}else{connected=false;}}); NRF.on("bond", function (status) {uiLog("bond: "+status);if(status=="success"){connected=true;}else{connected=false;}}); NRF.on("advertising", function (isAdvertising) {uiLog("advertising: "+isAdvertising);}); NRF.on("advertising", function (isAdvertising) {uiLog("advertising: "+isAdvertising);});
- I install "default apps" -> this already installs my app as clock app, then you get prompted to "reload" or set it in the apploader to automatically reload. No further install from the WebIDE.
-
- Uploading to ram
- 'Download from RAM' in the webide, there you can see the duplication.
- It happens when i do the install default apps for example. Then after completion it requires a reload. At that point the Problem exists.
- I did not see 3x or more yet. But i will test this in 1-2 hours.
- Will check the setui possibility and report back.
Thanks for the Quick response so far!
- Uploading to ram
-
ill post the relevant sections (i guess). This is basically toplevel, everything else is just functions.
Bangle.loadWidgets(); Bangle.drawWidgets(); Bangle.setOptions({ lockTimeout: 0, backlightTimeout: 10000, btnLoadTimeout: 0, hrmSportMode: -1 }); NRF.setTxPower(8); var bootTimer = 0; setInterval(function() { if (BTN.read()) bootTimer++; else bootTimer=0; if (bootTimer<10) E.kickWatchdog(); }, 2000); Graphics.prototype.setFontAnton = function(scale) { // Actual height 69 (68 - 0) . . . . setDrawClock(); onInit(); // set up our new services initGraphics();
function onInit() { NRF.on('connect', function () { connected = true; uiLog("connected"); }); NRF.on('disconnect', function () { connected = false; uiLog("disconnected"); NRF.eraseBonds(onBondErased); }); NRF.on('bond', function(status) { uiLog("bond: " + status); if(status == "success"){ connected = true; } else { connected = false; } }); NRF.on('advertising', function(isAdvertising) { uiLog("advertising: " + isAdvertising); }); NRF.setServices({...}); uiLog("Waiting..","Bluetooth Connection"); setInterval(stepCount, 30000); setInterval(batteryPercentage, 5000); Bangle.on('accel', onAccel); Bangle.on('HRM-raw', onHRM); Bangle.setHRMPower(1, "app"); }
-
Hey guys,
long time lurker, first time poster here.
So i'm having trouble understanding / fixing this.
I created my own app.js, got everything to work that this is my default app.
The app works fine when i launch it from the WebIDE, however, when installing it from the apploader and then "reloading", i suddenly have code duplicated in ram, therefore functions being called twice.
So e.g.
in ram it is like this:
Bangle.on("accel", onAccel);
Bangle.on("accel", onAccel);when launching from the WebIDE, this duplication is not present.
What am i missing? How do i get a "clean" launch after installing?Thanks in advance.
edit: when installing from the webide after the installation from the apploader the console prints:
Uncaught Storage Updated!might be related?
update, i found a way around it, probably exposing a bug?
i did the follwing to avoid duplicate appstart basically.
and
The "bug" that listeners are added twice is still there, but this avoids it.