Avatar for user93296

user93296

Member since Aug 2018 • Last active Aug 2018
  • 1 conversations
  • 3 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user93296

    I managed to get it to work by cleaning out all code and using the button press examples from Music Controller. And then just add the advertising code bit. It might have been a problem with the broadcast message being to long.

    function setBleBroadcastingDistress(){
      clearTimeout();
      NRF.setServices({
        'b2fb58a0-8452-402a-8435-eedf397464a9' : {
          0x5AFE : {
            value : true,
            readable : true
          }
        }
      }, { advertise: [ 'b2fb58a0-8452-402a-8435-eedf397464a9' ], uart: false });
    
      NRF.setAdvertising(
        {
          0x1815 : pressIdentifier
        }
        ,
        {
          name: 'ALERT!',
          showName: true
      });
      digitalWrite(LED1, 1);
      setTimeout(function(){
        digitalWrite(LED1,0 );
        setBleBroadcastingNormal();
      }, 10000);
    }
    

    Then advertise another UUID when everything is normal.

    For IDE mode this was enough.

    function ideConnect(){
        NRF.setServices(undefined, { uart: true });
        NRF.setAdvertising({},{
          name: 'IDE',
          showName: true
      });
    }
    

    I will add the connectable:true as you suggested.
    Thanks!

  • Avatar for user93296

    Leds flash as expected. Long press makes it blink blue, but nothing shows up in the "whants to pair" list of the IDE.

    Yes! iBeacon was my first attempt but iBeacon wont provide any method of identifying unique identifiers and separating them.
    e.g When monitoring for iBeacons in the background with uuid=123
    the triggerd event when iBeacon is in range dosen´t contain major or minor.

    https://github.com/Polidea/react-native-­ble-plx/wiki/Bluetooth-Scanning

  • Avatar for user93296

    Goal: Im trying to create a puck that advertises a distress-call ( panic / sos button) and gets picked up by any phone with the corresponding app installed.
    So simply advertising som data and then change som specific advertising data when the button is pressed.
    While developing a long press will make the puck go back into a state where it can connect to the web IDE.

    I have 2 problems at the moment.
    1 When doing a long press the puck is not able to reconnect with the IDE.

    2 The app finds the puck but the serviceUUIDs list is empty. This list need to have at least one entry for iphone to let it be discovered in the background.
    Data retrived in the app :

    "F6:A1:EC:AF:EB:0F"
    isConnectable:null
    localName:"MyName"
    manufacturerData:null
    mtu:23
    name:"MyName"
    overflowServiceUUIDs:null
    rssi:-42
    serviceData:{00000019-0000-1000-8000-008­05f9b34fb: "dGVzdA==", 00001076-0000-1000-8000-00805f9b34fb: "AA=="}
    serviceUUIDs:null 
    solicitedServiceUUIDs:null
    txPowerLevel:null
    

    Puck Code:

    var downTime = 0;
    var presses = 1;
    var heartrate = 5;
    var distress = false;
    
    function ledBlink(ledId, duration, loops) {
      digitalWrite(ledId, true);
      let loop = loops || 1;
      setTimeout(function () {
        digitalWrite(ledId, false);
        if(loop > 1) {
          loop--;
          setTimeout(function () {
            // be off for same amount of time
            ledBlink(ledId, duration, loop);
          }, duration);
        }
      }, duration);
    }
    
    
    function onUp() {
      const lengthOfPress = Date().ms - downTime;
      console.log('Button down for ' + lengthOfPress + 'ms');
      if(lengthOfPress > 1000) {
       longPress();
      } else {
        shortPress();
      }
    }
    
    function onDown() {
      downTime = Date().ms;
      setWatch(onUp, BTN, { edge: 'falling', debounce: 50 });
    }
    
    function longPress() {
      ledBlink(LED3, 100, 3);
      IdeConnect();
    }
    
    function shortPress() {
      ledBlink(LED1, 100, presses);
      presses++;
      beaconMode();
    }
    
    function IdeConnect() {
      // reset ble to connect with Espurino web IDE
      ledBlink(LED3, 200, 10);
      NRF.setServices(undefined, { uart: true });
      NRF.setAdvertising({});
    }
    
    function beaconMode() {
      // advertise some data to everyone in range
      distress = !distress;
      if(distress){
        ledBlink(LED1, 200, 3);
      } else {
        ledBlink(LED2, 200, 3);
      }
    
      // from exaple code
      NRF.setServices({
        0x180D: { // heart_rate
          0x2A37: { // heart_rate_measurement
            notify: true,
            value : [0x06, distress],
          }
        }
      }, { advertise: [ '180D' ], uart: false });
    
      NRF.setAdvertising(
        {
         0x1076 : [distress], // change bit to filter out distresscalls
         0x19 : ['t','e','s','t'] // some identifier
        }
        ,
        {
          name: 'MyName',
          showName: true,
          connectable: false,
          discoverable: true,
          manufacturer: 0x0590,
          manufacturerData:[distress],
        });
    }
    
    
    setWatch(onDown, BTN, { repeat: true, edge: 'rising', debounce: 50 });
    
    
    //save();
    
    
Actions