Avatar for valap95

valap95

Member since Nov 2020 • Last active Apr 2021
  • 5 conversations
  • 27 comments

Most recent activity

  • in Bangle.js
    Avatar for valap95

    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.

  • in Bangle.js
    Avatar for valap95

    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

  • in Bangle.js
    Avatar for valap95

    Thank you, Gordon, solved it!!!

    • 3 comments
    • 103 views
  • in Bangle.js
    Avatar for valap95

    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:

  • in Bangle.js
    Avatar for valap95

    hi,
    I accidentally run a code on the Espruino ide on the flash memory, how can I delete that code so that I can reuse the bangle?

    Thanks in advance

  • in Bangle.js
    Avatar for valap95

    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

  • in Bangle.js
    Avatar for valap95

    Posted on Wed 10th, June 2020
    This project is applicable to stream data to a smartphone, so without using web BLE?

    • 7 comments
    • 253 views
Actions