Banglerun with a custom mobile app

Posted on
  • Hi everyone,
    i'm trying to use Bangle.js in a university project.
    I state that I have never programmed in javascript before, but i have experience with python and C#.
    I'd like to modify the app Banglerun, in order to send measured data to a mobile app made by me, that uses them to produce charts and things like that.
    But it's very hard to do that due to the way it is implemented, it's in typescript and the file app.js is a single line code illegible and not editable. How can i do that?

    I tried to use vscode but i can't solve errors that occurs, so i have to use Espruino ide that doesn't support typescript.

  • Yes, sorry about that - the Banglerun app is literally the only app in the app store that's written in this way, and you're not the only one to find it difficult to modify.

    What did you actually want to do with your mobile app? Stream the data live, or retrieve recorded data?

    As I understand it the BangleRun app actually creates a log of each run anyway:­lob/master/apps/banglerun/src/log.ts#L25­

    So you could actually just connect to the Bangle and grab the data from each run even without having to modify the app.

    In fact if you were happy to write a webpage (progressive web app) to retrieve the data (rather than a native phone app) then you could use the interface.html from the GPS recorder app­ree/master/apps/gpsrec as a starting point - it has most of what's needed to list files, read data and dump it - so you just need to interpret the slightly different BangleRun data which has a few more columns.

    If it helps there's even code to graph stuff here:­/blob/master/apps/bletemplogger/interfac­e.html

  • What did you actually want to do with your mobile app? Stream the data live, or retrieve recorded data?

    I'd like to stream data to my app and create some live charts, like HR one and intensity excercise one, but also save them in order to see these charts after the run.
    I saw in the code that the app creates a log of each run, so for that task it's easy, but i need also to implement data streaming for the project (it is one of the task asked). Initially i wanted to write the app by myself, but reading the typescript code of banglerun it's well written, also in terms of measurements, with the kalman filters to noise reduction, so i decided to modify it in order to stream data, that is why i wanted to use vscode.
    Do you think it is possible to modify the file app.js by hands, making it readable? @Gordon.

    If it helps there's even code to graph stuff here:­/blob/master/apps/bletemplogger/interfac­e.html

    Thank you very much, it will be very usefull in future work.

  • Well, it might be possible to modify the file by hand, but if there's any way to avoid it I would!

    I just did:

    npm install rollup  rollup-plugin-typescript rollup-plugin-terser typescript
    rollup -c

    And it generated app.js, so I'd definitely try doing it that way if you can make it work

  • I'm trying to do that, but i don't understand how this can fix the way app.js appers. I've nevere used before rollup, i'm reading now the documentation, but running

    rollup -c

    gave me errors.
    Otherwise, running rollup app.js it seems like is rollup to generate app.js in that way.
    Maybe i misunderstood what you said, but i keep trying to fix this, if i solve, will publish the code of corrected file in this conversation.

    Thank's you @Gordon.

  • Ok i think i found a way to modify the app, it is a little bit twisted but it should work. I'm going to explain how for future people that will might have the same problem.
    After installing all the package nedded (see preavious posts to understand), you can modify the code inside \src folder. After that, running the rollup.config.js file in that way:

    rollup --config  rollup.config.js

    it will be created a new file app.js with your modifications. After that, the file app.js can be copied and pasted in Espruino IDE and finally runned in bangle.js.

    I don't know id it is the best way to do that but it works.

  • Great, glad you got it going! I think that's the correct way of doing it.

    I'm surprised rollup -c didn't do it for you though

  • Hi all,

    I'm the developer of BangleRun... Sorry to have missed this discussion, but I'm glad that you managed to modify the app anyway :)

    I used typescript and rollup because:

    1. strong typing helps me a lot (especially for not-so-simple projects like this app)
    2. it's the language I'm more familiar with, and
    3. the plain javascript code was too big to fit in memory during runtime.

    The app started as a weekend project, and then became something more... I wasn't expecting much interest from other people, but now it's probably time to document the thing a bit and add at least a README file on how to compile it :)

  • Thanks - a README for it would be awesome actually :)

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

Banglerun with a custom mobile app

Posted by Avatar for valap95 @valap95