Example #1
0
 public InvincibleTrader(IUtcClock utcClock, ICentralRegistry centralRegistry, IBeacon beacon, IBackfiller backfiller)
 {
     _utcClock        = utcClock;
     _centralRegistry = centralRegistry;
     _beacon          = beacon;
     _backfiller      = backfiller;
 }
Example #2
0
 public void SetUp()
 {
     mockLogger = Substitute.For <ILogger>();
     mockLogger.IsDebugEnabled.Returns(true);
     mockBeacon  = Substitute.For <IBeacon>();
     mockSession = Substitute.For <ISessionInternals>();
 }
Example #3
0
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                IBeacon beacon  = (IBeacon)e.Beacons;
                var     message = string.Empty;

                switch ((ProximityType)beacon.Proximity)
                {
                case ProximityType.Immediate:
                    UpdateDisplay("You found the monkey!", Color.Green);
                    break;

                case ProximityType.Near:
                    UpdateDisplay("You're getting warmer", Color.Yellow);
                    break;

                case ProximityType.Far:
                    UpdateDisplay("You're freezing cold", Color.Blue);
                    break;

                case ProximityType.Unknown:
                    UpdateDisplay("I'm not sure how close you are to the monkey", Color.Red);
                    break;
                }

                _previousProximity = beacon.Proximity;
            }
        }
Example #4
0
        private IBeacon LimitedBeaconSearch()
        {
            IBeacon result   = null;
            float   distance = float.MaxValue;

            for (int i = FlightGlobals.VesselsLoaded.Count - 1; i >= 0; i--)
            {
                float vesselDistance = Vector3.Distance(base.vessel.GetWorldPos3D(), FlightGlobals.VesselsLoaded[i].GetWorldPos3D());
                if (!(vesselDistance >= distance))
                {
                    List <ESLDBeacon> beaconsOnVessel = FlightGlobals.VesselsLoaded[i].FindPartModulesImplementing <ESLDBeacon>();
                    for (int j = beaconsOnVessel.Count - 1; j >= 0; j--)
                    {
                        if (!beaconsOnVessel[j].activated || !beaconsOnVessel[j].moduleIsEnabled || (!((Object)FlightGlobals.VesselsLoaded[i] != (Object)base.vessel) && !beaconsOnVessel[j].canJumpSelf))
                        {
                            j--;
                            continue;
                        }
                        result   = beaconsOnVessel[j];
                        distance = vesselDistance;
                        break;
                    }
                }
            }
            return(result);
        }
Example #5
0
        private void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                IBeacon beacon = e.Beacons.FirstOrDefault();

                switch ((ProximityType)beacon.Proximity)
                {
                case ProximityType.Immediate:
                    ShowMessage("Proximity immediate " + beacon.Major);
                    break;

                case ProximityType.Near:
                    ShowMessage("Proximity near " + beacon.Major);
                    break;

                case ProximityType.Far:
                    ShowMessage("Proximity far " + beacon.Major);
                    break;

                case ProximityType.Unknown:
                    ShowMessage("Beacon proximity unknown");
                    break;
                }
            }
        }
Example #6
0
 /// <summary>
 /// Constructor for creating a new root action instance
 /// </summary>
 /// <param name="logger">the logger used to log information</param>
 /// <param name="parentSession">the session to which this root action belongs to</param>
 /// <param name="name">the name of this root action</param>
 /// <param name="beacon">the beacon for retrieving certain data and for sending data</param>
 public RootAction(
     ILogger logger,
     ISessionInternals parentSession,
     string name,
     IBeacon beacon)
     : base(logger, parentSession, name, beacon)
 {
 }
Example #7
0
        public void SetUp()
        {
            mockLogger = Substitute.For <ILogger>();
            mockLogger.IsDebugEnabled.Returns(true);
            mockLogger.IsDebugEnabled.Returns(true);

            mockBeacon = Substitute.For <IBeacon>();
            mockAdditionalParameters = Substitute.For <IAdditionalQueryParameters>();
        }
Example #8
0
    public override bool Equals(object that)
    {
        if (!(that is IBeacon))
        {
            return(false);
        }
        IBeacon thatIBeacon = (IBeacon)that;

        return(thatIBeacon.Major == this.Major && thatIBeacon.Minor == this.Minor && thatIBeacon.ProximityUuid == thatIBeacon.ProximityUuid);
    }
Example #9
0
 protected IBeacon(IBeacon otherIBeacon)
 {
     this.major         = otherIBeacon.major;
     this.minor         = otherIBeacon.minor;
     this.accuracy      = otherIBeacon.accuracy;
     this.proximity     = otherIBeacon.proximity;
     this.rssi          = otherIBeacon.rssi;
     this.proximityUuid = otherIBeacon.proximityUuid;
     this.txPower       = otherIBeacon.txPower;
 }
Example #10
0
    public static IBeacon fromScanData(byte[] scanData, int rssi)
    {
        if (((int)scanData[5] & 0xff) == 0x4c &&
            ((int)scanData[6] & 0xff) == 0x00 &&
            ((int)scanData[7] & 0xff) == 0x02 &&
            ((int)scanData[8] & 0xff) == 0x15)
        {
        }



        else if (((int)scanData[5] & 0xff) == 0x2d &&
                 ((int)scanData[6] & 0xff) == 0x24 &&
                 ((int)scanData[7] & 0xff) == 0xbf &&
                 ((int)scanData[8] & 0xff) == 0x16)
        {
            IBeacon iBeacon = new IBeacon();
            iBeacon.major         = 0;
            iBeacon.minor         = 0;
            iBeacon.proximityUuid = "00000000-0000-0000-0000-000000000000";
            iBeacon.txPower       = -55;
            return(iBeacon);
        }
        else
        {
            System.Console.WriteLine(TAG, "This is not an iBeacon advertisment.  The bytes I see are: " + bytesToHex(scanData));
            return(null);
        }

        IBeacon iBeacon = new IBeacon();

        iBeacon.major   = (scanData[25] & 0xff) * 0x100 + (scanData[26] & 0xff);
        iBeacon.minor   = (scanData[27] & 0xff) * 0x100 + (scanData[28] & 0xff);
        iBeacon.txPower = (int)scanData[29];         // this one is signed
        iBeacon.rssi    = rssi;


        byte[] proximityUuidBytes = new byte[16];
        System.arraycopy(scanData, 9, proximityUuidBytes, 0, 16);
        String        hexString = bytesToHex(proximityUuidBytes);
        StringBuilder sb        = new StringBuilder();

        sb.append(hexString.substring(0, 8));
        sb.append("-");
        sb.append(hexString.substring(8, 12));
        sb.append("-");
        sb.append(hexString.substring(12, 16));
        sb.append("-");
        sb.append(hexString.substring(16, 20));
        sb.append("-");
        sb.append(hexString.substring(20, 32));
        iBeacon.proximityUuid = sb.toString();

        return(iBeacon);
    }
Example #11
0
 public void Update(IBeacon beacon)
 {
     this.AddressAsUlong    = beacon.AddressAsUlong;
     this.DataSections      = beacon.DataSections;
     this.IsProximityBeacon = beacon.IsProximityBeacon;
     this.LocalName         = beacon.LocalName;
     this.ManufacturerData  = beacon.ManufacturerData;
     this.ServiceUuids      = beacon.ServiceUuids;
     this.UpdatedAt         = beacon.UpdatedAt;
     this.Rssi = beacon.Rssi;
 }
Example #12
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterSingleton <IAppInfo, AppInfoImplementation>();

            containerRegistry.RegisterForNavigation <NavigationPage>();
            containerRegistry.RegisterForNavigation <MainPage, MainPageViewModel>();


            ibeacon = DependencyService.Get <IBeacon>();
            ibeacon.Initial();
        }
        public void SetUp()
        {
            mockLogger = Substitute.For <ILogger>();
            mockLogger.IsDebugEnabled.Returns(true);
            mockLogger.IsDebugEnabled.Returns(true);

            nextBeaconId = IdBaseOffset;
            mockBeacon   = Substitute.For <IBeacon>();
            mockBeacon.NextId.Returns(_ => nextBeaconId++);

            parentComposite = Substitute.For <IOpenKitComposite>();
        }
Example #14
0
        internal Session(
            ILogger logger,
            IOpenKitComposite parent,
            IBeacon beacon
            )
        {
            state       = new SessionState(this);
            this.logger = logger;
            this.parent = parent;
            this.beacon = beacon;

            beacon.StartSession();
        }
Example #15
0
 public override void OnUpdate()
 {
     if (hailerActive)
     {
         if ((Object)hailerGui != (Object)null)
         {
             nearBeacon = hailerGui.nearBeacon;
         }
         else
         {
             nearBeacon = LimitedBeaconSearch();
             bool flag = nearBeacon != null;
             ((BaseFieldList <BaseField, KSPField>)base.Fields)["nearBeaconDistance"].guiActive = flag;
             ((BaseFieldList <BaseField, KSPField>)base.Fields)["nearBeaconRelVel"].guiActive   = flag;
             hasNearBeacon = (flag ? "Present" : "Not Present");
             if (flag)
             {
                 nearBeaconDistance = (double)Vector3.Distance(base.vessel.GetWorldPos3D(), nearBeacon.Vessel.GetWorldPos3D());
                 nearBeaconRelVel   = (double)Vector3.Magnitude(base.vessel.obt_velocity - nearBeacon.Vessel.obt_velocity);
             }
         }
     }
 }
        private void UpdateDisplay(IBeacon ibeacon)
        {
            RunOnUiThread(() =>
                {
                    _iBeacon = ibeacon;
                    _textBeaconId.Text = ibeacon.ProximityUuid;
                    var beaconResult = BeaconManager.GetBeaconAsync(ibeacon.ProximityUuid);

                    if(beaconResult != null)
                    {
                        _textBeaconName.Text = beaconResult.Name;
                            _textBeaconDescription.Text = beaconResult.Notes;
                    }
                    else
                    {
                        _newBeaconDetected = true;
                    }
                });
        }
        void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var newDetectedBeacon = e.Beacons.FirstOrDefault();
                if (_iBeacon != null && _iBeacon.ProximityUuid == newDetectedBeacon.ProximityUuid) {
                    return;
                }

                switch((ProximityType)newDetectedBeacon.Proximity)
                {
                case ProximityType.Immediate:
                    UpdateDisplay(newDetectedBeacon);
                    break;
                case ProximityType.Near:
                    UpdateDisplay(newDetectedBeacon);
                    break;
                    //case ProximityType.Far:
                    //	UpdateDisplay(beacon.ProximityUuid);
                    //	break;
                    //case ProximityType.Unknown:
                    //	UpdateDisplay(beacon.ProximityUuid);
                    //	break;
                }

                _previousProximity = newDetectedBeacon.Proximity;
                _iBeacon = newDetectedBeacon;
            }
        }
        void SetProximity(IBeacon source, BeaconItem dest)
        {
            Proximity p = Proximity.Unknown;

            switch((ProximityType)source.Proximity) {
            case ProximityType.Immediate:
                p = Proximity.Immediate;
                break;
            case ProximityType.Near:
                p = Proximity.Near;
                break;
            case ProximityType.Far:
                p = Proximity.Far;
                break;
            }

            if (p > dest.Proximity || p < dest.Proximity) {
                dest.ProximityChangeTimestamp = DateTime.Now;
            }

            dest.Proximity = p;
        }
 public BeaconViewModel(IBeacon beacon)
 {
     this.Information = $"{beacon.Proximity}";
     //			this.Information = $"{beacon.Proximity} {beacon.Identifier}";
     this.Details = $"Major: {beacon.Major} - Minor: {beacon.Minor} - ID: {beacon.Uuid}";
 }