Skip to content

Commit

Permalink
fix (Android.FailSafeBleConnectionSettings.cs): we now have seperate …
Browse files Browse the repository at this point in the history
…failsafe settings for downloading which set initial-mtu-size=50 (old was: 23 which caused even healthy phones to fail downloading)
  • Loading branch information
ksidirop-laerdal committed Oct 23, 2024
1 parent 3a0b296 commit 6ce8fd3
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public EAndroidFileDownloaderVerdict beginDownload(
final String remoteFilePath,
final int initialMtuSize
// final int windowCapacity, //theoretically nordic firmwares at some point will support this for downloads but as of Q3 2024 there is no support for this
// final int memoryAlignment //this doesnt make sense for downloading it only makes sense in uploading scenarios https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/issues/188#issuecomment-2391146897
)
{
if (!IsCold()) //keep first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public partial class FileDownloaderTestbed
{
[Theory]
[InlineData("FDT.SFDA.SCSBFBTFS.GFBC.010", "/path/to/file.bin", 2)]
[InlineData("FDT.SFDA.SCSBFBTFS.GFBC.020", "/path/to/file.bin", 3)]
[InlineData("FDT.SFDA.SCSBFBTFS.GFBC.030", "/path/to/file.bin", 5)]
// [InlineData("FDT.SFDA.SCSBFBTFS.GFBC.020", "/path/to/file.bin", 3)]
// [InlineData("FDT.SFDA.SCSBFBTFS.GFBC.030", "/path/to/file.bin", 5)]
public async Task SingleFileDownloadAsync_ShouldCompleteSuccessfullyByFallingBackToFailsafeSettings_GivenFlakyBluetoothConnection(string testcaseNickname, string remoteFilePath, int maxTriesCount)
{
// Arrange
Expand All @@ -43,7 +43,7 @@ public async Task SingleFileDownloadAsync_ShouldCompleteSuccessfullyByFallingBac
));

// Assert
await work.Should().CompleteWithinAsync((maxTriesCount * 2).Seconds());
await work.Should().CompleteWithinAsync((maxTriesCount * 200).Seconds());

mockedNativeFileDownloaderProxy.BugDetected.Should().BeNull();
mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
Expand Down Expand Up @@ -127,9 +127,9 @@ public override EFileDownloaderVerdict BeginDownload(
await Task.Delay(5);
FileDownloadProgressPercentageAndDataThroughputChangedAdvertisement(60, 10);

if (_tryCounter == _maxTriesCount && initialMtuSize != AndroidTidbits.BleConnectionSettings.FailSafes.InitialMtuSize)
if (_tryCounter == _maxTriesCount && initialMtuSize != AndroidTidbits.BleConnectionFailsafeSettings.ForDownloading.InitialMtuSize)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(initialMtuSize)} set to {AndroidTidbits.BleConnectionSettings.FailSafes.InitialMtuSize} but it's set to {initialMtuSize?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(initialMtuSize)} set to {AndroidTidbits.BleConnectionFailsafeSettings.ForDownloading.InitialMtuSize} but it's set to {initialMtuSize?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileDownloaderState.Downloading, EFileDownloaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Unknown, EFileOperationGroupReturnCode.Unset); // order
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,41 +136,41 @@ public override EFileUploaderVerdict BeginUpload(
await Task.Delay(5);
FileUploadProgressPercentageAndDataThroughputChangedAdvertisement(60, 10);

if (_tryCounter == _maxTriesCount && initialMtuSize != AndroidTidbits.BleConnectionSettings.FailSafes.InitialMtuSize)
if (_tryCounter == _maxTriesCount && initialMtuSize != AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.InitialMtuSize)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(initialMtuSize)} set to {AndroidTidbits.BleConnectionSettings.FailSafes.InitialMtuSize} but it's set to {initialMtuSize?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(initialMtuSize)} set to {AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.InitialMtuSize} but it's set to {initialMtuSize?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileUploaderState.Uploading, EFileUploaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Generic, EFileOperationGroupReturnCode.Unset); // order
return;
}

if (_tryCounter == _maxTriesCount && windowCapacity != AndroidTidbits.BleConnectionSettings.FailSafes.WindowCapacity)
if (_tryCounter == _maxTriesCount && windowCapacity != AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.WindowCapacity)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(windowCapacity)} set to {AndroidTidbits.BleConnectionSettings.FailSafes.WindowCapacity} but it's set to {windowCapacity?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(windowCapacity)} set to {AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.WindowCapacity} but it's set to {windowCapacity?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileUploaderState.Uploading, EFileUploaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Generic, EFileOperationGroupReturnCode.Unset); // order
return;
}

if (_tryCounter == _maxTriesCount && memoryAlignment != AndroidTidbits.BleConnectionSettings.FailSafes.MemoryAlignment)
if (_tryCounter == _maxTriesCount && memoryAlignment != AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.MemoryAlignment)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(memoryAlignment)} set to {AndroidTidbits.BleConnectionSettings.FailSafes.MemoryAlignment} but it's set to {memoryAlignment?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(memoryAlignment)} set to {AndroidTidbits.BleConnectionFailsafeSettings.ForUploading.MemoryAlignment} but it's set to {memoryAlignment?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileUploaderState.Uploading, EFileUploaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Generic, EFileOperationGroupReturnCode.Unset); // order
return;
}

if (_tryCounter == _maxTriesCount && pipelineDepth != AppleTidbits.BleConnectionSettings.FailSafes.PipelineDepth)
if (_tryCounter == _maxTriesCount && pipelineDepth != AppleTidbits.BleConnectionFailsafeSettings.ForUploading.PipelineDepth)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(pipelineDepth)} set to {AppleTidbits.BleConnectionSettings.FailSafes.PipelineDepth} but it's set to {pipelineDepth?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(pipelineDepth)} set to {AppleTidbits.BleConnectionFailsafeSettings.ForUploading.PipelineDepth} but it's set to {pipelineDepth?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileUploaderState.Uploading, EFileUploaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Generic, EFileOperationGroupReturnCode.Unset); // order
return;
}

if (_tryCounter == _maxTriesCount && byteAlignment != AppleTidbits.BleConnectionSettings.FailSafes.ByteAlignment)
if (_tryCounter == _maxTriesCount && byteAlignment != AppleTidbits.BleConnectionFailsafeSettings.ForUploading.ByteAlignment)
{
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(byteAlignment)} set to {AppleTidbits.BleConnectionSettings.FailSafes.ByteAlignment} but it's set to {byteAlignment?.ToString() ?? "(null)"} instead - something is wrong!";
BugDetected = $"[BUG DETECTED] The very last try should be with {nameof(byteAlignment)} set to {AppleTidbits.BleConnectionFailsafeSettings.ForUploading.ByteAlignment} but it's set to {byteAlignment?.ToString() ?? "(null)"} instead - something is wrong!";
StateChangedAdvertisement(remoteFilePath, EFileUploaderState.Uploading, EFileUploaderState.Error); // order
FatalErrorOccurredAdvertisement(remoteFilePath, BugDetected, EMcuMgrErrorCode.Generic, EFileOperationGroupReturnCode.Unset); // order
return;
Expand Down
Loading

0 comments on commit 6ce8fd3

Please sign in to comment.