Commit 0f093fc4 authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬

Started BT Selection dialog, remigrated to `flutter_blue` from `rx_ble`...

Started BT Selection dialog, remigrated to `flutter_blue` from `rx_ble` because I started understanding `StreamBuilder`'s
parent 9cb64041
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"plugin_scaffold","dependencies":[]},{"name":"rx_ble","dependencies":["plugin_scaffold"]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-02-11 17:16:22.831677","version":"1.14.7-pre.83"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.6.3+1\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.6.3+1\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-02-12 00:30:36.235783","version":"1.14.7-pre.83"}
\ No newline at end of file
......@@ -21,5 +21,10 @@
"description": "Reason for the location permission request prompt",
"type": "text",
"placeholders": {}
},
"bluetoothScanMessage": "Scan for Bluetooth Devices",
"@bluetoothScanMessage": {
"type": "text",
"placeholders": {}
}
}
\ No newline at end of file
......@@ -21,5 +21,10 @@
"description": "Raison pour l'annonce de requête de permissions de localisation",
"type": "text",
"placeholders": {}
},
"bluetoothScanMessage": "Recherche d'appareils Bluetooth",
"@bluetoothScanMessage": {
"type": "text",
"placeholders": {}
}
}
\ No newline at end of file
{
"@@last_modified": "2020-02-05T17:32:54.083906",
"@@last_modified": "2020-02-12T00:51:00.943793",
"ok": "OK",
"@ok": {
"type": "text",
......@@ -21,5 +21,10 @@
"description": "Reason for the location permission request prompt",
"type": "text",
"placeholders": {}
},
"bluetoothScanMessage": "Scan for Bluetooth Devices",
"@bluetoothScanMessage": {
"type": "text",
"placeholders": {}
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> {
"bluetoothScanMessage" : MessageLookupByLibrary.simpleMessage("Scan for Bluetooth Devices"),
"cancel" : MessageLookupByLibrary.simpleMessage("Cancel"),
"locationPromptReason" : MessageLookupByLibrary.simpleMessage("To use Bluetooth Low Energy and to increase data collection accuracy, this permission is required."),
"locationPromptTitle" : MessageLookupByLibrary.simpleMessage("This app needs to use location services"),
......
......@@ -21,6 +21,7 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> {
"bluetoothScanMessage" : MessageLookupByLibrary.simpleMessage("Recherche d\'appareils Bluetooth"),
"cancel" : MessageLookupByLibrary.simpleMessage("Annuler"),
"locationPromptReason" : MessageLookupByLibrary.simpleMessage("Afin d\'augmenter la précision de la localisation et pour utiliser Bluetooth Low Energy, cette permission est nécessaire."),
"ok" : MessageLookupByLibrary.simpleMessage("OK")
......
......@@ -44,4 +44,10 @@ class InternalLocalization {
name: 'locationPromptReason',
desc: 'Reason for the location permission request prompt'
);
/// Bluetooth Strings
String get bluetoothScanMessage => Intl.message(
'Scan for Bluetooth Devices',
name: 'bluetoothScanMessage',
);
}
......@@ -6,7 +6,7 @@ import 'package:logair_application/localization/localization_delegate.dart';
import 'package:logair_application/platform/bluetooth_le_service.dart';
import 'package:logair_application/routes/home.dart';
// TODO Lang service, intialized with the right locale, where accessible from entire program
// TODO Lang service, initialized with the right locale, where accessible from entire program
// TODO USED FOR DEBUGGING
final bool displayMode = false;
......@@ -16,7 +16,7 @@ void main() => runApp(displayMode ? DevicePreview(child: LogAirApplication()) :
class LogAirApplication extends StatelessWidget {
static const String _title = 'LogAir Connector';
// This widget is the root of your application.
// This widget is the root of your Wpplication.
@override
Widget build(BuildContext context) {
BTLEHandler();
......
import 'dart:async';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:logair_application/platform/wake_service.dart';
class BTLEHandler {
......@@ -8,9 +9,18 @@ class BTLEHandler {
static Duration duration = new Duration(seconds: 1);
Timer t;
FlutterBlue _flutterBlueInstance = FlutterBlue.instance;
factory BTLEHandler() => _singleton;
BTLEHandler._internal();
BTLEHandler._internal() {
_flutterBlueInstance.setLogLevel(LogLevel.info);
}
startScan() =>
_flutterBlueInstance.startScan(timeout: Duration(seconds: 5));
Future<List<BluetoothDevice>> get connectedDevices => _flutterBlueInstance.connectedDevices;
bool switchState() {
if (started)
......
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:logair_application/localization/localization.dart';
import 'package:logair_application/platform/bluetooth_le_service.dart';
import 'dart:convert';
showBluetoothSelectionDialog(BuildContext context) {
List<String> _frequentDevices = []; // await Devices, filter with cached values
import 'package:shared_preferences/shared_preferences.dart';
class Device {
final String name;
final String address;
Device({this.name, this.address});
Device.fromJson(Map<String, dynamic> data) : name = data["name"], address = data["address"];
@override
String toString() => 'DEVICE $name@$address';
}
showBluetoothSelectionDialog(BuildContext context) async {
/// Connected + frequent devices.
SharedPreferences prefs = await SharedPreferences.getInstance();
List<Device> _frequentDevices = List.from(json.decode((prefs.getString('json') ?? '[ ]')).map((device) => Device(name: device["name"], address: device["address"]))); // await Devices, filter with cached values
print(_frequentDevices);
showDialog(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
children: <Widget>[
SingleChildScrollView(
padding: EdgeInsets.all(0),
child: Column(
children: <Widget>[
ListTile(
title: Text(InternalLocalization.of(context).bluetoothScanMessage),
dense: true,
trailing: IconButton(
icon: Icon(Icons.refresh),
onPressed: () => BTLEHandler().startScan(),
),
),
Divider(),
ListTile(title: Text("Connected"), dense: true),
/// Currently connected BT Devices.
StreamBuilder<List<BluetoothDevice>>(
stream: Stream.periodic(Duration(seconds: 2)).asyncMap((_) => BTLEHandler().connectedDevices),
initialData: [],
builder: (context, snapshot) => Column(
children: snapshot.data.map(
(data) => ListTile(
dense: true,
title: Text(data.name),
subtitle: Text(data.id.toString()),
onTap: () => {
/// Do connect with this device.
print('Pressed ${data.name}')
}
)
).toList(),
)
)
],
)
)
],
);
}
);
}
_getFrequentDevices() async {
}
\ No newline at end of file
......@@ -120,11 +120,25 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.9-beta"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_blue:
dependency: "direct main"
description:
name: flutter_blue
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3+1"
flutter_cache_manager:
dependency: transitive
description:
......@@ -338,20 +352,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
plugin_scaffold:
positioned_tap_detector:
dependency: transitive
description:
name: plugin_scaffold
name: positioned_tap_detector
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
positioned_tap_detector:
version: "1.0.3"
protobuf:
dependency: transitive
description:
name: positioned_tap_detector
name: protobuf
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.1"
provider:
dependency: "direct main"
description:
......@@ -373,13 +387,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
rx_ble:
rxdart:
dependency: transitive
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.6"
shared_preferences:
dependency: "direct main"
description:
name: rx_ble
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1"
version: "0.4.3"
sky_engine:
dependency: transitive
description: flutter
......
......@@ -19,9 +19,10 @@ dependencies:
provider: null
geolocator: ^5.2.1
flutter_map: ^0.8.2
rx_ble:
flutter_blue: ^0.6.3+1
permission_handler: ^4.2.0+hotfix.3
get_it: ^3.1.0
shared_preferences: ^0.4.3
intl_translation: ^0.17.9
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment