Example #1
0
        public async Task Test_ABP_Invalid_NwkSKey_Fails_With_Mic_Error()
        {
            var device = this.testFixture.Device8_ABP;

            Console.WriteLine($"Starting {nameof(Test_ABP_Invalid_NwkSKey_Fails_With_Mic_Error)} using device {device.DeviceID}");

            var nwkSKeyToUse = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

            Assert.NotEqual(nwkSKeyToUse, device.NwkSKey);
            await lora.setDeviceModeAsync(LoRaArduinoSerial._device_mode_t.LWABP);

            await lora.setIdAsync(device.DevAddr, device.DeviceID, null);

            await lora.setKeyAsync(nwkSKeyToUse, device.AppSKey, null);

            await lora.SetupLora(this.testFixture.Configuration.LoraRegion);

            lora.transferPacket("100", 10);

            await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

            // After transferPacket: Expectation from serial
            // +MSG: Done
            await AssertUtils.ContainsWithRetriesAsync("+MSG: Done", this.lora.SerialLogs);

            // 0000000000000008: with devAddr 0028B1B3 check MIC failed. Device will be ignored from now on
            await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: with devAddr {device.DevAddr} check MIC failed. Device will be ignored from now on");


            this.lora.ClearSerialLogs();
            testFixture.ClearNetworkServerLogEvents();

            // Try with confirmed message

            await lora.transferPacketWithConfirmedAsync("51", 10);

            await Task.Delay(Constants.DELAY_BETWEEN_MESSAGES);

            // 0000000000000008: with devAddr 0028B1B3 check MIC failed. Device will be ignored from now on
            await this.testFixture.ValidateNetworkServerEventLogStartsWithAsync($"{device.DeviceID}: with devAddr {device.DevAddr} check MIC failed. Device will be ignored from now on");


            // Before starting new test, wait until Lora drivers stops sending/receiving data
            await lora.WaitForIdleAsync();
        }