Ejemplo n.º 1
0
        public static LoRaArduinoSerial CreateFromPort(string port)
        {
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            LoRaArduinoSerial result = null;

            TestLogger.Log($"** Starting serial port '{port}' **");

            var serialPort = new SerialPort(port)
            {
                BaudRate  = 115200,
                Parity    = Parity.None,
                StopBits  = StopBits.One,
                DataBits  = 8,
                DtrEnable = true,
                Handshake = Handshake.None
            };

            result = new LoRaArduinoSerial(serialPort);

            try
            {
                serialPort.Open();
            }
            catch (Exception ex)
            {
                TestLogger.Log($"Error opening serial port '{port}': {ex.ToString()}");
                throw;
            }

            return(result);
        }
Ejemplo n.º 2
0
 public OTAAJoinTest(IntegrationTestFixture testFixture)
 {
     this.testFixture = testFixture;
     this.loraRegion  = LoraRegion.EU;
     this.lora        = LoRaArduinoSerial.CreateFromPort(testFixture.Configuration.LeafDeviceSerialPort);
     this.testFixture.ClearNetworkServerLogEvents();
 }
Ejemplo n.º 3
0
        public async Task InitializeAsync()
        {
            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }

            if (this.Configuration.CreateDevices)
            {
                try
                {
                    await CreateOrUpdateDevicesAsync();
                }
                catch (Exception ex)
                {
                    TestLogger.Log($"[ERR] Failed to create devices in IoT Hub. {ex.ToString()}");
                }
            }

            if (!string.IsNullOrEmpty(Configuration.IoTHubEventHubConnectionString) && this.Configuration.NetworkServerModuleLogAssertLevel != LogValidationAssertLevel.Ignore)
            {
                this.IoTHubMessages = new EventHubDataCollector(Configuration.IoTHubEventHubConnectionString, Configuration.IoTHubEventHubConsumerGroup);
                await this.IoTHubMessages.StartAsync();
            }

            if (Configuration.UdpLog)
            {
                this.udpLogListener = new UdpLogListener(Configuration.UdpLogPort);
                this.udpLogListener.Start();
            }
        }
Ejemplo n.º 4
0
        public void Dispose()
        {
            TestLogger.Log($"{nameof(IntegrationTestFixture)} disposed");

            if (disposed)
            {
                return;
            }

            AppDomain.CurrentDomain.UnhandledException -= this.OnUnhandledException;

            this.arduinoDevice?.Dispose();
            this.arduinoDevice = null;

            this.IoTHubMessages?.Dispose();
            this.IoTHubMessages = null;
            this.registryManager?.Dispose();
            this.registryManager = null;

            this.udpLogListener?.Dispose();
            this.udpLogListener = null;

            GC.SuppressFinalize(this);

            this.disposed = true;
        }
Ejemplo n.º 5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this.arduinoDevice?.Dispose();
                this.arduinoDevice = null;
            }
        }
Ejemplo n.º 6
0
        public static LoRaArduinoSerial CreateFromPort(string port)
        {
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            LoRaArduinoSerial result = null;

            if (!isWindows)
            {
                Console.WriteLine($"Starting serial port '{port}' on non-Windows");

                var serialPort = new SerialDevice(port, BaudRate.B115200);
                result = new LoRaArduinoSerial(serialPort);

                Console.WriteLine($"Opening serial port");
                try
                {
                    serialPort.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error opening serial port '{port}': {ex.ToString()}");
                    throw;
                }
            }
            else
            {
                Console.WriteLine($"Starting serial port '{port}' on Windows");

                var serialPortWin = new SerialPort(port)
                {
                    BaudRate  = 115200,
                    Parity    = Parity.None,
                    StopBits  = StopBits.One,
                    DataBits  = 8,
                    DtrEnable = true,
                    Handshake = Handshake.None
                };
                result = new LoRaArduinoSerial(serialPortWin);

                try
                {
                    serialPortWin.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error opening serial port '{port}': {ex.ToString()}");
                    throw;
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }
        }
Ejemplo n.º 8
0
        public override async Task InitializeAsync()
        {
            TestLogger.LogDate = true;

            await base.InitializeAsync();

            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }

            LoRaAPIHelper.Initialize(this.Configuration.FunctionAppCode, this.Configuration.FunctionAppBaseUrl);
        }
Ejemplo n.º 9
0
 public void Dispose()
 {
     this.lora?.Dispose();
     this.lora = null;
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 10
0
 public IntegrationTestBaseCi(IntegrationTestFixtureCi testFixture)
     : base(testFixture)
 {
     this.arduinoDevice = testFixture.ArduinoDevice;
 }
 public IntegrationTestBase(IntegrationTestFixture testFixture)
 {
     this.testFixture   = testFixture;
     this.arduinoDevice = testFixture.ArduinoDevice;
     this.TestFixture.ClearLogs();
 }
Ejemplo n.º 12
0
 public SensorDecodingTest(IntegrationTestFixture testFixture)
 {
     this.testFixture = testFixture;
     this.lora        = LoRaArduinoSerial.CreateFromPort(testFixture.Configuration.LeafDeviceSerialPort);
     this.testFixture.ClearNetworkServerLogEvents();
 }