From 10ac0a5d2e623cf0271a89456d76d6ca76349126 Mon Sep 17 00:00:00 2001 From: spehj Date: Fri, 18 Oct 2024 09:47:42 +0200 Subject: [PATCH 1/5] upgrade permission handler version to be compatible with the latest gradle --- esp_provisioning/example/android/app/build.gradle | 2 +- .../example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- esp_provisioning/example/pubspec.yaml | 2 +- esp_provisioning/pubspec.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esp_provisioning/example/android/app/build.gradle b/esp_provisioning/example/android/app/build.gradle index 17ce401..a83dee5 100644 --- a/esp_provisioning/example/android/app/build.gradle +++ b/esp_provisioning/example/android/app/build.gradle @@ -44,7 +44,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.spindance.esp_provisioning.example" - minSdkVersion flutter.minSdkVersion + minSdkVersion 24 // flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/esp_provisioning/example/android/gradle/wrapper/gradle-wrapper.properties b/esp_provisioning/example/android/gradle/wrapper/gradle-wrapper.properties index cfe88f6..e6b38c2 100644 --- a/esp_provisioning/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/esp_provisioning/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/esp_provisioning/example/pubspec.yaml b/esp_provisioning/example/pubspec.yaml index cfcbc4e..86939f2 100644 --- a/esp_provisioning/example/pubspec.yaml +++ b/esp_provisioning/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: path: ../ flutter: sdk: flutter - permission_handler: ^8.3.0 + permission_handler: ^11.3.1 dev_dependencies: flutter_driver: diff --git a/esp_provisioning/pubspec.yaml b/esp_provisioning/pubspec.yaml index 0f8bf1d..c15bc74 100644 --- a/esp_provisioning/pubspec.yaml +++ b/esp_provisioning/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: sdk: flutter freezed_annotation: ^2.4.1 json_annotation: 4.8.1 - permission_handler: ^8.1.0 + permission_handler: ^11.3.1 dev_dependencies: build_runner: ^2.4.9 From 28c5dcb5b99b46c6e96c65183b646f91ab70aba3 Mon Sep 17 00:00:00 2001 From: spehj Date: Fri, 18 Oct 2024 10:00:57 +0200 Subject: [PATCH 2/5] upgraded gradle version --- esp_provisioning_android/android/build.gradle | 8 +++++--- .../android/gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/esp_provisioning_android/android/build.gradle b/esp_provisioning_android/android/build.gradle index 084e456..4d93d5a 100644 --- a/esp_provisioning_android/android/build.gradle +++ b/esp_provisioning_android/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -17,7 +17,8 @@ buildscript { rootProject.allprojects { repositories { google() - mavenCentral(url: 'https://jitpack.io') + mavenCentral() + maven { url 'https://jitpack.io' } // Fixed maven central syntax } } @@ -25,7 +26,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdk 31 + namespace 'com.spindance.esp_provisioning' + compileSdk 34 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/esp_provisioning_android/android/gradle/wrapper/gradle-wrapper.properties b/esp_provisioning_android/android/gradle/wrapper/gradle-wrapper.properties index ae04661..27313fb 100644 --- a/esp_provisioning_android/android/gradle/wrapper/gradle-wrapper.properties +++ b/esp_provisioning_android/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From faeff21e56c3bcfebfc6ddcedcefbf4784b6b453 Mon Sep 17 00:00:00 2001 From: spehj Date: Sun, 23 Feb 2025 11:12:58 +0100 Subject: [PATCH 3/5] Refactor build.gradle and settings.gradle for improved plugin management and structure --- .../example/android/app/build.gradle | 19 ++++-------- esp_provisioning/example/android/build.gradle | 13 -------- .../example/android/settings.gradle | 30 ++++++++++++++----- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/esp_provisioning/example/android/app/build.gradle b/esp_provisioning/example/android/app/build.gradle index 8699f6e..4bd55bf 100644 --- a/esp_provisioning/example/android/app/build.gradle +++ b/esp_provisioning/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace 'com.spindance.esp_provisioning.example' compileSdk flutter.compileSdkVersion @@ -63,7 +60,3 @@ android { flutter { source '../..' } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/esp_provisioning/example/android/build.gradle b/esp_provisioning/example/android/build.gradle index 68b15a8..bc157bd 100644 --- a/esp_provisioning/example/android/build.gradle +++ b/esp_provisioning/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.9.0' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/esp_provisioning/example/android/settings.gradle b/esp_provisioning/example/android/settings.gradle index 44e62bc..b3832f7 100644 --- a/esp_provisioning/example/android/settings.gradle +++ b/esp_provisioning/example/android/settings.gradle @@ -1,11 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.1.0" apply false + id "org.jetbrains.kotlin.android" version "1.9.0" apply false +} + +include ":app" \ No newline at end of file From 209d9e0bc999bc0e239fdaf90654dcaf2cb39be7 Mon Sep 17 00:00:00 2001 From: spehj Date: Thu, 25 Sep 2025 15:18:12 +0200 Subject: [PATCH 4/5] fixing build issues --- esp_provisioning/lib/esp_provisioning.dart | 30 ++++--- .../lib/src/esp_ble_device.freezed.dart | 60 ++++++++++---- .../lib/src/esp_ble_device.g.dart | 8 +- .../src/esp_wifi_access_point.freezed.dart | 82 +++++++++++++------ .../lib/src/esp_wifi_access_point.g.dart | 12 ++- .../test/esp_provisioning_test.dart | 10 ++- esp_provisioning_android/android/build.gradle | 6 +- .../esp_provisioning_platform_interface.dart | 12 +-- ..._provisioning_platform_interface_test.dart | 12 +-- 9 files changed, 147 insertions(+), 85 deletions(-) diff --git a/esp_provisioning/lib/esp_provisioning.dart b/esp_provisioning/lib/esp_provisioning.dart index ad36859..1930de5 100644 --- a/esp_provisioning/lib/esp_provisioning.dart +++ b/esp_provisioning/lib/esp_provisioning.dart @@ -52,7 +52,9 @@ class EspProvisioning { int responseTimeoutSec = defaultResponseTimeoutSec, ]) async { // Get the access points as JSON strings. - final accessPointJsonStrings = await _espPlatform.getEspAccessPoints(deviceName).timeout( + final accessPointJsonStrings = await _espPlatform + .getEspAccessPoints(deviceName) + .timeout( Duration(seconds: responseTimeoutSec), onTimeout: () => throw TimeoutException('Failed to get access points within $responseTimeoutSec seconds.'), ); @@ -61,8 +63,8 @@ class EspProvisioning { final accessPointMaps = accessPointJsonStrings.map((e) => json.decode(e) as Map).toList(); // Convert the maps into EspWifiAccessPoint objects and return the sorted by SSID. - final accessPoints = accessPointMaps.map(EspWifiAccessPoint.fromJson).toList() - ..sort((a, b) => a.ssid.compareTo(b.ssid)); + final accessPoints = + accessPointMaps.map(EspWifiAccessPoint.fromJson).toList()..sort((a, b) => a.ssid.compareTo(b.ssid)); return accessPoints; } @@ -75,11 +77,12 @@ class EspProvisioning { String ssid, String password, [ int responseTimeoutSec = defaultResponseTimeoutSec, - ]) => - _espPlatform.setEspAccessPoint(deviceName, ssid, password).timeout( - Duration(seconds: responseTimeoutSec), - onTimeout: () => throw TimeoutException('Failed to set access point within $responseTimeoutSec seconds.'), - ); + ]) => _espPlatform + .setEspAccessPoint(deviceName, ssid, password) + .timeout( + Duration(seconds: responseTimeoutSec), + onTimeout: () => throw TimeoutException('Failed to set access point within $responseTimeoutSec seconds.'), + ); /// Sends [data] to the specified [endpoint] on the device with [deviceName], returning a [Uint8List] response. /// [responseTimeoutSec] is optional and defaults to [defaultResponseTimeoutSec]. @@ -88,9 +91,10 @@ class EspProvisioning { String endpoint, Uint8List data, [ int responseTimeoutSec = defaultResponseTimeoutSec, - ]) => - _espPlatform.sendData(deviceName, endpoint, data).timeout( - Duration(seconds: responseTimeoutSec), - onTimeout: () => throw TimeoutException('Failed to send data within $responseTimeoutSec seconds.'), - ); + ]) => _espPlatform + .sendData(deviceName, endpoint, data) + .timeout( + Duration(seconds: responseTimeoutSec), + onTimeout: () => throw TimeoutException('Failed to send data within $responseTimeoutSec seconds.'), + ); } diff --git a/esp_provisioning/lib/src/esp_ble_device.freezed.dart b/esp_provisioning/lib/src/esp_ble_device.freezed.dart index 006450e..b121d3b 100644 --- a/esp_provisioning/lib/src/esp_ble_device.freezed.dart +++ b/esp_provisioning/lib/src/esp_ble_device.freezed.dart @@ -26,21 +26,28 @@ mixin _$EspBleDevice { /// The device's BLE RSSI. The Espressif iOS library does not provide this value; on iOS it will always be 0. int get rssi => throw _privateConstructorUsedError; + /// Serializes this EspBleDevice to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $EspBleDeviceCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of EspBleDevice + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $EspBleDeviceCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $EspBleDeviceCopyWith<$Res> { - factory $EspBleDeviceCopyWith(EspBleDevice value, $Res Function(EspBleDevice) then) = + factory $EspBleDeviceCopyWith( + EspBleDevice value, $Res Function(EspBleDevice) then) = _$EspBleDeviceCopyWithImpl<$Res, EspBleDevice>; @useResult $Res call({String name, int rssi}); } /// @nodoc -class _$EspBleDeviceCopyWithImpl<$Res, $Val extends EspBleDevice> implements $EspBleDeviceCopyWith<$Res> { +class _$EspBleDeviceCopyWithImpl<$Res, $Val extends EspBleDevice> + implements $EspBleDeviceCopyWith<$Res> { _$EspBleDeviceCopyWithImpl(this._value, this._then); // ignore: unused_field @@ -48,6 +55,8 @@ class _$EspBleDeviceCopyWithImpl<$Res, $Val extends EspBleDevice> implements $Es // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of EspBleDevice + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -68,8 +77,10 @@ class _$EspBleDeviceCopyWithImpl<$Res, $Val extends EspBleDevice> implements $Es } /// @nodoc -abstract class _$$EspBleDeviceImplCopyWith<$Res> implements $EspBleDeviceCopyWith<$Res> { - factory _$$EspBleDeviceImplCopyWith(_$EspBleDeviceImpl value, $Res Function(_$EspBleDeviceImpl) then) = +abstract class _$$EspBleDeviceImplCopyWith<$Res> + implements $EspBleDeviceCopyWith<$Res> { + factory _$$EspBleDeviceImplCopyWith( + _$EspBleDeviceImpl value, $Res Function(_$EspBleDeviceImpl) then) = __$$EspBleDeviceImplCopyWithImpl<$Res>; @override @useResult @@ -77,11 +88,15 @@ abstract class _$$EspBleDeviceImplCopyWith<$Res> implements $EspBleDeviceCopyWit } /// @nodoc -class __$$EspBleDeviceImplCopyWithImpl<$Res> extends _$EspBleDeviceCopyWithImpl<$Res, _$EspBleDeviceImpl> +class __$$EspBleDeviceImplCopyWithImpl<$Res> + extends _$EspBleDeviceCopyWithImpl<$Res, _$EspBleDeviceImpl> implements _$$EspBleDeviceImplCopyWith<$Res> { - __$$EspBleDeviceImplCopyWithImpl(_$EspBleDeviceImpl _value, $Res Function(_$EspBleDeviceImpl) _then) + __$$EspBleDeviceImplCopyWithImpl( + _$EspBleDeviceImpl _value, $Res Function(_$EspBleDeviceImpl) _then) : super(_value, _then); + /// Create a copy of EspBleDevice + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -106,7 +121,8 @@ class __$$EspBleDeviceImplCopyWithImpl<$Res> extends _$EspBleDeviceCopyWithImpl< class _$EspBleDeviceImpl with DiagnosticableTreeMixin implements _EspBleDevice { const _$EspBleDeviceImpl({required this.name, required this.rssi}); - factory _$EspBleDeviceImpl.fromJson(Map json) => _$$EspBleDeviceImplFromJson(json); + factory _$EspBleDeviceImpl.fromJson(Map json) => + _$$EspBleDeviceImplFromJson(json); /// The device's advertised name. @override @@ -139,11 +155,13 @@ class _$EspBleDeviceImpl with DiagnosticableTreeMixin implements _EspBleDevice { (identical(other.rssi, rssi) || other.rssi == rssi)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, rssi); - @JsonKey(ignore: true) + /// Create a copy of EspBleDevice + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EspBleDeviceImplCopyWith<_$EspBleDeviceImpl> get copyWith => @@ -158,19 +176,25 @@ class _$EspBleDeviceImpl with DiagnosticableTreeMixin implements _EspBleDevice { } abstract class _EspBleDevice implements EspBleDevice { - const factory _EspBleDevice({required final String name, required final int rssi}) = _$EspBleDeviceImpl; - - factory _EspBleDevice.fromJson(Map json) = _$EspBleDeviceImpl.fromJson; + const factory _EspBleDevice( + {required final String name, + required final int rssi}) = _$EspBleDeviceImpl; - @override + factory _EspBleDevice.fromJson(Map json) = + _$EspBleDeviceImpl.fromJson; /// The device's advertised name. - String get name; @override + String get name; /// The device's BLE RSSI. The Espressif iOS library does not provide this value; on iOS it will always be 0. + @override int get rssi; + + /// Create a copy of EspBleDevice + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) - _$$EspBleDeviceImplCopyWith<_$EspBleDeviceImpl> get copyWith => throw _privateConstructorUsedError; + @JsonKey(includeFromJson: false, includeToJson: false) + _$$EspBleDeviceImplCopyWith<_$EspBleDeviceImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/esp_provisioning/lib/src/esp_ble_device.g.dart b/esp_provisioning/lib/src/esp_ble_device.g.dart index c639ae7..14deb0e 100644 --- a/esp_provisioning/lib/src/esp_ble_device.g.dart +++ b/esp_provisioning/lib/src/esp_ble_device.g.dart @@ -6,12 +6,14 @@ part of 'esp_ble_device.dart'; // JsonSerializableGenerator // ************************************************************************** -_$EspBleDeviceImpl _$$EspBleDeviceImplFromJson(Map json) => _$EspBleDeviceImpl( +_$EspBleDeviceImpl _$$EspBleDeviceImplFromJson(Map json) => + _$EspBleDeviceImpl( name: json['name'] as String, - rssi: json['rssi'] as int, + rssi: (json['rssi'] as num).toInt(), ); -Map _$$EspBleDeviceImplToJson(_$EspBleDeviceImpl instance) => { +Map _$$EspBleDeviceImplToJson(_$EspBleDeviceImpl instance) => + { 'name': instance.name, 'rssi': instance.rssi, }; diff --git a/esp_provisioning/lib/src/esp_wifi_access_point.freezed.dart b/esp_provisioning/lib/src/esp_wifi_access_point.freezed.dart index a581c61..e74c799 100644 --- a/esp_provisioning/lib/src/esp_wifi_access_point.freezed.dart +++ b/esp_provisioning/lib/src/esp_wifi_access_point.freezed.dart @@ -32,17 +32,27 @@ mixin _$EspWifiAccessPoint { /// The Wi-Fi signal strength of the access point. int get rssi => throw _privateConstructorUsedError; + /// Serializes this EspWifiAccessPoint to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $EspWifiAccessPointCopyWith get copyWith => throw _privateConstructorUsedError; + + /// Create a copy of EspWifiAccessPoint + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $EspWifiAccessPointCopyWith get copyWith => + throw _privateConstructorUsedError; } /// @nodoc abstract class $EspWifiAccessPointCopyWith<$Res> { - factory $EspWifiAccessPointCopyWith(EspWifiAccessPoint value, $Res Function(EspWifiAccessPoint) then) = + factory $EspWifiAccessPointCopyWith( + EspWifiAccessPoint value, $Res Function(EspWifiAccessPoint) then) = _$EspWifiAccessPointCopyWithImpl<$Res, EspWifiAccessPoint>; @useResult - $Res call({String ssid, int channel, EspWifiAccessPointSecurity security, int rssi}); + $Res call( + {String ssid, + int channel, + EspWifiAccessPointSecurity security, + int rssi}); } /// @nodoc @@ -55,6 +65,8 @@ class _$EspWifiAccessPointCopyWithImpl<$Res, $Val extends EspWifiAccessPoint> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of EspWifiAccessPoint + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -85,22 +97,30 @@ class _$EspWifiAccessPointCopyWithImpl<$Res, $Val extends EspWifiAccessPoint> } /// @nodoc -abstract class _$$EspWifiAccessPointImplCopyWith<$Res> implements $EspWifiAccessPointCopyWith<$Res> { - factory _$$EspWifiAccessPointImplCopyWith( - _$EspWifiAccessPointImpl value, $Res Function(_$EspWifiAccessPointImpl) then) = +abstract class _$$EspWifiAccessPointImplCopyWith<$Res> + implements $EspWifiAccessPointCopyWith<$Res> { + factory _$$EspWifiAccessPointImplCopyWith(_$EspWifiAccessPointImpl value, + $Res Function(_$EspWifiAccessPointImpl) then) = __$$EspWifiAccessPointImplCopyWithImpl<$Res>; @override @useResult - $Res call({String ssid, int channel, EspWifiAccessPointSecurity security, int rssi}); + $Res call( + {String ssid, + int channel, + EspWifiAccessPointSecurity security, + int rssi}); } /// @nodoc class __$$EspWifiAccessPointImplCopyWithImpl<$Res> extends _$EspWifiAccessPointCopyWithImpl<$Res, _$EspWifiAccessPointImpl> implements _$$EspWifiAccessPointImplCopyWith<$Res> { - __$$EspWifiAccessPointImplCopyWithImpl(_$EspWifiAccessPointImpl _value, $Res Function(_$EspWifiAccessPointImpl) _then) + __$$EspWifiAccessPointImplCopyWithImpl(_$EspWifiAccessPointImpl _value, + $Res Function(_$EspWifiAccessPointImpl) _then) : super(_value, _then); + /// Create a copy of EspWifiAccessPoint + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -132,11 +152,17 @@ class __$$EspWifiAccessPointImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$EspWifiAccessPointImpl with DiagnosticableTreeMixin implements _EspWifiAccessPoint { +class _$EspWifiAccessPointImpl + with DiagnosticableTreeMixin + implements _EspWifiAccessPoint { const _$EspWifiAccessPointImpl( - {required this.ssid, required this.channel, required this.security, required this.rssi}); + {required this.ssid, + required this.channel, + required this.security, + required this.rssi}); - factory _$EspWifiAccessPointImpl.fromJson(Map json) => _$$EspWifiAccessPointImplFromJson(json); + factory _$EspWifiAccessPointImpl.fromJson(Map json) => + _$$EspWifiAccessPointImplFromJson(json); /// The SSID of the access point. @override @@ -177,19 +203,23 @@ class _$EspWifiAccessPointImpl with DiagnosticableTreeMixin implements _EspWifiA other is _$EspWifiAccessPointImpl && (identical(other.ssid, ssid) || other.ssid == ssid) && (identical(other.channel, channel) || other.channel == channel) && - (identical(other.security, security) || other.security == security) && + (identical(other.security, security) || + other.security == security) && (identical(other.rssi, rssi) || other.rssi == rssi)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, ssid, channel, security, rssi); - @JsonKey(ignore: true) + /// Create a copy of EspWifiAccessPoint + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EspWifiAccessPointImplCopyWith<_$EspWifiAccessPointImpl> get copyWith => - __$$EspWifiAccessPointImplCopyWithImpl<_$EspWifiAccessPointImpl>(this, _$identity); + __$$EspWifiAccessPointImplCopyWithImpl<_$EspWifiAccessPointImpl>( + this, _$identity); @override Map toJson() { @@ -206,25 +236,29 @@ abstract class _EspWifiAccessPoint implements EspWifiAccessPoint { required final EspWifiAccessPointSecurity security, required final int rssi}) = _$EspWifiAccessPointImpl; - factory _EspWifiAccessPoint.fromJson(Map json) = _$EspWifiAccessPointImpl.fromJson; - - @override + factory _EspWifiAccessPoint.fromJson(Map json) = + _$EspWifiAccessPointImpl.fromJson; /// The SSID of the access point. - String get ssid; @override + String get ssid; /// The channel of the access point. On Android, channel is unsupported so the value is always 0. - int get channel; @override + int get channel; /// The security configuration of the access point. - EspWifiAccessPointSecurity get security; @override + EspWifiAccessPointSecurity get security; /// The Wi-Fi signal strength of the access point. + @override int get rssi; + + /// Create a copy of EspWifiAccessPoint + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) - _$$EspWifiAccessPointImplCopyWith<_$EspWifiAccessPointImpl> get copyWith => throw _privateConstructorUsedError; + @JsonKey(includeFromJson: false, includeToJson: false) + _$$EspWifiAccessPointImplCopyWith<_$EspWifiAccessPointImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/esp_provisioning/lib/src/esp_wifi_access_point.g.dart b/esp_provisioning/lib/src/esp_wifi_access_point.g.dart index 9b8a09a..b86122a 100644 --- a/esp_provisioning/lib/src/esp_wifi_access_point.g.dart +++ b/esp_provisioning/lib/src/esp_wifi_access_point.g.dart @@ -6,14 +6,18 @@ part of 'esp_wifi_access_point.dart'; // JsonSerializableGenerator // ************************************************************************** -_$EspWifiAccessPointImpl _$$EspWifiAccessPointImplFromJson(Map json) => _$EspWifiAccessPointImpl( +_$EspWifiAccessPointImpl _$$EspWifiAccessPointImplFromJson( + Map json) => + _$EspWifiAccessPointImpl( ssid: json['ssid'] as String, - channel: json['channel'] as int, + channel: (json['channel'] as num).toInt(), security: EspWifiAccessPointSecurity.fromJson(json['security'] as String), - rssi: json['rssi'] as int, + rssi: (json['rssi'] as num).toInt(), ); -Map _$$EspWifiAccessPointImplToJson(_$EspWifiAccessPointImpl instance) => { +Map _$$EspWifiAccessPointImplToJson( + _$EspWifiAccessPointImpl instance) => + { 'ssid': instance.ssid, 'channel': instance.channel, 'security': _$EspWifiAccessPointSecurityEnumMap[instance.security]!, diff --git a/esp_provisioning/test/esp_provisioning_test.dart b/esp_provisioning/test/esp_provisioning_test.dart index 8d37708..55fef6c 100644 --- a/esp_provisioning/test/esp_provisioning_test.dart +++ b/esp_provisioning/test/esp_provisioning_test.dart @@ -63,8 +63,9 @@ void main() { }); test('connect', () async { - when(() => espProvisioningPlatform.connectDevice(deviceA.name, serviceUuid, proofOfPossession)) - .thenAnswer((_) async {}); + when( + () => espProvisioningPlatform.connectDevice(deviceA.name, serviceUuid, proofOfPossession), + ).thenAnswer((_) async {}); await subject.connect(deviceA.name, proofOfPossession); verify(() => espProvisioningPlatform.connectDevice(deviceA.name, serviceUuid, proofOfPossession)).called(1); }); @@ -76,8 +77,9 @@ void main() { }); test('getAccessPoints', () async { - when(() => espProvisioningPlatform.getEspAccessPoints(deviceA.name)) - .thenAnswer((_) async => [accessPointJsonString]); + when( + () => espProvisioningPlatform.getEspAccessPoints(deviceA.name), + ).thenAnswer((_) async => [accessPointJsonString]); expect(await subject.getAccessPoints(deviceA.name), [ap]); verify(() => espProvisioningPlatform.getEspAccessPoints(deviceA.name)).called(1); }); diff --git a/esp_provisioning_android/android/build.gradle b/esp_provisioning_android/android/build.gradle index 0dcaf3a..be4adf1 100644 --- a/esp_provisioning_android/android/build.gradle +++ b/esp_provisioning_android/android/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - namespace "com.spindance.esp_provisioning_android" + namespace "com.spindance.esp_provisioning" compileSdk 31 compileOptions { @@ -47,8 +47,8 @@ android { buildTypes { release { - minifyEnabled true - consumerProguardFiles 'proguard-rules.pro' + minifyEnabled false + // consumerProguardFiles 'proguard-rules.pro' // removed for now } } } diff --git a/esp_provisioning_platform_interface/lib/esp_provisioning_platform_interface.dart b/esp_provisioning_platform_interface/lib/esp_provisioning_platform_interface.dart index 9902228..2072a0a 100644 --- a/esp_provisioning_platform_interface/lib/esp_provisioning_platform_interface.dart +++ b/esp_provisioning_platform_interface/lib/esp_provisioning_platform_interface.dart @@ -79,12 +79,12 @@ abstract class EspProvisioningPlatform extends PlatformInterface { /// Send [data] to the ESP device with the specified [deviceName] using the custom BLE endpoint indicated by /// [endpointPath]. Future sendData(String deviceName, String endpointPath, Uint8List data) async { - final base64StringResult = - await methodChannel.invokeMethod(PluginMethodNames.sendData, { - PluginArgumentNames.deviceName: deviceName, - PluginArgumentNames.endpointPath: endpointPath, - PluginArgumentNames.data: data, - }); + final base64StringResult = await methodChannel + .invokeMethod(PluginMethodNames.sendData, { + PluginArgumentNames.deviceName: deviceName, + PluginArgumentNames.endpointPath: endpointPath, + PluginArgumentNames.data: data, + }); if (base64StringResult == null) throw Exception('Unable to send data.'); return base64StringResult; } diff --git a/esp_provisioning_platform_interface/test/esp_provisioning_platform_interface_test.dart b/esp_provisioning_platform_interface/test/esp_provisioning_platform_interface_test.dart index 50ad466..8aef443 100644 --- a/esp_provisioning_platform_interface/test/esp_provisioning_platform_interface_test.dart +++ b/esp_provisioning_platform_interface/test/esp_provisioning_platform_interface_test.dart @@ -112,11 +112,7 @@ void main() { const password = 'Password'; await subject.setEspAccessPoint(deviceName, ssid, password); - final expectedArguments = { - 'deviceName': deviceName, - 'ssid': ssid, - 'password': password, - }; + final expectedArguments = {'deviceName': deviceName, 'ssid': ssid, 'password': password}; expect(log, [isMethodCall('setAccessPoint', arguments: expectedArguments)]); }); @@ -124,11 +120,7 @@ void main() { test('sendData', () async { await subject.sendData(deviceName, endpoint, data); - final expectedArguments = { - 'deviceName': deviceName, - 'endpointPath': endpoint, - 'data': data, - }; + final expectedArguments = {'deviceName': deviceName, 'endpointPath': endpoint, 'data': data}; expect(log, [isMethodCall('sendData', arguments: expectedArguments)]); }); From e7bcebacce698a48cb52a9d16361f013f7efd8bc Mon Sep 17 00:00:00 2001 From: spehj Date: Thu, 25 Sep 2025 15:25:21 +0200 Subject: [PATCH 5/5] Update AndroidManifest.xml to simplify structure and remove package declaration --- esp_provisioning_android/android/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp_provisioning_android/android/src/main/AndroidManifest.xml b/esp_provisioning_android/android/src/main/AndroidManifest.xml index b173cd8..0fd6dad 100644 --- a/esp_provisioning_android/android/src/main/AndroidManifest.xml +++ b/esp_provisioning_android/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ - + +