Esempio n. 1
0
        private void Instance_Ranged(object sender, IEnumerable <IBeacon> e)
        {
            try
            {
                Beacons.Clear();
                foreach (var beacon in e)
                {
                    var imageCellBeacon = new ImageCellBeacon
                    {
                        Text        = beacon.Proximity.ToString(),
                        Detail      = $"{beacon.Major}.{beacon.Minor}",
                        DetailColor =
                            beacon.Uuid == EstimoteConfig.EstimoteUuidVirtual ? "Blue" : "Purple",
                        ImageSource =
                            beacon.Uuid == EstimoteConfig.EstimoteUuidVirtual ? "EstimoteBlue.png"
                                : "EstimotePurple.png",
                    };
                    Beacons.Add(imageCellBeacon);
                }
                _beaconsFound = DateTime.Now;
                DisplayCurrentStatus();
                if (!_timerStarted)
                {
                    Device.StartTimer(TimeSpan.FromSeconds(5), TimerElapsed);
                    _timerStarted = true;
                }

                Debug.WriteLine("Beacons : " + Beacons.Count);
            }
            catch (Exception exception)
            {
                LogStatus = exception.Message;
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Mac,Type,Name,Location,Date,Rssi1,Rssi2,Rssi3,Rssi4")] Beacons beacons)
        {
            if (id != beacons.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(beacons);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BeaconsExists(beacons.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(beacons));
        }
Esempio n. 3
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (sender != null)
     {
         System.Windows.Controls.Button btn = (System.Windows.Controls.Button)sender;
         Beacons p = btn.DataContext as Beacons;
         Console.WriteLine(p.FamilyPath);
         Process.Start(p.FamilyPath);
     }
 }
        public async Task <IActionResult> Create([Bind("Id,Mac,Type,Name,Location,Date,Rssi1,Rssi2,Rssi3,Rssi4")] Beacons beacons)
        {
            if (ModelState.IsValid)
            {
                _context.Add(beacons);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(beacons));
        }
Esempio n. 5
0
        private bool TimerElapsed()
        {
            var dif = DateTime.Now.Subtract(_beaconsFound);

            Debug.WriteLine("Dif " + dif.Seconds);
            if (dif.Seconds <= 5)
            {
                return(true);
            }
            Beacons.Clear();
            DisplayCurrentStatus();
            return(true);
        }
Esempio n. 6
0
    protected override void FillArrays()
    {
        radiuses = new float[3];
        x_t      = new float[3];
        y_t      = new float[3];

        Beacons = GameObject.FindGameObjectsWithTag("Beacon");

        Beacons = Beacons.OrderBy(x => x.GetComponent <BLE_Script>().CountedDistance).Take(3).ToArray();

        for (int i = 0; i < Beacons.Length; i++)
        {
            radiuses[i] = Beacons[i].GetComponent <BLE_Script>().CountedDistance;
            x_t[i]      = Beacons[i].transform.position.x;
            y_t[i]      = Beacons[i].transform.position.y;
        }
    }
        public void CreateBeacon(AdvertisementBeaconPageNewBeaconViewModel parameters)
        {
            short?preferredTxPower = null;

            if (parameters.PreferredTxPower != "")
            {
                preferredTxPower = Convert.ToInt16(parameters.PreferredTxPower);
            }

            var beacon = new ObservableBluetoothLEBeacon(
                GattConvert.ToIBufferFromHexString(parameters.Payload).ToArray(),
                parameters.UseExtendedFormat,
                parameters.IsAnonymous,
                parameters.IncludeTxPower,
                preferredTxPower);

            Beacons.Add(beacon);

            // Reset the parameters after creation.
            parameters.Reset();
        }
Esempio n. 8
0
        private void OnBeaconDeleted(BeaconViewModel beacon)
        {
            beacon.Deleted -= OnBeaconDeleted;

            Beacons.Remove(beacon);
        }
Esempio n. 9
0
 public string BeaconsAsString()
 {
     return(Beacons.Aggregate("", (current, beacon) => current + ("(" + beacon.X + "; " + beacon.Y + "); Acc=" + beacon.Accuracy + "\n")));
 }