Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 6 additions & 13 deletions esp_provisioning/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -63,7 +60,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions esp_provisioning/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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-8.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
30 changes: 22 additions & 8 deletions esp_provisioning/example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 17 additions & 13 deletions esp_provisioning/lib/esp_provisioning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
);
Expand All @@ -61,8 +63,8 @@ class EspProvisioning {
final accessPointMaps = accessPointJsonStrings.map((e) => json.decode(e) as Map<String, dynamic>).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;
}
Expand All @@ -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].
Expand All @@ -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.'),
);
}
60 changes: 42 additions & 18 deletions esp_provisioning/lib/src/esp_ble_device.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions esp_provisioning/lib/src/esp_ble_device.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading