Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nicolas Richard Walter Boeckh
LogAir_Application_XOS
Commits
d3561bf8
Commit
d3561bf8
authored
Feb 25, 2020
by
Nicolas Richard Walter Boeckh
💬
Browse files
Removed carousel card debug elements.
parent
6d33e413
Changes
8
Hide whitespace changes
Inline
Side-by-side
lib/enums/bluetooth_le_serial_uuid.dart
deleted
100644 → 0
View file @
6d33e413
import
'package:uuid/uuid.dart'
;
class
BtleUUID
{
// TODO Function for service, characteristics parsing.
static
final
List
<
int
>
bluetoothLeCc254xService
=
Uuid
().
parse
(
"0000ffe0-0000-1000-8000-00805f9b34fb"
);
}
\ No newline at end of file
lib/handlers/bluetooth_le_handler.dart
View file @
d3561bf8
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_blue/flutter_blue.dart'
;
import
'package:kotlin_flavor/scope_functions.dart'
;
import
'package:logair_application/enums/platform_channels.dart'
;
import
'package:logair_application/services/wake_service.dart'
;
/// Serves as a wrapper class around [FlutterBlue], and helps integrate it into the application with extensions
class
BTLEHandler
{
/// [Singleton]() instantiation factory.
factory
BTLEHandler
()
=>
_singleton
;
/// Internal static [Singleton]() reference.
static
final
BTLEHandler
_singleton
=
new
BTLEHandler
.
_internal
();
static
bool
started
=
false
;
static
bool
wakeServiceActive
=
false
;
static
bool
serviceRegistered
=
false
;
static
bool
characteristicRegistered
=
false
;
...
...
@@ -25,7 +29,6 @@ class BTLEHandler {
FlutterBlue
fblueInstance
=
FlutterBlue
.
instance
;
factory
BTLEHandler
()
=>
_singleton
;
BTLEHandler
.
_internal
()
{
fblueInstance
.
setLogLevel
(
LogLevel
.
info
);
...
...
@@ -58,7 +61,6 @@ class BTLEHandler {
success
=
true
;
}
}
}
return
success
;
}
...
...
@@ -68,25 +70,24 @@ class BTLEHandler {
_characteristic
.
value
.
transform
(
new
StreamTransformer
.
fromHandlers
(
handleData:
(
List
<
int
>
list
,
EventSink
<
List
<
int
>>
sink
)
{
if
(
list
.
isNotEmpty
)
sink
.
add
(
list
);
else
sink
.
add
([]);
if
(
list
.
isNotEmpty
)
sink
.
add
(
list
);
}
)
).
listen
((
event
)
{
print
(
"Got something"
);
partialData
+=
String
.
fromCharCodes
(
event
);
_partialData
+=
event
;
});
}
return
true
;
}
else
return
false
;
}
String
partialData
=
""
;
List
<
int
>
_
partialData
=
[]
;
Stream
<
String
>
getData
()
async
*
{
Stream
<
List
<
int
>
>
getData
()
async
*
{
while
(
true
)
{
String
temp
=
partialData
;
partialData
=
""
;
List
<
int
>
temp
=
_
partialData
;
_
partialData
=
[]
;
yield
temp
;
await
Future
.
delayed
(
Duration
(
milliseconds:
500
));
}
...
...
@@ -111,6 +112,7 @@ class BTLEHandler {
Future
<
dynamic
>
disconnect
()
=>
this
.
_device
?.
let
((
it
)
{
_device
=
null
;
_characteristic
=
null
;
return
it
.
disconnect
();
});
...
...
@@ -121,22 +123,23 @@ class BTLEHandler {
setDevice
(
BluetoothDevice
device
)
=>
device
?.
let
((
it
)
=>
this
.
_device
=
it
);
bool
switchState
()
{
if
(
started
)
if
(
wakeServiceActive
)
_end
();
else
_start
();
return
started
;
return
wakeServiceActive
;
}
void
_start
()
{
WakeService
().
modifyWakeService
(
true
).
then
((
value
)
=>
print
(
'_device will stay awake
$value
'
));
started
=
true
;
wakeServiceActive
=
true
;
t
=
new
Timer
.
periodic
(
duration
,
(
Timer
t
)
=>
print
(
"
${new DateTime.now()}
"
));
}
void
_end
()
{
WakeService
().
modifyWakeService
(
false
).
then
((
value
)
=>
print
(
'_device will stay awake
$value
'
));
wakeServiceActive
=
false
;
t
.
cancel
();
}
...
...
lib/handlers/data_handler.dart
0 → 100644
View file @
d3561bf8
lib/ui/carousel_card.dart
View file @
d3561bf8
...
...
@@ -2,20 +2,19 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
import
'package:logair_application/ui/base_widget.dart'
;
/// Data / Functionality card in a multiple pane carousel.
class
CarouselCard
extends
StatelessWidget
{
/// [Widget] displayed within the [CarouselCard], should be scrollable to accomodate smaller screens.
final
Widget
child
;
// TODO Used for visual debugging purposes, remove
final
Color
color
;
CarouselCard
({
Key
key
,
@required
this
.
child
,
@required
this
.
color
})
:
super
(
key:
key
);
CarouselCard
({
Key
key
,
@required
this
.
child
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
BaseWidget
(
builder:
(
context
,
sizingInfo
)
=>
new
Container
(
color:
color
,
width:
sizingInfo
.
localWidgetSize
.
width
,
height:
sizingInfo
.
localWidgetSize
.
height
,
padding:
EdgeInsets
.
all
(
1
),
child:
Container
(
decoration:
BoxDecoration
(
...
...
@@ -23,7 +22,9 @@ class CarouselCard extends StatelessWidget {
border:
Border
.
all
(
color:
Colors
.
grey
.
shade500
),
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
)),
),
child:
child
child:
SingleChildScrollView
(
child:
child
),
),
),
);
...
...
lib/ui/components/growing_text.dart
View file @
d3561bf8
import
'package:flutter/widgets.dart'
;
class
TextArea
extends
StatefulWidget
{
TextArea
({
Key
key
})
:
super
(
key:
key
);
@override
_TextAreaState
createState
()
=>
_TextAreaState
();
}
class
_TextAreaState
extends
State
<
TextArea
>
{
_TextAreaState
();
String
data
=
""
;
@override
Widget
build
(
BuildContext
context
)
{
return
Text
(
data
);
}
append
(
String
add
)
{
setState
(()
=>
this
.
data
+=
add
);
}
}
\ No newline at end of file
lib/ui/data_widget.dart
View file @
d3561bf8
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_blue/flutter_blue.dart'
;
import
'package:logair_application/enums/bluetooth_le_serial_uuid.dart'
;
import
'package:logair_application/handlers/bluetooth_le_handler.dart'
;
import
'package:logair_application/ui/carousel_card.dart'
;
...
...
@@ -46,15 +44,14 @@ class DataWidget extends StatelessWidget {
return
Text
(
"Not connected"
);
},
),
StreamBuilder
<
String
>(
StreamBuilder
<
List
<
int
>
>(
stream:
BTLEHandler
().
getData
(),
initialData:
""
,
initialData:
[]
,
builder:
(
context
,
snapshot
)
{
String
data
=
snapshot
.
data
;
print
(
"Data = "
+
data
);
List
<
int
>
data
=
snapshot
.
data
;
if
(
data
!=
null
&&
data
.
length
>
0
)
{
print
((
new
DateTime
.
now
().
millisecondsSinceEpoch
.
toString
())
+
" : "
+
data
);
return
Text
(
data
);
return
Text
(
String
.
fromCharCodes
(
data
));
}
else
return
Text
(
"No data streaming"
);
},
...
...
@@ -62,6 +59,6 @@ class DataWidget extends StatelessWidget {
]
),
);
return
CarouselCard
(
child:
widget
,
color:
Colors
.
green
);
return
CarouselCard
(
child:
widget
);
}
}
\ No newline at end of file
lib/ui/map_widget.dart
View file @
d3561bf8
...
...
@@ -19,6 +19,6 @@ class MapWidget extends StatelessWidget {
)
);
return
CarouselCard
(
child:
widget
,
color:
Colors
.
red
);
return
CarouselCard
(
child:
widget
);
}
}
\ No newline at end of file
lib/ui/social_widget.dart
View file @
d3561bf8
...
...
@@ -19,6 +19,6 @@ class SocialWidget extends StatelessWidget {
),
);
return
CarouselCard
(
child:
widget
,
color:
Colors
.
yellow
);
return
CarouselCard
(
child:
widget
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment