/// <summary>
        /// Creates a <see cref="TestDeviceInfo"/> with ABP authentication
        /// </summary>
        public static TestDeviceInfo CreateABPDevice(uint deviceID, string prefix = null, string gatewayID = null, string sensorDecoder = "DecoderValueSensor", uint netId = 1, char deviceClassType = 'A', bool supports32BitFcnt = false)
        {
            var value8  = deviceID.ToString("00000000");
            var value16 = deviceID.ToString("0000000000000000");
            var value32 = deviceID.ToString("00000000000000000000000000000000");

            if (!string.IsNullOrEmpty(prefix))
            {
                value8  = string.Concat(prefix, value8.Substring(prefix.Length));
                value16 = string.Concat(prefix, value16.Substring(prefix.Length));
                value32 = string.Concat(prefix, value32.Substring(prefix.Length));
            }

            var devAddrValue = NetIdHelper.SetNwkIdPart(value8, netId);
            var result       = new TestDeviceInfo
            {
                DeviceID          = value16,
                GatewayID         = gatewayID,
                SensorDecoder     = sensorDecoder,
                AppSKey           = value32,
                NwkSKey           = value32,
                DevAddr           = devAddrValue,
                ClassType         = deviceClassType,
                Supports32BitFCnt = supports32BitFcnt
            };

            return(result);
        }
Ejemplo n.º 2
0
        public SimulatedDevice(TestDeviceInfo testDeviceInfo, uint frmCntDown = 0, uint frmCntUp = 0)
        {
            this.LoRaDevice = testDeviceInfo;

            this.FrmCntDown = frmCntDown;
            this.FrmCntUp   = frmCntUp;

            if (!this.IsJoined)
            {
                this.joinFinished = new SemaphoreSlim(0);
            }
        }
        /// <summary>
        /// Creates a <see cref="TestDeviceInfo"/> with OTAA authentication
        /// </summary>
        /// <param name="deviceID">Device identifier. It will padded with 0's</param>
        public static TestDeviceInfo CreateOTAADevice(uint deviceID, string prefix = null, string gatewayID = null, string sensorDecoder = "DecoderValueSensor")
        {
            var value16 = deviceID.ToString("0000000000000000");
            var value32 = deviceID.ToString("00000000000000000000000000000000");

            if (!string.IsNullOrEmpty(prefix))
            {
                value16 = string.Concat(prefix, value16.Substring(prefix.Length));
                value32 = string.Concat(prefix, value32.Substring(prefix.Length));
            }

            var result = new TestDeviceInfo
            {
                DeviceID      = value16,
                AppEUI        = value16,
                AppKey        = value32,
                GatewayID     = gatewayID,
                SensorDecoder = sensorDecoder,
            };

            return(result);
        }
 // Logs starts of a test method call
 protected void LogTestStart(TestDeviceInfo device, [CallerMemberName] string memberName = "")
 {
     this.Log($"[INFO] ** Starting {memberName} using device {device.DeviceID} **");
 }