GPS and SCAN BLE

I would like to develop a micro app that adds the location when it SCAN BLE beacon
… as beacons are in a truck.

What would you recomend in term of code, to do in sequence

Every x hours,

  1. Launch a GPS fix
  2. Once fix is OK … launch the BLE scan

Thks

Something like this maybe:

var lastKnownLocation = null;

timers.repeat('4 hours', () => {
  location.startUpdates((location) => {
    // fix found
    lastKnownLocation = location;
    location.stop();
  })
  .then(() => {
    ble.startScan((scanResult) => {
      // process scan results
    }, '1 min')
    .then(() => {
      // BLE scan is done, upload location and BLE scan results to Cloud?
    });
  });
});
1 Like