• Hi & happy new year everyone,

    I am developing an app (a 15 puzzle). I made the first release on my personal copy of the app loader at

    https://dirkhillbrecht.github.io/BangleA­pps/#

    If you try to upload the "Garbled 15 puzzle" into a real Bangle 2 (newest v2.11 firmware), you get the error

    Upload failed, Unexpected response Uncaught SyntaxError: Got var expected EOF

    Uploading into the emulator through the app loader works. If you take the source code from

    https://github.com/dirkhillbrecht/Bangle­Apps/blob/dh/apps/p15prob/puzzle15.app.j­s

    and upload it into a Bangle 2 via the Web IDE, it works, too - as long as you disable the variable name shortening in the minification settings.

    I know that the source code is quite complex defining classes and having lots of source code comments, but that shouldn't be a problem, should it?

    Can anyone explain what's going on here? If you want me to investigate further, please let me know where to start. I do not feel settled enough with the whole Espruino ecosystem to start narrowing down the problem source on my own.

    Best regards,
    Dirk

  • [not tested]

    oldfirst = this.first;
    

    ->
    let oldfirst = this.first;

  • Thanks for finding this syntax flaw. Unfortunately, it's not the problem, I've updated the source code accordingly but the problems persists.

  • This looks like a problem with your apps.json entry.
    I cant see any entries for this puzzle.

    For everything to work properly

    1) code should be in Bangle/apps/myapp/app.js
    2) In apps.json the id should be myapp and match the subdirectory name

    ,
      {
        "id": "myapp",   // this MUST match your Bangle/apps/myapp directory
        "name": "Can be any old name",
        "shortName": "keep its short as it appears in menus, this is too long",
        "version": "0.01",
        // etc
    }
    

    When I go to your App loader and click on the link to the source code , I get a 404. This is due to some mismatch between the app id, the apps.json entry and the sub-directory where you checked in the code.

  • Code looks good as far as I can tell.

    I would not recommend

    // Drop mode as this is a game
    Bangle.setUI(undefined);
    

    This will mean there is no way to exit the app, and you are forced to do a long BTN1 reset to get out of the app.

    Instead use:

    Bangle.setUI("clock");  // means BTN1 short press can exit the app and go to the launcher
    
  • Your "Garbled 15 puzzle (v0.02)" is working on my "real" Bangle.js 2 :

    This confirms the statement from HughB that the code is correct but the environment needs to be fixed.

  • Hi,

    thank you all for your replies. I'm still in the process of nailing it down...

    First, @HughB, the source code link does indeed not work. It silently assumes that the app loader is built from the "master" branch - while I use master to follow the official repo and use a branch "dh" for my own app loader. I think, this is even suggested in the docs. If you manually exchange "tree/master/apps" with "tree/dh/apps", the source code is shown as expected.

    As you all say the problem is not the code but the packaging, I replaces my whole elaborated software with a very simple app:

    // Minimum test program
    
    E.showMessage("Hallo");
    
    // end of file
    

    …and indeed the behaviour is exactly the same: Works in emulator, works on manual upload, "var/EOF" error on upload from the loader. So, it seems very much that you are right and the probem is in the packaging. I'm still searching, however, what exactly is wrong and which stupid mistake I made…

    Best regards,
    Dirk

  • Hi,

    I finally got it: I garbled the JS for the app icon! I misunderstood the docs for creating app-icon.js on https://github.com/espruino/BangleApps . I did not enable compression and I copied the result of the converter verbatim into app-icon.js. Either that var img = at the beginning or E.toArrayBuffer generated due to the missing compression broke the app loader's neck.

    With the correct icon file deployment works now. I removed the "Garbled 15 puzzle" "app" from my loader and released a new version 0.02 of the "real" app with working deployment. It is also already actually playable, even though there are still some problems with the menu system. I'm on it.

    Thanks again for pointing me into the right direction. Your help was greatly appreciated!

    Best regards,
    Dirk

  • I tried the app out. Its looking nice.
    I thought of doing one of these myself as its the perfect thing for a touch screen.
    The 2048 puzzle would also be great.

    In terms of your problem, I noticed that:

    https://github.com/dirkhillbrecht/Bangle­Apps/tree/dh/apps/puzzle15
    Exists

    https://github.com/dirkhillbrecht/Bangle­Apps/tree/dh/apps/p15prob
    Does not exist

    You may have setup the apps.json file for p15prob but not committed the code to the branch so that the directory for p15prob exists.

    But then again I noticed that your apps.json file had dropped the garbled entry from when I last looked at it - so for me it maybe a case of shifting sands looking at this while its work in progress.

  • You are right, id and directory name must match. Also, in the storage section, the name entries for the app's files must match the myapp.(app|settings|…).(js|…) pattern. But the local names of the files, which are referenced in the url property of the storage entries, can be arbitrary. In the official app loader, <appname>.app.js and app.js are both used. After testing around, I decided to stick with the long version even within the app loader.

    The 404 is also gone, I've changed the branch name template in loader.js to match the setup of my app loader.

  • I decided to stick with the long version even within the app loader.

    I tend to use the long names rather than app.js icon.js etc.
    It helps when you just want to work on one file continuusly and just upload it through the IDE.
    If you set the IDE open dialogue to watch the IDE will reload your file into the right hand side
    You can then setup the RAM button to upload to myapp.app.js.
    This makes hacking / debugging really quick.

  • Hello @HughB,

    thanks for the feedback. Yes, after I found the real reason for the deployment problem, I removed the "garbled" version of Puzzle15. The "real" version in my app loader is under heavy development. I just released v0.03 which is the first one with a working menu system and everything more or less ready. I want to add some settings and then think about a merge request into the official app loader. But you might want to give it a try.

    Regards,
    Dirk

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

App loader upload problem with Bangle 2: Got var expected EOF

Posted by Avatar for dirkhillbrecht @dirkhillbrecht

Actions