Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop #157

Merged
merged 121 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
8e1c573
feat (AndroidFirmwareInstaller.java): we now support the option of se…
ksidirop-laerdal Sep 25, 2024
f1aa85a
Merge pull request #140 from Laerdal/ksidirop/MAN-417-fw-installation…
ksidirop-laerdal Sep 25, 2024
278af9c
feat (FirmwareInstallerTestbed.InstallAsync.ShouldCompleteSuccessfull…
ksidirop-laerdal Sep 26, 2024
86f6470
feat (FirmwareInstaller.InstallAsync()): we now detect persistent fai…
ksidirop-laerdal Sep 26, 2024
0786511
refa (FirmwareInstaller.InstallAsync()): we now fallback to using fai…
ksidirop-laerdal Sep 26, 2024
fb39d76
feat (FirmwareInstallerTestbed.InstallAsync.ShouldCompleteSuccessfull…
ksidirop-laerdal Sep 26, 2024
1797e7c
doc (IFirmwareInstallerCommandable.InstallAsync()): add a remark abou…
ksidirop-laerdal Sep 27, 2024
6d9f9d5
feat ([Android/Apple] FailSafeBleConnectionSettings.cs): make the fai…
ksidirop-laerdal Sep 27, 2024
d8a8819
fix (firmware-installer-tests-suite): we now make sure to also trigge…
ksidirop-laerdal Sep 30, 2024
2eaf34b
refa (tests-suite): use array literals wherever possible (old was: cl…
ksidirop-laerdal Sep 30, 2024
2d3ba6f
refa: .StartsWith("/") -> .StartsWith('/') for the sake of efficiency
ksidirop-laerdal Sep 30, 2024
88bbff2
refa (StreamExtensions.cs): we now use stream.DisposeAsync() (old was…
ksidirop-laerdal Sep 30, 2024
c7bf3c8
feat (FileUploaderTestbed.SingleFileUploadAsync.ShouldAutodisposeGive…
ksidirop-laerdal Sep 30, 2024
73902da
feat (FileUploader.GetDataAsByteArray_()): enable support for callbac…
ksidirop-laerdal Sep 30, 2024
be660b7
feat (FileUploader.cs): BeginUpload() now supports passing to it cust…
ksidirop-laerdal Sep 30, 2024
87cc117
clean (FirmwareInstaller.BeginInstallation()): simplify the method to…
ksidirop-laerdal Sep 30, 2024
15990eb
doc (IFileUploader.cs): add trivial comments explaining why IFileUplo…
ksidirop-laerdal Sep 30, 2024
7a5f17e
feat (FileDownloader.cs): add support for falling back to failsafe se…
ksidirop-laerdal Oct 1, 2024
fd8579c
fix (Laerdal.McuMgr.Bindings.MacCatalyst.csproj): TargetPlatformVersi…
ksidirop-laerdal Oct 1, 2024
cdbcc20
fix (Laerdal.SetupBuildEnvironment.sh): explicitly install workloads …
ksidirop-laerdal Oct 1, 2024
aa0c628
refa (github-actions.yml): disable mac-catalyst build for now until w…
ksidirop-laerdal Oct 1, 2024
37d1f13
fix (Laerdal.Builder.targets): the tests are now run with the --no-re…
ksidirop-laerdal Oct 2, 2024
4eb8027
refa (Laerdal.Builder.targets): trivial refinements to the way we run…
ksidirop-laerdal Oct 2, 2024
6054dd3
Merge pull request #141 from Laerdal/ksidirop/MAN-419-auto-detect-pro…
ksidirop-laerdal Oct 2, 2024
5a2f8be
fix (Laerdal.McuMgr.csproj): now explicitly sets the proper versions …
ksidirop-laerdal Oct 2, 2024
d89717a
fix (Laerdal.GenerateSignAndUploadSbom.sh): dotnet-CycloneDX is now i…
ksidirop-laerdal Oct 2, 2024
0d079d0
refa (Laerdal.McuMgr.csproj): we now set the dotnet property <TargetP…
ksidirop-laerdal Oct 2, 2024
0640d36
Merge branch 'develop' of github.com:Laerdal/Laerdal.McuMgr into ksid…
ksidirop-laerdal Oct 2, 2024
01381d2
[MAN-420] Fix build error concerning mac catalyst sdk version
ksidirop-laerdal Oct 2, 2024
95c47df
fix (Laerdal.Builder.targets): fix a bug which was causing our build …
ksidirop-laerdal Oct 2, 2024
1370faf
fix (Laerdal.McuMgr.Bindings.MacCatalyst.csproj): we now pass SUPPORT…
ksidirop-laerdal Oct 2, 2024
c4a9776
[MAN-420] Fix build error concerning mac catalyst sdk version
ksidirop-laerdal Oct 2, 2024
d20552e
fix (Laerdal.Mac.CompileAndGenerateFatLibs.sh): fix a bug which sneak…
ksidirop-laerdal Oct 3, 2024
96f2161
Merge pull request #144 from Laerdal/ksidirop/MAN-420-fix-build-error…
ksidirop-laerdal Oct 3, 2024
afadfb1
clean (AndroidFileDownloader.java): remove non-applicable parameters …
ksidirop-laerdal Oct 3, 2024
31c3866
Merge pull request #145 from Laerdal/ksidirop/MAN-419-auto-detect-pro…
ksidirop-laerdal Oct 3, 2024
bec12cc
fix (AndroidFileUploader.java, IOSFileUploader.swift): if the file-up…
ksidirop-laerdal Oct 3, 2024
7d2a1e4
fix (AndroidFileDownloader.java, IOSFileDownloader.swift): if the fil…
ksidirop-laerdal Oct 3, 2024
fa58473
Merge pull request #146 from Laerdal/ksidirop/NOJIRA-improve-error-re…
ksidirop-laerdal Oct 3, 2024
3038428
feat (github-actions.yml): we now target dotnet-workload version 8.0.402
ksidirop-laerdal Oct 4, 2024
ea8a57a
feat (build.gradle): we now build the laerdal-nordic "glue java-lib" …
ksidirop-laerdal Oct 4, 2024
42eff6b
perf (Laerdal.Builder.targets, Laerdal.McuMgr.Bindings.Android.Native…
ksidirop-laerdal Oct 4, 2024
001ff58
[MAN-422] Version-pin dotnet8 workloads in the pipelines
ksidirop-laerdal Oct 4, 2024
2185215
clean (Laerdal.McuMgr.csproj): trivial neutral cleanups
ksidirop-laerdal Oct 4, 2024
f4e0e62
doc (github-actions.yml): trivial comments
ksidirop-laerdal Oct 8, 2024
f8803c0
clean (RemoteFilePathHelpers.cs): trivial neutral cleanups
ksidirop-laerdal Oct 14, 2024
b0061e0
feat (AndroidFileUploader.java): we now call resetUploadState() befor…
ksidirop-laerdal Oct 14, 2024
8b9ed51
fix (FileUploader.TrySetBluetoothDevice()): fix a bug which was causi…
ksidirop-laerdal Oct 14, 2024
31a54c6
clean: trivial neutral comment-cleanups
ksidirop-laerdal Oct 15, 2024
7c45650
refa (AndroidFileUploader.ensureTransportIsInitializedExactlyOnce()):…
ksidirop-laerdal Oct 15, 2024
9a09d9d
refa (AndroidFileUploader.ensureFilesystemManagerIsInitializedExactly…
ksidirop-laerdal Oct 15, 2024
eeb2441
clean (HelpersAndroid.cs): trivial neutral refactoring
ksidirop-laerdal Oct 15, 2024
80ba0ef
refa (AndroidFileUploader.tryInvalidateCachedTransport()): it now als…
ksidirop-laerdal Oct 15, 2024
023e160
fix (AndroidFileUploader.java): fix the order of the parameters of lo…
ksidirop-laerdal Oct 15, 2024
7e67db0
feat (AndroidFileUploader.java): add new logging statements
ksidirop-laerdal Oct 15, 2024
793671e
fix (AndroidFileUploader.java): fix a bug in trySetBluetoothDevice() …
ksidirop-laerdal Oct 15, 2024
b2b5fd8
feat (EMcuMgrErrorCode.cs): add new error codes Generic, ProtocolVers…
ksidirop-laerdal Oct 18, 2024
447f2c7
refa (AndroidFileUploader.java): onError() now returns generic error …
ksidirop-laerdal Oct 18, 2024
9774f58
refa (FileUploader.cs): trivial neutral refactoring to simplify FileU…
ksidirop-laerdal Oct 18, 2024
ae9942e
clean (FileDownloader.cs, FileUploader.cs): we now increase suspiciou…
ksidirop-laerdal Oct 18, 2024
304492e
refa (AndroidFileUploader.java, IOSFileUploader.swift): we now suppor…
ksidirop-laerdal Oct 18, 2024
c068ab8
feat (FileUploader.cs): BeginUpload() now employs fail-safe settings …
ksidirop-laerdal Oct 18, 2024
4f18de9
clean (FileUploaderTestbed.SingleFileUploadAsync.ShouldCompleteSucces…
ksidirop-laerdal Oct 18, 2024
7dc8f4d
Merge pull request #148 from Laerdal/ksidirop/MAN-431-file-uploading-…
ksidirop-laerdal Oct 18, 2024
9ad1187
fix (github-actions.yml): disable test-result publishing due to an er…
ksidirop-laerdal Oct 22, 2024
b36a412
Merge pull request #149 from Laerdal/ksidirop/MAN-431-file-uploading-…
ksidirop-laerdal Oct 22, 2024
94d095b
fix (github-actions.yml): disable test-result publishing due to an er…
ksidirop-laerdal Oct 22, 2024
b92305a
Merge branch 'develop' of github.com:Laerdal/Laerdal.McuMgr into ksid…
ksidirop-laerdal Oct 22, 2024
c773618
feat (AndroidFileUploader.java): add @Contract(pure = true) wherever …
ksidirop-laerdal Oct 22, 2024
857c25e
feat (AndroidDeviceResetter.java): add @Contract(pure = true) whereve…
ksidirop-laerdal Oct 22, 2024
4bea652
feat (AndroidFileDownloader.java): add @Contract(pure = true) whereve…
ksidirop-laerdal Oct 22, 2024
93e108b
feat (AndroidFirmwareEraser.java): add @Contract(pure = true) whereve…
ksidirop-laerdal Oct 22, 2024
1402545
feat (AndroidFirmwareInstaller.java): add @Contract(pure = true) wher…
ksidirop-laerdal Oct 22, 2024
544daf2
clean (AndroidFileUploader.java): trivial cleanups in logging statements
ksidirop-laerdal Oct 22, 2024
1b10b71
refa (IOSFileUploader.swift): we now allow trySetBluetoothDevice() an…
ksidirop-laerdal Oct 22, 2024
7ee6ad0
fix (AndroidFileUploader.java): onError() is no longer marked as 'pur…
ksidirop-laerdal Oct 22, 2024
b2055ed
clean (AndroidFileUploader.java): trivial neutral cleanups and simpli…
ksidirop-laerdal Oct 22, 2024
f83e409
refa (AndroidFileDownloader.java): refactor the implementation to mak…
ksidirop-laerdal Oct 22, 2024
b08ad28
clean (AndroidFileDownloader.java): simplify calls to onError() to im…
ksidirop-laerdal Oct 22, 2024
172cdf3
clean (AndroidFileUploader.java): simplify calls to onError() to impr…
ksidirop-laerdal Oct 22, 2024
073b068
clean (AndroidFileUploader.java): _remoteFilePathSanitized is now set…
ksidirop-laerdal Oct 22, 2024
c60b108
fix (gradle.properties): suppress a warning about android-sdk 34 not …
ksidirop-laerdal Oct 22, 2024
d0ef7c8
revert (AndroidFileDownloader.java, AndroidFileUploader.java): we now…
ksidirop-laerdal Oct 22, 2024
3ea6401
refa (IOSFileUploader.swift): trivial neutral refactoring to improve …
ksidirop-laerdal Oct 22, 2024
5b52b8e
refa (IOSFileDownloader.swift): add support for trySetBluetoothDevice…
ksidirop-laerdal Oct 22, 2024
6ab66d8
fix (FileDownloader::BeginDownload()): the method now supports fallin…
ksidirop-laerdal Oct 22, 2024
94d1cab
fix (github-actions.yml): fix a bug on test-results publishing
ksidirop-laerdal Oct 22, 2024
934743d
migrate (.sln -> .slnx): we now use the .slnx format to store the sol…
ksidirop-laerdal Oct 23, 2024
4362eb2
clean (Laerdal.McuMgr.csproj): trivial neutral tweaks
ksidirop-laerdal Oct 23, 2024
1f8169a
doc (Laerdal.Builder.targets): trivial doc-comment tweaks
ksidirop-laerdal Oct 23, 2024
1f751a0
clean (ConnectionSettingsHelpers.cs): fix method and variable names s…
ksidirop-laerdal Oct 23, 2024
7c20a70
clean (ConnectionSettingsHelpers.cs): use self-explanatory variables …
ksidirop-laerdal Oct 23, 2024
d8ce411
refa (ConnectionSettingsHelpers.cs): we now consider default connecti…
ksidirop-laerdal Oct 23, 2024
963a8d0
refa (ConnectionSettingsHelpers.GetFailsafeConnectionSettingsIfConnec…
ksidirop-laerdal Oct 23, 2024
3ca1e45
refa (FileDownloader.BeginDownload(), FileUploader.BeginUpload()): we…
ksidirop-laerdal Oct 23, 2024
3a0b296
clean (ConnectionSettingsHelpers.GetFailSafeConnectionSettingsIfHostD…
ksidirop-laerdal Oct 23, 2024
6ce8fd3
fix (Android.FailSafeBleConnectionSettings.cs): we now have seperate …
ksidirop-laerdal Oct 23, 2024
b76d5f5
Merge pull request #150
ksidirop-laerdal Oct 23, 2024
0741355
feat (build.gradle): no.nordicsemi.android:mcumgr-ble and no.nordicse…
ksidirop-laerdal Oct 23, 2024
bb40539
clean (FileUploader.cs, FileUploader.cs): trivial neutral cleanups in…
ksidirop-laerdal Oct 23, 2024
ff21511
Merge pull request #151
ksidirop-laerdal Oct 23, 2024
1ee8d9b
clean (FirmwareInstaller.InstallAsync()): replace we now GetFailsafeC…
ksidirop-laerdal Oct 24, 2024
2d34d54
doc (README.md): enrich the summary section with a clarification in r…
ksidirop-laerdal Oct 24, 2024
dc92af4
doc (README.md): update the summary section with a clarification abou…
ksidirop-laerdal Oct 24, 2024
ac00bf5
refa (FirmwareInstaller.BeginInstall()): we now use the fail-safe set…
ksidirop-laerdal Oct 24, 2024
6efb48e
Merge pull request #153
ksidirop-laerdal Oct 24, 2024
edc5a6b
fix (Laerdal.McuMgr.slnx.DotSettings.user): don't include the dotnet …
ksidirop-laerdal Oct 25, 2024
f522514
refa (IOS*.swift): simplify the way we use enums
ksidirop-laerdal Oct 25, 2024
93cea34
refa (FileDownloader.DownloadAsync()): FileDownloader_FatalErrorOccur…
ksidirop-laerdal Oct 25, 2024
a5225b7
feat (FileUploader.BeginUpload()): fix a bug which was causing the ex…
ksidirop-laerdal Oct 25, 2024
d3451d4
refa (FileDownloader, FileUploader): when we detect an error from an …
ksidirop-laerdal Oct 28, 2024
5cfd1b7
refa (FirmwareInstaller): now both the ios and android side report th…
ksidirop-laerdal Oct 28, 2024
8dcca7c
clean (java libs): neutral tweaks to reformat all java files
ksidirop-laerdal Oct 29, 2024
f56db79
refa (java + ios libs): the device-resetter and the firmware-eraser n…
ksidirop-laerdal Oct 29, 2024
c1e12ff
refa (DeviceResetter, FirmwareEraser): we now use global error codes …
ksidirop-laerdal Oct 29, 2024
511e10e
Merge pull request #154
ksidirop-laerdal Oct 29, 2024
a9a9920
clean (AndroidFileDownloader.java): tryEnsureHighConnectionPriority()…
ksidirop-laerdal Oct 31, 2024
0971c23
clean (AndroidFileDownloader.java): tryEnsureHighConnectionPriority()…
ksidirop-laerdal Oct 31, 2024
95f26f5
clean (AndroidDeviceResetter.java): trivial neutral simplifications o…
ksidirop-laerdal Oct 31, 2024
986d01c
refa (DeviceResetter): the BeginReset() method now returns a verdict …
ksidirop-laerdal Oct 31, 2024
f3c32b9
Merge pull request #156
ksidirop-laerdal Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ env:
SCL_DEPENDENCY_TRACKER_SERVER_URL: ${{ secrets.SCL_DEPENDENCY_TRACKER_SERVER_URL }}
SCL_DEPENDENCY_TRACKER_SIGNING_PRIVATE_KEY: ${{ secrets.SCL_DEPENDENCY_TRACKER_SIGNING_PRIVATE_KEY }}

BINDINGS_IOS___SDK_VERSION: "17.5"
BINDINGS_IOS___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.4.app/Contents/Developer"
DOTNET_TARGET_WORKLOAD_VERSION: "8.0.402" # dont upgrade this lightheartedly the workload snapshot implicitly defines which versions of Android/iOS/MacCatalyst SDKs are supported

BINDINGS_MACCATALYST___SDK_VERSION: "14.5"
BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.4.app/Contents/Developer"
BINDINGS_ANDROID___DOTNET_TARGET_PLATFORM_VERSION: "34" # for the csproj file

BINDINGS_IOS___SDK_VERSION: "17.5" # for xcodebuild
BINDINGS_IOS___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.4.app/Contents/Developer" # for xcodebuild
BINDINGS_IOS___DOTNET_TARGET_PLATFORM_VERSION: "17.0" # for the csproj file

BINDINGS_MACCATALYST___SDK_VERSION: "14.5" # for xcodebuild
BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.4.app/Contents/Developer" # for xcodebuild
BINDINGS_MACCATALYST___DOTNET_TARGET_PLATFORM_VERSION: "17.0" # for the csproj file

on:
workflow_call: # so that other workflows can trigger this
Expand Down Expand Up @@ -64,6 +70,7 @@ jobs:
chmod +x "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \
&& \
"${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh" \
"${{env.DOTNET_TARGET_WORKLOAD_VERSION}}" \
"https://nuget.pkg.github.com/Laerdal/index.json" \
"${{env.SCL_GITHUB_NUGET_FEED_USERNAME}}" \
"${{env.SCL_GITHUB_ACCESS_TOKEN}}" \
Expand All @@ -85,26 +92,31 @@ jobs:
-p:Should_Skip_MacCatalyst="false" \
\
-p:PackageOutputPath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts" \
\
-p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \
-p:Laerdal_Source_Branch="${{env.LAERDAL_SOURCE_BRANCH}}" \
-p:Laerdal_Repository_Path="${{env.LAERDAL_REPOSITORY_PATH}}" \
-p:Laerdal_Github_Access_Token="${{env.SCL_GITHUB_ACCESS_TOKEN}}" \
-p:Laerdal_Test_Results_Folderpath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/TestResults" \
\
-p:Laerdal_Dependency_Tracker_Server_Url="${{env.SCL_DEPENDENCY_TRACKER_SERVER_URL}}" \
-p:Laerdal_Dependency_Tracker_Api_Key_File_Path="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/dependency_tracker_api_key.ppk" \
-p:Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/dependency_tracker_private_signing_key.ppk" \
-p:Laerdal_Bindings_Android___DotnetTargetPlatformVersion="${{env.BINDINGS_ANDROID___DOTNET_TARGET_PLATFORM_VERSION}}" \
\
-p:Laerdal_Bindings_iOS___Sdk_Version="${{env.BINDINGS_IOS___SDK_VERSION}}" \
-p:Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path="${{env.BINDINGS_IOS___XCODE_IDE_DEV_PATH}}" \
-p:Laerdal_Bindings_iOS___DotnetTargetPlatformVersion="${{env.BINDINGS_IOS___DOTNET_TARGET_PLATFORM_VERSION}}" \
\
-p:Laerdal_Bindings_MacCatalyst___Sdk_Version="${{env.BINDINGS_MACCATALYST___SDK_VERSION}}" \
-p:Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path="${{env.BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH}}" \
-p:Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion="${{env.BINDINGS_MACCATALYST___DOTNET_TARGET_PLATFORM_VERSION}}" \
\
-p:Laerdal_Dependency_Tracker_Server_Url="${{env.SCL_DEPENDENCY_TRACKER_SERVER_URL}}" \
-p:Laerdal_Dependency_Tracker_Api_Key_File_Path="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/dependency_tracker_api_key.ppk" \
-p:Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts/dependency_tracker_private_signing_key.ppk" \
&& \
rm "./dependency_tracker_private_signing_key.ppk" "./dependency_tracker_api_key.ppk"

- name: '📡 Publish Test Results' # https://github.com/marketplace/actions/publish-test-results
uses: 'EnricoMi/publish-unit-test-result-action/macos@v2'
uses: 'EnricoMi/publish-unit-test-result-action/macos@master'
if: always()
with:
files: |
Expand Down
4 changes: 3 additions & 1 deletion Laerdal.McuMgr.Bindings.Android.Native/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ android.useAndroidX=true
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
# in macos just comment this one out
# as long as we use gradle 7.6 we will get warnings if we try to build against android 34 or above we suppress such warnings
android.suppressUnsupportedCompileSdk=34
# in macos just comment out the windows paths and keep the homebrew path
# org.gradle.java.home=C/://Program Files//Microsoft//jdk-11.0.15.10-hotspot
# org.gradle.java.home=C://Program Files//OpenJDK//jdk-17.0.2
org.gradle.java.home=/opt/homebrew/opt/openjdk@17
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ tasks.register('wrapper', Wrapper) {
}

android {
compileSdk 33
compileSdk 34 // its best to keep this always aligned with the <TargetPlatformVersion> in the .csproj file and with BINDINGS_ANDROID___DOTNET_TARGET_PLATFORM_VERSION at the top of the github actions .yml file

defaultConfig {
minSdk 21
targetSdk 33
targetSdk 34 // its best to keep this always aligned with the <TargetPlatformVersion> in the .csproj file and with BINDINGS_ANDROID___DOTNET_TARGET_PLATFORM_VERSION at the top of the github actions .yml file

consumerProguardFiles "consumer-rules.pro"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -38,12 +38,12 @@ android {
}

dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'no.nordicsemi.android:mcumgr-ble:2.0.2'
implementation 'no.nordicsemi.android:mcumgr-core:2.0.2'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'no.nordicsemi.android:mcumgr-ble:2.2.1'
implementation 'no.nordicsemi.android:mcumgr-core:2.2.1'
implementation 'com.google.android.material:material:1.12.0'
}

// repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
import android.content.Context;
import androidx.annotation.NonNull;
import io.runtime.mcumgr.McuMgrCallback;
import io.runtime.mcumgr.McuMgrErrorCode;
import io.runtime.mcumgr.McuMgrTransport;
import io.runtime.mcumgr.ble.McuMgrBleTransport;
import io.runtime.mcumgr.exception.McuMgrException;
import io.runtime.mcumgr.managers.DefaultManager;
import io.runtime.mcumgr.response.HasReturnCode;
import io.runtime.mcumgr.response.dflt.McuMgrOsResponse;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings("unused")
public class AndroidDeviceResetter {
public class AndroidDeviceResetter
{

private DefaultManager _manager;
private final McuMgrTransport _transport;
Expand All @@ -23,49 +27,59 @@ public class AndroidDeviceResetter {
* @param context the android-context of the calling environment
* @param bluetoothDevice the device to perform the firmware-install on
*/
public AndroidDeviceResetter(@NonNull final Context context, @NonNull final BluetoothDevice bluetoothDevice) {
public AndroidDeviceResetter(@NonNull final Context context, @NonNull final BluetoothDevice bluetoothDevice)
{
_transport = new McuMgrBleTransport(context, bluetoothDevice);
}

public void beginReset() {
public EAndroidDeviceResetterInitializationVerdict beginReset()
{
if (!IsCold())
{ //keep first
onError("[ADR.BR.000] Another reset operation is already in progress (state='" + _currentState + "')");

return EAndroidDeviceResetterInitializationVerdict.FAILED__OTHER_RESET_ALREADY_IN_PROGRESS;
}

try
{
_manager = new DefaultManager(_transport);
setState(EAndroidDeviceResetterState.IDLE); //order
_manager = new DefaultManager(_transport); //order
setState(EAndroidDeviceResetterState.RESETTING); //order

AndroidDeviceResetter self = this;
_manager.reset(new McuMgrCallback<McuMgrOsResponse>()
{
@Override
public void onResponse(@NotNull final McuMgrOsResponse response)
{
if (!response.isSuccess())
{ // check for an error return code
self.onError("[ADR.BR.002] Reset failed (error-code '" + response.getReturnCode().toString() + "')", response.getReturnCode(), response.getGroupReturnCode());
return;
}

setState(EAndroidDeviceResetterState.COMPLETE);
}

@Override
public void onError(@NotNull final McuMgrException exception)
{
self.onError("[ADR.BR.005] Reset failed '" + exception.getMessage() + "'", exception);
}
});
}
catch (final Exception ex)
{
setState(EAndroidDeviceResetterState.FAILED);
fatalErrorOccurredAdvertisement("Failed to create manager: '" + ex.getMessage() + "'");
return;
onError("[ADR.BR.010] Failed to initialize reset operation: '" + ex.getMessage() + "'", ex);
return EAndroidDeviceResetterInitializationVerdict.FAILED__ERROR_UPON_COMMENCING;
}

setState(EAndroidDeviceResetterState.RESETTING);

_manager.reset(new McuMgrCallback<McuMgrOsResponse>() {

@Override
public void onResponse(@NotNull final McuMgrOsResponse response) {
if (!response.isSuccess()) { // check for an error return code
fatalErrorOccurredAdvertisement("Reset failed (error-code '" + response.getReturnCode().toString() + "')");

setState(EAndroidDeviceResetterState.FAILED);
return;
}

setState(EAndroidDeviceResetterState.COMPLETE);
}

@Override
public void onError(@NotNull final McuMgrException error) {
fatalErrorOccurredAdvertisement("Reset failed '" + error.getMessage() + "'");

setState(EAndroidDeviceResetterState.FAILED);
}

});
return EAndroidDeviceResetterInitializationVerdict.SUCCESS;
}

public void disconnect() { //noinspection ConstantValue
public void disconnect()
{
if (_manager == null)
return;

Expand All @@ -76,38 +90,78 @@ public void disconnect() { //noinspection ConstantValue
mcuMgrTransporter.release();
}

public EAndroidDeviceResetterState getState() {
public EAndroidDeviceResetterState getState()
{
return _currentState;
}

private EAndroidDeviceResetterState _currentState = EAndroidDeviceResetterState.NONE;
private void setState(EAndroidDeviceResetterState newState) {

@Contract(pure = true)
private boolean IsCold()
{
return _currentState == EAndroidDeviceResetterState.NONE
|| _currentState == EAndroidDeviceResetterState.COMPLETE;
}

private void setState(final EAndroidDeviceResetterState newState)
{
final EAndroidDeviceResetterState oldState = _currentState; //order

_currentState = newState; //order

stateChangedAdvertisement(oldState, newState); //order
}

protected void onCleared() {
protected void onCleared()
{
// _manager.setFirmwareUpgradeCallback(null);
}

private String _lastFatalErrorMessage;

public String getLastFatalErrorMessage() {
@Contract(pure = true)
public String getLastFatalErrorMessage()
{
return _lastFatalErrorMessage;
}

public void fatalErrorOccurredAdvertisement(String errorMessage) {
_lastFatalErrorMessage = errorMessage; //this method is intentionally empty its meant to be overridden by csharp binding libraries to intercept updates
private void onError(final String errorMessage)
{
onError(errorMessage, null);
}

private void onError(final String errorMessage, final Exception exception)
{
onErrorImpl(errorMessage, McuMgrExceptionHelpers.DeduceGlobalErrorCodeFromException(exception));
}

private void onError(final String errorMessage, final McuMgrErrorCode exceptionCodeSpecs, final HasReturnCode.GroupReturnCode groupReturnCodeSpecs)
{
onErrorImpl(errorMessage, McuMgrExceptionHelpers.DeduceGlobalErrorCodeFromException(exceptionCodeSpecs, groupReturnCodeSpecs));
}

private void onErrorImpl(final String errorMessage, final int globalErrorCode)
{
setState(EAndroidDeviceResetterState.FAILED);

fatalErrorOccurredAdvertisement(errorMessage, globalErrorCode);
}

public void fatalErrorOccurredAdvertisement(final String errorMessage, final int globalErrorCode)
{ //this method is meant to be overridden by csharp binding libraries to intercept updates
_lastFatalErrorMessage = errorMessage;
}

public void logMessageAdvertisement(String message, String category, String level) {
@Contract(pure = true)
public void logMessageAdvertisement(final String message, final String category, final String level)
{
//this method is intentionally empty its meant to be overridden by csharp binding libraries to intercept updates
}

public void stateChangedAdvertisement(EAndroidDeviceResetterState oldState, EAndroidDeviceResetterState currentState) {
@Contract(pure = true)
public void stateChangedAdvertisement(final EAndroidDeviceResetterState oldState, final EAndroidDeviceResetterState currentState)
{
//this method is intentionally empty its meant to be overridden by csharp binding libraries to intercept updates
}

Expand Down
Loading
Loading