internal static LoRaDevice CreateFromSimulatedDevice(
            SimulatedDevice simulatedDevice,
            ILoRaDeviceClient loRaDeviceClient,
            DefaultLoRaDataRequestHandler requestHandler         = null,
            ILoRaDeviceClientConnectionManager connectionManager = null)
        {
            var result = new LoRaDevice(simulatedDevice.LoRaDevice.DevAddr, simulatedDevice.LoRaDevice.DeviceID, connectionManager ?? new SingleDeviceConnectionManager(loRaDeviceClient))
            {
                AppEUI        = simulatedDevice.LoRaDevice.AppEUI,
                AppKey        = simulatedDevice.LoRaDevice.AppKey,
                SensorDecoder = simulatedDevice.LoRaDevice.SensorDecoder,
                AppSKey       = simulatedDevice.LoRaDevice.AppSKey,
                NwkSKey       = simulatedDevice.LoRaDevice.NwkSKey,
                GatewayID     = simulatedDevice.LoRaDevice.GatewayID,
                IsOurDevice   = true,
                ClassType     = (simulatedDevice.ClassType == 'C' || simulatedDevice.ClassType == 'c') ? LoRaDeviceClassType.C : LoRaDeviceClassType.A,
            };

            result.SetFcntDown(simulatedDevice.FrmCntDown);
            result.SetFcntUp(simulatedDevice.FrmCntUp);
            result.AcceptFrameCountChanges();

            if (requestHandler != null)
            {
                result.SetRequestHandler(requestHandler);
            }

            return(result);
        }
 public TestLoRaDeviceFactory(ILoRaDeviceClient loRaDeviceClient, ILoRaDeviceClientConnectionManager connectionManager = null)
 {
     this.loRaDeviceClient  = loRaDeviceClient;
     this.connectionManager = connectionManager ?? new LoRaDeviceClientConnectionManager(new MemoryCache(new MemoryCacheOptions
     {
         ExpirationScanFrequency = TimeSpan.FromSeconds(5),
     }));
 }
Exemplo n.º 3
0
 public TestLoRaDeviceFactory(
     NetworkServerConfiguration configuration,
     ILoRaDeviceClient loRaDeviceClient,
     ILoRaDeviceClientConnectionManager connectionManager,
     LoRaDeviceCache deviceCache,
     ILoRaDataRequestHandler requestHandler)
     : this(requestHandler, connectionManager, deviceCache, configuration, loRaDeviceClient)
 {
 }
Exemplo n.º 4
0
 public void Register(LoRaDevice loRaDevice, ILoRaDeviceClient loraDeviceClient)
 {
     this.managedConnections.AddOrUpdate(
         this.GetConnectionCacheKey(loRaDevice.DevEUI),
         new ManagedConnection(loRaDevice, loraDeviceClient),
         (k, existing) =>
     {
         // Update existing
         return(new ManagedConnection(loRaDevice, loraDeviceClient));
     });
 }
Exemplo n.º 5
0
 private TestLoRaDeviceFactory(ILoRaDataRequestHandler requestHandler,
                               ILoRaDeviceClientConnectionManager connectionManager,
                               LoRaDeviceCache deviceCache,
                               NetworkServerConfiguration configuration,
                               ILoRaDeviceClient loRaDeviceClient)
     : base(configuration ?? new NetworkServerConfiguration {
     GatewayID = MessageProcessorTestBase.ServerGatewayID
 },
            requestHandler,
            connectionManager,
            deviceCache,
            NullLoggerFactory.Instance,
            NullLogger <LoRaDeviceFactory> .Instance,
            meter: null)
 {
     this.loRaDeviceClient = loRaDeviceClient;
 }
        public void Register(LoRaDevice loRaDevice, ILoRaDeviceClient loraDeviceClient)
        {
            if (loRaDevice is null)
            {
                throw new ArgumentNullException(nameof(loRaDevice));
            }

            var key = GetConnectionCacheKey(loRaDevice.DevEUI);

            lock (this.managedConnections)
            {
                if (this.managedConnections.ContainsKey(key))
                {
                    throw new InvalidOperationException($"Connection already registered for device {loRaDevice.DevEUI}");
                }

                this.managedConnections[key] = new ManagedConnection(loRaDevice, loraDeviceClient);
            }
        }
 public TestLoRaDeviceFactory(
     NetworkServerConfiguration configuration,
     ILoRaDeviceFrameCounterUpdateStrategyProvider frameCounterUpdateStrategyProvider,
     ILoRaDeviceClient loRaDeviceClient,
     IDeduplicationStrategyFactory deduplicationFactory,
     ILoRaADRStrategyProvider adrStrategyProvider,
     ILoRAADRManagerFactory adrManagerFactory,
     IFunctionBundlerProvider functionBundlerProvider,
     ILoRaDeviceClientConnectionManager connectionManager)
     : this(loRaDeviceClient)
 {
     this.configuration = configuration;
     this.frameCounterUpdateStrategyProvider = frameCounterUpdateStrategyProvider;
     this.deduplicationFactory    = deduplicationFactory;
     this.adrStrategyProvider     = adrStrategyProvider;
     this.adrManagerFactory       = adrManagerFactory;
     this.functionBundlerProvider = functionBundlerProvider;
     this.connectionManager       = connectionManager;
 }
Exemplo n.º 8
0
        internal static LoRaDevice CreateFromSimulatedDevice(
            SimulatedDevice simulatedDevice,
            ILoRaDeviceClient loRaDeviceClient)
        {
            var result = new LoRaDevice(simulatedDevice.LoRaDevice.DevAddr, simulatedDevice.LoRaDevice.DeviceID, loRaDeviceClient)
            {
                AppEUI        = simulatedDevice.LoRaDevice.AppEUI,
                AppKey        = simulatedDevice.LoRaDevice.AppKey,
                SensorDecoder = simulatedDevice.LoRaDevice.SensorDecoder,
                AppSKey       = simulatedDevice.LoRaDevice.AppSKey,
                NwkSKey       = simulatedDevice.LoRaDevice.NwkSKey,
                GatewayID     = simulatedDevice.LoRaDevice.GatewayID,
                IsOurDevice   = true,
            };

            result.SetFcntDown(simulatedDevice.FrmCntDown);
            result.SetFcntUp(simulatedDevice.FrmCntUp);

            return(result);
        }
 public ManagedConnection(LoRaDevice loRaDevice, ILoRaDeviceClient deviceClient)
 {
     LoRaDevice   = loRaDevice;
     DeviceClient = deviceClient;
 }
 public TestLoRaDeviceFactory(ILoRaDeviceClient loRaDeviceClient)
 {
     this.loRaDeviceClient = loRaDeviceClient;
 }
Exemplo n.º 11
0
 public void SetClient(DevEui devEUI, ILoRaDeviceClient deviceClient) => this.deviceClientMap[devEUI] = deviceClient;
 public void Register(LoRaDevice loRaDevice, ILoRaDeviceClient loraDeviceClient)
 {
 }
Exemplo n.º 13
0
 public TestLoRaDeviceFactory(ILoRaDeviceClient loRaDeviceClient, ILoRaDataRequestHandler requestHandler, LoRaDeviceCache deviceCache, ILoRaDeviceClientConnectionManager connectionManager = null)
     : this(requestHandler, connectionManager, deviceCache, null, loRaDeviceClient)
 {
 }
Exemplo n.º 14
0
 public TestLoRaDeviceFactory(ILoRaDeviceClient loRaDeviceClient, LoRaDeviceCache deviceCache, ILoRaDeviceClientConnectionManager connectionManager = null)
     : this(null, connectionManager, deviceCache, null, loRaDeviceClient)
 {
 }
 internal void SetClient(string devEUI, ILoRaDeviceClient deviceClient) => this.deviceClientMap[devEUI] = deviceClient;
Exemplo n.º 16
0
 public ManagedConnection(LoRaDevice loRaDevice, ILoRaDeviceClient deviceClient)
 {
     this.LoRaDevice   = loRaDevice;
     this.DeviceClient = deviceClient;
 }
Exemplo n.º 17
0
                public LoRaDeviceTest(ILoRaDeviceClient deviceClient)
#pragma warning disable CA2000 // Dispose objects before losing scope - ownership is transferred
                    : base(new DevAddr(0xffffffff), new DevEui(0), new SingleDeviceConnectionManager(deviceClient))
#pragma warning restore CA2000 // Dispose objects before losing scope
                {
                }
 public SingleDeviceConnectionManager(ILoRaDeviceClient deviceClient)
 {
     this.singleDeviceClient = deviceClient;
 }