-
Hi @Gordon,
I've just implemented a code that allows to stream data via BLE (in my case to a mobile app developed for a specific task). Idk if it is interesting for you (in terms of adding this part to the original app) or others for private use, in any case, I post it in this post.import { ActivityStatus, AppState} from './state'; declare var NRF: any; //Setto i servizi per preparare la connessione function SetServices(state:AppState){ NRF.setServices({ // activity services 'f8b20001-89ad-4220-8c9f-d81756009f0c': { 'f8b20002-89ad-4220-8c9f-d81756009f0c': { descriptio: 'duration', notify: true, readable: true, value: [state.duration] }, 'f8b20003-89ad-4220-8c9f-d81756009f0c':{ description: 'distance', notify:'true', readable: 'true', value: [state.distance] }, 'f8b20004-89ad-4220-8c9f-d81756009f0c':{ description: 'speed', notify:'true', readable: 'true', value: [state.speed] }, 'f8b20005-89ad-4220-8c9f-d81756009f0c':{ description: 'steps', notify:'true', readable: 'true', value: [state.steps] }, 'f8b20006-89ad-4220-8c9f-d81756009f0c':{ description: 'cadence', notify:'true', readable: 'true', value: [state.cadence] }, }, //HR services 'f8b20007-89ad-4220-8c9f-d81756009f0c': { 'f8b20008-89ad-4220-8c9f-d81756009f0c': { description:'HR', readable: true, notify: true, value : [state.hr], } } }); } function UpdateServices(state: AppState): void { NRF.updateServices({ // activity services 'f8b20001-89ad-4220-8c9f-d81756009f0c': { 'f8b20002-89ad-4220-8c9f-d81756009f0c': { descriptio: 'duration', notify: true, readable: true, value: [state.duration] }, 'f8b20003-89ad-4220-8c9f-d81756009f0c':{ description: 'distance', notify:'true', readable: 'true', value: [state.distance] }, 'f8b20004-89ad-4220-8c9f-d81756009f0c':{ description: 'speed', notify:'true', readable: 'true', value: [state.speed] }, 'f8b20005-89ad-4220-8c9f-d81756009f0c':{ description: 'steps', notify:'true', readable: 'true', value: [state.steps] }, 'f8b20006-89ad-4220-8c9f-d81756009f0c':{ description: 'cadence', notify:'true', readable: 'true', value: [state.cadence] }, }, //HR services 'f8b20007-89ad-4220-8c9f-d81756009f0c': { 'f8b20008-89ad-4220-8c9f-d81756009f0c': { description:'HR', readable: true, notify: true, value : [state.hr], } } }); } export {SetServices,UpdateServices};
I added this .ts file to the src folder in my fork of BangleApps and ran using rollup in vs code. Then I took app.js content and with it, I created my own app.
Kind Regards
Valerio
-
-
hi @Gordon,
I added this typescript code to banglerun:import { AppState} from './state'; declare var NRF: any; function startStreaming(state:AppState):void{ SetServices(state); } //Setto i servizi per preparare la connessione function SetServices(state:AppState){ NRF.setServices({ // activity services 'f8b20001-89ad-4220-8c9f-d81756009f0c': { 'f8b20002-89ad-4220-8c9f-d81756009f0c': { descriptio: 'duration', notify: true, readable: true, value: [] }, 'f8b20003-89ad-4220-8c9f-d81756009f0c':{ description: 'distance', notify:'true', readable: 'true', value: [0] }, 'f8b20004-89ad-4220-8c9f-d81756009f0c':{ description: 'speed', notify:'true', readable: 'true', value: [0] }, 'f8b20005-89ad-4220-8c9f-d81756009f0c':{ description: 'steps', notify:'true', readable: 'true', value: [0] }, 'f8b20006-89ad-4220-8c9f-d81756009f0c':{ description: 'cadence', notify:'true', readable: 'true', value: [0] }, }, //HR services 'f8b20007-89ad-4220-8c9f-d81756009f0c': { 'f8b20008-89ad-4220-8c9f-d81756009f0c': { description:'HR', readable: true, notify: true, value : [0], } } }); UpdateServices(state); } function UpdateServices(state: AppState): void { NRF.updateServices({ // activity services 'f8b20001-89ad-4220-8c9f-d81756009f0c': { 'f8b20002-89ad-4220-8c9f-d81756009f0c': { descriptio: 'duration', notify: true, readable: true, value: [state.duration] }, 'f8b20003-89ad-4220-8c9f-d81756009f0c':{ description: 'distance', notify:'true', readable: 'true', value: [state.distance] }, 'f8b20004-89ad-4220-8c9f-d81756009f0c':{ description: 'speed', notify:'true', readable: 'true', value: [state.speed] }, 'f8b20005-89ad-4220-8c9f-d81756009f0c':{ description: 'steps', notify:'true', readable: 'true', value: [state.steps] }, 'f8b20006-89ad-4220-8c9f-d81756009f0c':{ description: 'cadence', notify:'true', readable: 'true', value: [state.cadence] }, }, //HR services 'f8b20007-89ad-4220-8c9f-d81756009f0c': { 'f8b20008-89ad-4220-8c9f-d81756009f0c': { description:'HR', readable: true, notify: true, value : [state.hr], } } }); }
this code, when the app starts, set services, and when you press start button should start to update value. But when I run the code i obtain this error:
-
-
Sorry for returning to this post after months, I'm back on the project, and now I need to modify banglerun to accomplish my task. I added a new src page in the code, where I'd like to establish a BLE connection with my smartphone app. My problem is that I can not run the code because NRF.setService for example gives me an error. Do I have to add some extensions? Do you have some advices to do this ? @Gordon
-
-
-
It is different because with these sensors I had to program only the client-side, so my app side. BLE sensors stream data independently, in the past project I used to use Light Blue, to understand what the sensor sends, then I used to program my app side in order to receive data.
I said it's different because this time I have also to program the sensor side (bangle in this case), and I think I'm missing something like setting services or connecting. -
Because I want to start a connection on my app scanning for devices and connecting with bangle (so the app is central and watch peripheral), after that bangle starts to stream sensor data, like GPS, HR to my app which saves them locally with SQLite.
The app side is fine, I have problems with the bangle side because I can connect from the app (i can see it thanks to the BLE widget, but when I want to see services or characteristics I catch an error in my app).
But having no experience in a situation like that I can't understand what is the problem -
Hi,
I posted a conversation a few months ago about it. I'm trying again to establish a BLE communication between my smartphone (with a custom app installed) and my bangle.
My problem is that I have experience connecting with sensors that streaming data automatically, like BLE pulse oximeter, HR band, and so on. So in such cases, I had to make my smartphone central (so it starts communication) and Gatt client because it receives data from sensors.
This time is kinda different because the bangle needs to be programmed as a peripheral GATT server and I can't do that, or in other words, it does not work until now in the way I did it.
If someone has some suggestions/tips I'm glad to hear them. -
Oooook i got it, Thank you very much @Gordon, always available and clear. Now i'm going to work on this project.
-
Perfect, that's a good news thank you @Gordon, but i have another question about the architecture, i saw that espruino hub is a bridge between BLE and MQTT, but i didn't understand if the protocol uded is actually a BLE or MQTT? I'll try to explain well, i have to think the data flow between devices as a BLE protocol and manage them in that way, or MQTT?
-
Hi everyone,
i saw the video about using puck.js and raspberryPI with espruino Hub and i'm asking, is it possible to do the same with bangle.js, creating a custom server that stores data and also a custo app for bangle that takes that, obviously always having a connection?Sorry if this is a stupid question but i'm new in IoT world and i'm trying to learn.
-
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.
-
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.
-
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:https://github.com/espruino/EspruinoAppsÂ/blob/master/apps/bletemplogger/interfacÂe.html
Thank you very much, it will be very usefull in future work.
-
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?p.s.
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. -
Thank you very much @Gordon, i solved that problem thanks to your tip but i still can't install apps using vscode there are other errors. I think i'm gonna learn to use Espruino WEB IDE.
-
Ok i solved all problems, now i can list the devices, but i can't install an app through it, i'm getting an exception in heatshrink.js, it is difficult to understand due to the way is written. I will attach an image with the exception underlined, if it persists i think i will leave the idea to use vscode.
Thank's a lot anyway. -
-
-
@parasquid thank you, now i can run apploader.js, but actually i have problems with noble, when i run it i only see in the debug console messages that are visible in the image. But i can't find a list of device in order to connect my bangle. Am i missing something?@Gordon
-
Were you following some docs written somewhere because if so I should
probably update them to include git clone --recurse-submodules
--remote-submodulesUsing GitHub exstension in vsCode, i cloned bangle app using the link u gave me in previous answer. Then i ran the bin/apploader.js and this caused an error. Checking it, i saw that was core folder that after clonation remain empty. I don't if i answered well to your question, in any case thank's for the help, i'm using stackoverflow link to solve the problem and if you need more info i'll give you them.
-
They are custom services, that I read in my app. In that case, they pass to the app measures made by banglerun algorithm. If it can be useful i can share also the C# code that manages connection in my app.