summaryrefslogtreecommitdiff
path: root/lib/main.dart
diff options
context:
space:
mode:
authoruvok2025-07-21 19:08:18 +0200
committeruvok2025-07-21 19:08:18 +0200
commit53242a20032c054e854f2bf3d94f4a5bd10b0be3 (patch)
treed57be4e401b2f09878c8e04ecd3246f6b3fada4c /lib/main.dart
parentdbf1f754078ceebe532663aa163519de699e5a90 (diff)
More BLE handling in second screeen?
Diffstat (limited to 'lib/main.dart')
-rw-r--r--lib/main.dart27
1 files changed, 6 insertions, 21 deletions
diff --git a/lib/main.dart b/lib/main.dart
index f821106..aef85cf 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -70,28 +70,13 @@ class _MyHomePageState extends State<MyHomePage> {
static const int noItemSelected = -1;
int selectedResult = noItemSelected;
- void onConnStateChange(BluetoothConnectionState event) {
- logger.i("New conn state: ${event.toString()}");
- }
-
void _doConnect() async {
var dev = scanResults[selectedResult].device;
- var subs = dev.connectionState.listen(onConnStateChange);
- try {
- logger.i("Try to connect...");
- await dev.connect();
- logger.i("Connected!");
- await dev.disconnect();
- logger.i("Disonnected!");
- } finally {
- subs.cancel();
- }
-
//???
- // Navigator.push(
- // context,
- // MaterialPageRoute(builder: (context) => DeviceScreen()),
- // );
+ Navigator.push(
+ context,
+ MaterialPageRoute(builder: (context) => DeviceScreen(btDevice: dev)),
+ );
}
void _doScan() async {
@@ -110,14 +95,14 @@ class _MyHomePageState extends State<MyHomePage> {
if (Platform.isAndroid) {
await FlutterBluePlus.startScan(
withKeywords: ["NimBLE"],
- timeout: Duration(seconds: 5),
+ timeout: Duration(seconds: 3),
);
} else {
// for Linux, which can't do advNames
// msd doesn't work, either????
await FlutterBluePlus.startScan(
withMsd: [MsdFilter(0xffff, data: ascii.encode("uvok"))],
- timeout: Duration(seconds: 5),
+ timeout: Duration(seconds: 3),
);
}