Avatar for sfnk

sfnk

Member since Apr 2024 • Last active May 2024
  • 1 conversations
  • 6 comments

Most recent activity

  • in Bangle.js
    Avatar for sfnk

    update, i found a way around it, probably exposing a bug?

    i did the follwing to avoid duplicate appstart basically.

    E.on('init', startApp);
    startApp();
    

    and

    function startApp(){
        if(appStarted){
          return;
        }
    

    The "bug" that listeners are added twice is still there, but this avoids it.

  • in Bangle.js
    Avatar for sfnk

    no, cannot imagine it being literally duplicated. Also not finding any evidence for it.

    this is the generated print:

    bootupdate.js contains connect
    00emerno.app.js contains connect
    widbt.wid.js contains connect
    
  • in Bangle.js
    Avatar for sfnk

    For sure, sorry for any confusion.

    1. 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.
    2. Connect with the WebIDE - "Download from RAM" shows this duplicated code.
    3. 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");N­RF.eraseBonds(onBondErased);});
    NRF.on("disconnect", function () {connected=false;uiLog("disconnected");N­RF.eraseBonds(onBondErased);});
    NRF.on("bond", function (status) {uiLog("bond: "+status);if(status=="success"){connecte­d=true;}else{connected=false;}});
    NRF.on("bond", function (status) {uiLog("bond: "+status);if(status=="success"){connecte­d=true;}else{connected=false;}});
    NRF.on("advertising", function (isAdvertising) {uiLog("advertising: "+isAdvertising);});
    NRF.on("advertising", function (isAdvertising) {uiLog("advertising: "+isAdvertising);});
    
  • in Bangle.js
    Avatar for sfnk
    1. Uploading to ram
    2. 'Download from RAM' in the webide, there you can see the duplication.
    3. It happens when i do the install default apps for example. Then after completion it requires a reload. At that point the Problem exists.
    4. I did not see 3x or more yet. But i will test this in 1-2 hours.
    5. Will check the setui possibility and report back.

    Thanks for the Quick response so far!

  • in Bangle.js
    Avatar for sfnk

    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");
    }
    
  • in Bangle.js
    Avatar for sfnk

    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?

Actions