diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index c2adee8..8b93256 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -34,7 +34,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.tuanpm.esp_provisioning_example"
- minSdkVersion 16
+ minSdkVersion 19
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 8c369ef..caa9e56 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -5,9 +5,11 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
+
+
diff --git a/example/ios/Podfile b/example/ios/Podfile
deleted file mode 100644
index 6697f0a..0000000
--- a/example/ios/Podfile
+++ /dev/null
@@ -1,87 +0,0 @@
-# Uncomment this line to define a global platform for your project
-# platform :ios, '9.0'
-
-# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
-ENV['COCOAPODS_DISABLE_STATS'] = 'true'
-
-project 'Runner', {
- 'Debug' => :debug,
- 'Profile' => :release,
- 'Release' => :release,
-}
-
-def parse_KV_file(file, separator='=')
- file_abs_path = File.expand_path(file)
- if !File.exists? file_abs_path
- return [];
- end
- generated_key_values = {}
- skip_line_start_symbols = ["#", "/"]
- File.foreach(file_abs_path) do |line|
- next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
- plugin = line.split(pattern=separator)
- if plugin.length == 2
- podname = plugin[0].strip()
- path = plugin[1].strip()
- podpath = File.expand_path("#{path}", file_abs_path)
- generated_key_values[podname] = podpath
- else
- puts "Invalid plugin specification: #{line}"
- end
- end
- generated_key_values
-end
-
-target 'Runner' do
- use_frameworks!
- use_modular_headers!
-
- # Flutter Pod
-
- copied_flutter_dir = File.join(__dir__, 'Flutter')
- copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
- copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
- unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
- # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
- # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
- # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
-
- generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
- unless File.exist?(generated_xcode_build_settings_path)
- raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
- end
- generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
- cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
-
- unless File.exist?(copied_framework_path)
- FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
- end
- unless File.exist?(copied_podspec_path)
- FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
- end
- end
-
- # Keep pod path relative so it can be checked into Podfile.lock.
- pod 'Flutter', :path => 'Flutter'
-
- # Plugin Pods
-
- # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
- # referring to absolute paths on developers' machines.
- system('rm -rf .symlinks')
- system('mkdir -p .symlinks/plugins')
- plugin_pods = parse_KV_file('../.flutter-plugins')
- plugin_pods.each do |name, path|
- symlink = File.join('.symlinks', 'plugins', name)
- File.symlink(path, symlink)
- pod name, :path => File.join(symlink, 'ios')
- end
-end
-
-post_install do |installer|
- installer.pods_project.targets.each do |target|
- target.build_configurations.each do |config|
- config.build_settings['ENABLE_BITCODE'] = 'NO'
- end
- end
-end
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
deleted file mode 100644
index 789bb2f..0000000
--- a/example/ios/Podfile.lock
+++ /dev/null
@@ -1,41 +0,0 @@
-PODS:
- - esp_provisioning (0.0.1):
- - Flutter
- - Flutter (1.0.0)
- - flutter_ble_lib (2.2.3):
- - Flutter
- - MultiplatformBleAdapter (= 0.1.5)
- - MultiplatformBleAdapter (0.1.5)
- - "permission_handler (5.0.0+hotfix.3)":
- - Flutter
-
-DEPENDENCIES:
- - esp_provisioning (from `.symlinks/plugins/esp_provisioning/ios`)
- - Flutter (from `Flutter`)
- - flutter_ble_lib (from `.symlinks/plugins/flutter_ble_lib/ios`)
- - permission_handler (from `.symlinks/plugins/permission_handler/ios`)
-
-SPEC REPOS:
- trunk:
- - MultiplatformBleAdapter
-
-EXTERNAL SOURCES:
- esp_provisioning:
- :path: ".symlinks/plugins/esp_provisioning/ios"
- Flutter:
- :path: Flutter
- flutter_ble_lib:
- :path: ".symlinks/plugins/flutter_ble_lib/ios"
- permission_handler:
- :path: ".symlinks/plugins/permission_handler/ios"
-
-SPEC CHECKSUMS:
- esp_provisioning: f23d52f966f1de0f66007d805220abb52f61a2f1
- Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
- flutter_ble_lib: 20e79f0b1d78d921d9ed68ab4451e190029bc3d9
- MultiplatformBleAdapter: 3c4391d428382738a47662ae1f665a29ce78ff39
- permission_handler: 4a985b5448897c27fdeadde84f7452520c0e6c58
-
-PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a
-
-COCOAPODS: 1.9.0.beta.2
diff --git a/example/lib/ble_screen/ble_screen.dart b/example/lib/ble_screen/ble_screen.dart
index 296624d..a9d0975 100644
--- a/example/lib/ble_screen/ble_screen.dart
+++ b/example/lib/ble_screen/ble_screen.dart
@@ -34,7 +34,7 @@ class _BleScreenState extends State {
return Container(
padding: EdgeInsets.only(top: 5.0),
height: MediaQuery.of(context).size.height - 50,
- child: WiFiScreen(),
+ child: WiFiScreenBLE(peripheral: item),
);
});
bottomSheetController.whenComplete(() {
diff --git a/example/lib/ble_service.dart b/example/lib/ble_service.dart
index febd56f..460d189 100644
--- a/example/lib/ble_service.dart
+++ b/example/lib/ble_service.dart
@@ -50,12 +50,13 @@ class BleService {
});
});
+ var state = await _waitForBluetoothPoweredOn();
if (Platform.isAndroid) {
- log.v('enableRadio');
- await _bleManager.enableRadio();
+ if (state.index != 3) { // check if bluetooth is already open
+ log.v('enableRadio');
+ await _bleManager.enableRadio();
+ }
}
-
- var state = await _waitForBluetoothPoweredOn();
_isPowerOn = true;
return state;
}
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 4e3a3dc..3bf0e05 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,3 +1,4 @@
+import 'package:esp_provisioning_example/softap_screen/softap_screen.dart';
import 'package:flutter/material.dart';
import 'ble_screen/ble_screen.dart';
@@ -26,7 +27,7 @@ class HomeScreen extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
- builder: (BuildContext context) => BleScreen()));
+ builder: (BuildContext context) => SoftApScreen()));
},
child: Text(
'Start Provisioning',
diff --git a/example/lib/softap_screen/softap_bloc.dart b/example/lib/softap_screen/softap_bloc.dart
new file mode 100644
index 0000000..2949617
--- /dev/null
+++ b/example/lib/softap_screen/softap_bloc.dart
@@ -0,0 +1,25 @@
+
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:esp_provisioning_example/softap_screen/softap_event.dart';
+import 'package:esp_provisioning_example/softap_screen/softap_state.dart';
+import 'package:esp_provisioning_example/softap_service.dart';
+
+
+
+class SoftApBloc extends Bloc {
+
+ @override
+ // TODO: implement initialState
+ get initialState => SoftApStateLoaded();
+
+ @override
+ Stream mapEventToState(event) async* {
+ if (event is SoftApEventStart){
+ yield* _mapStartToState();
+ }
+ }
+ Stream _mapStartToState() async* {
+
+ }
+}
+
diff --git a/example/lib/softap_screen/softap_event.dart b/example/lib/softap_screen/softap_event.dart
new file mode 100644
index 0000000..12efecd
--- /dev/null
+++ b/example/lib/softap_screen/softap_event.dart
@@ -0,0 +1,10 @@
+import 'package:equatable/equatable.dart';
+
+abstract class SoftApEvent extends Equatable {
+ const SoftApEvent();
+
+ @override
+ List