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

Maintenance work. #25

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
12 changes: 2 additions & 10 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="esp_provisioning_example"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="flutterEmbedding" android:value="2" />
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand All @@ -24,15 +25,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
5 changes: 3 additions & 2 deletions example/lib/ble_screen/ble_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'ble.dart';
class BleBloc extends Bloc<BleEvent, BleState> {
var bleService = BleService.getInstance();
StreamSubscription<ScanResult> _scanSubscription;
List<Map<String, dynamic>> bleDevices = new List<Map<String, dynamic>>();
List<Map<String, dynamic>> bleDevices = [];

BleBloc(BleState initialState) : super(initialState);

Expand Down Expand Up @@ -58,7 +58,8 @@ class BleBloc extends Bloc<BleEvent, BleState> {
}

@override
Future<void> close() {
Future<void> close() async {
super.close();
_scanSubscription?.cancel();
bleService.stopScanBle();
}
Expand Down
2 changes: 1 addition & 1 deletion example/lib/ble_screen/ble_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _BleScreenState extends State<BleScreen> {
}

return Center(
child: SpinKitRipple(color: Theme.of(context).textSelectionColor),
child: SpinKitRipple(color: Theme.of(context).textSelectionTheme.selectionColor),
);
},
),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/ble_service.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:async';
// import 'dart:html';
import 'dart:io';
import 'package:esp_provisioning_example/transport_ble.dart';
import 'package:flutter_ble_lib/flutter_ble_lib.dart';
import 'package:esp_provisioning/esp_provisioning.dart';
import 'package:logger/logger.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rxdart/rxdart.dart';
import 'package:location/location.dart' as location;
// import 'package:permission_handler/permission_handler.dart';

Expand Down
2 changes: 1 addition & 1 deletion example/lib/scan_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ScanList extends StatelessWidget {
child: Align(
alignment: Alignment.center,
child: SpinKitRipple(
color: Theme.of(_context).textSelectionColor)))),
color: Theme.of(_context).textSelectionTheme.selectionColor)))),
Expanded(
child: ListView.separated(
shrinkWrap: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:esp_provisioning/esp_provisioning.dart';
import 'package:flutter_ble_lib/flutter_ble_lib.dart';

import 'transport.dart';

class TransportBLE implements ProvTransport {
final Peripheral peripheral;
final String serviceUUID;
Expand Down
2 changes: 1 addition & 1 deletion example/lib/wifi_screen/password_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _PasswordFormFieldState extends State<PasswordFormField> {
return null;
},
decoration: InputDecoration(
suffixIcon: FlatButton(
suffixIcon: TextButton(
onPressed: () {
setState(() {
isObscureText = !isObscureText;
Expand Down
12 changes: 6 additions & 6 deletions example/lib/wifi_screen/wifi_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
List<Widget> _statusWidget = [
Column(
children: <Widget>[
FlatButton.icon(
TextButton.icon(
onPressed: () {},
icon: SpinKitThreeBounce(
color: Colors.black,
Expand All @@ -44,7 +44,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
),
Column(
children: <Widget>[
FlatButton.icon(
TextButton.icon(
onPressed: () {},
icon: Icon(
Icons.check,
Expand All @@ -56,7 +56,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
color: Colors.green,
),
)),
FlatButton.icon(
TextButton.icon(
onPressed: () {},
icon: SpinKitThreeBounce(
color: Colors.black,
Expand All @@ -81,7 +81,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
statusWidget = Expanded(child: _statusWidget[step]);
body = Expanded(
child:
SpinKitDoubleBounce(color: Theme.of(context).textSelectionColor));
SpinKitDoubleBounce(color: Theme.of(context).textSelectionTheme.selectionColor));
} else {
body = wifiList;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SpinKitThreeBounce(
color: Theme.of(context).textSelectionColor,
color: Theme.of(context).textSelectionTheme.selectionColor,
size: 20,
),
Text('Provisioning',
Expand All @@ -153,7 +153,7 @@ class _WiFiScreenState extends State<WiFiScreen> {
return Container(
child: Center(
child: SpinKitThreeBounce(
color: Theme.of(context).textSelectionColor,
color: Theme.of(context).textSelectionTheme.selectionColor,
size: 20,
),
),
Expand Down
39 changes: 23 additions & 16 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "2.9.0"
bloc:
dependency: transitive
description:
Expand All @@ -28,7 +28,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.1"
charcode:
dependency: transitive
description:
Expand All @@ -42,14 +42,14 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -91,7 +91,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
fixnum:
dependency: transitive
description:
Expand All @@ -105,7 +105,7 @@ packages:
source: sdk
version: "0.0.0"
flutter_ble_lib:
dependency: transitive
dependency: "direct main"
description:
name: flutter_ble_lib
url: "https://pub.dartlang.org"
Expand Down Expand Up @@ -148,7 +148,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
location:
dependency: "direct main"
description:
Expand Down Expand Up @@ -183,14 +183,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.8.0"
nested:
dependency: transitive
description:
Expand All @@ -204,7 +211,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
permission_handler:
dependency: "direct main"
description:
Expand Down Expand Up @@ -258,7 +265,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -279,21 +286,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.12"
typed_data:
dependency: transitive
description:
Expand All @@ -307,7 +314,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.18.4 <3.0.0"
flutter: ">=2.0.0"
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
rxdart: ^0.26.0
flutter_spinkit: ^5.0.0
location: ^4.1.1
flutter_ble_lib: ^2.3.2

cupertino_icons: ^1.0.2

Expand Down
1 change: 0 additions & 1 deletion lib/esp_provisioning.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ export 'src/esp_prov.dart';
export 'src/security.dart';
export 'src/security1.dart';
export 'src/transport.dart';
export 'src/transport_ble.dart';
export 'src/connection_models.dart';
10 changes: 5 additions & 5 deletions lib/src/connection_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ enum WifiConnectFailedReason {

class ConnectionStatus {
ConnectionStatus({
this.state,
required this.state,
this.ip,
this.failedReason,
});

final WifiConnectionState state;
final String ip;
final WifiConnectFailedReason failedReason;
final String? ip;
final WifiConnectFailedReason? failedReason;
}

class WifiAP {
const WifiAP({
this.ssid,
this.rssi,
required this.ssid,
required this.rssi,
this.active = false,
this.private = true,
});
Expand Down
4 changes: 2 additions & 2 deletions lib/src/crypt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Crypt {
});
}
Future<Uint8List> crypt (Uint8List data) async {
return _channel.invokeMethod('crypt', {
return await _channel.invokeMethod('crypt', {
'data': data,
});
}) as Uint8List;
}
}
14 changes: 7 additions & 7 deletions lib/src/esp_prov.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class EspProv {
ProvTransport transport;
ProvSecurity security;

EspProv({this.transport, this.security});
EspProv({required this.transport, required this.security});

Future<void> establishSession() async {
SessionData responseData;
SessionData responseData = SessionData();

await transport.disconnect();

Expand Down Expand Up @@ -146,13 +146,13 @@ class EspProv {
return ret;
}

Future<bool> sendWifiConfig({String ssid, String password}) async {
Future<bool> sendWifiConfig({required String ssid, required String password}) async {
var payload = WiFiConfigPayload();
payload.msg = WiFiConfigMsgType.TypeCmdSetConfig;

var cmdSetConfig = CmdSetConfig();
cmdSetConfig.ssid = utf8.encode(ssid ?? '');
cmdSetConfig.passphrase = utf8.encode(password ?? '');
cmdSetConfig.ssid = utf8.encode(ssid);
cmdSetConfig.passphrase = utf8.encode(password);
payload.cmdSetConfig = cmdSetConfig;
var reqData = await security.encrypt(payload.writeToBuffer());
var respData = await transport.sendReceive('prov-config', reqData);
Expand All @@ -171,7 +171,7 @@ class EspProv {
return (respPayload.respApplyConfig.status == Status.Success);
}

Future<ConnectionStatus> getStatus() async {
Future<ConnectionStatus?> getStatus() async {
var payload = WiFiConfigPayload();
payload.msg = WiFiConfigMsgType.TypeCmdGetStatus;

Expand Down Expand Up @@ -213,7 +213,7 @@ class EspProv {
{int packageSize = 256}) async {
var i = data.length;
var offset = 0;
List<int> ret = new List<int>(0);
List<int> ret = [];
while (i > 0) {
var needToSend = data.sublist(offset, i < packageSize ? i : packageSize);
var encrypted = await security.encrypt(needToSend);
Expand Down
Loading