Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고원빈
2021-05-16 13:37:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7e83d2be467640f426e8caf6ef306f1c19f0f906
7e83d2be
1 parent
78a8147c
[frontend] bluetooth 연결 작업 중
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
10 deletions
frontend/flutter_application_1/android/app/build.gradle
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
frontend/flutter_application_1/lib/src/screens/SettingPage.dart
frontend/flutter_application_1/lib/src/screens/SettingPage/Bluetooth.dart
frontend/flutter_application_1/android/app/build.gradle
View file @
7e83d2b
...
...
@@ -39,7 +39,7 @@ android {
defaultConfig
{
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId
"com.example.Smart_Medicine_Box"
minSdkVersion
1
6
minSdkVersion
1
9
targetSdkVersion
29
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
...
...
frontend/flutter_application_1/lib/src/screens/DashBoard.dart
View file @
7e83d2b
...
...
@@ -238,7 +238,7 @@ Widget ineerInformationpage(BuildContext context) {
children:
<
Widget
>[
Container
(
width:
size
.
width
*
0.43
,
height:
size
.
width
*
0.4
3
,
height:
size
.
width
*
0.4
5
,
margin:
const
EdgeInsets
.
all
(
5.0
),
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
5
,
10
,
10
),
decoration:
BoxDecoration
(
...
...
@@ -265,7 +265,7 @@ Widget ineerInformationpage(BuildContext context) {
),
Container
(
width:
size
.
width
,
height:
size
.
height
*
0.14
,
height:
size
.
height
*
0.14
5
,
child:
Center
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
...
...
@@ -276,7 +276,7 @@ Widget ineerInformationpage(BuildContext context) {
textScaleFactor:
1.0
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
80
,
fontSize:
76
,
fontFamily:
'NotoSansKR'
,
fontWeight:
FontWeight
.
w800
),
),
...
...
@@ -299,7 +299,7 @@ Widget ineerInformationpage(BuildContext context) {
),
Container
(
width:
size
.
width
*
0.43
,
height:
size
.
width
*
0.4
3
,
height:
size
.
width
*
0.4
5
,
margin:
const
EdgeInsets
.
all
(
5.0
),
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
5
,
10
,
10
),
decoration:
BoxDecoration
(
...
...
@@ -377,7 +377,7 @@ Widget ineerInformationpage(BuildContext context) {
children:
<
Widget
>[
Container
(
width:
size
.
width
*
0.43
,
height:
size
.
width
*
0.4
3
,
height:
size
.
width
*
0.4
5
,
margin:
const
EdgeInsets
.
all
(
5.0
),
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
5
,
10
,
10
),
decoration:
BoxDecoration
(
...
...
@@ -438,7 +438,7 @@ Widget ineerInformationpage(BuildContext context) {
),
Container
(
width:
size
.
width
*
0.43
,
height:
size
.
width
*
0.4
3
,
height:
size
.
width
*
0.4
5
,
margin:
const
EdgeInsets
.
all
(
5.0
),
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
5
,
10
,
10
),
decoration:
BoxDecoration
(
...
...
frontend/flutter_application_1/lib/src/screens/SettingPage.dart
View file @
7e83d2b
...
...
@@ -161,7 +161,7 @@ class _SettingPageState extends State<SettingPage> {
));
},
child:
Text
(
'
약
정보 수정'
,
'
회원
정보 수정'
,
textScaleFactor:
1.0
,
style:
TextStyle
(
color:
Colors
.
white
,
...
...
frontend/flutter_application_1/lib/src/screens/SettingPage/Bluetooth.dart
View file @
7e83d2b
...
...
@@ -10,7 +10,42 @@ class Bluetooth extends StatefulWidget {
FlutterBlue
flutterBlue
;
class
_BluetoothState
extends
State
<
Bluetooth
>
{
@override
void
initState
()
{
super
.
initState
();
flutterBlue
=
FlutterBlue
.
instance
;
}
void
_startscan
()
{
flutterBlue
.
startScan
(
timeout:
Duration
(
seconds:
12
));
var
subscription
=
flutterBlue
.
scanResults
.
listen
((
results
)
{
// do something with scan results
for
(
ScanResult
r
in
results
)
{
print
(
'Device Name :
${r.device.name}
// Device ID :
${r.device.id}
// Device rssi:
${r.rssi}
'
);
}
});
}
Widget
build
(
BuildContext
context
)
{
Widget
_buildItem
(
ScanResult
s
)
{
return
ListTile
(
leading:
Text
(
s
.
rssi
.
toString
()),
title:
Text
(
s
.
device
.
name
),
subtitle:
Text
(
s
.
device
.
id
.
id
),
onTap:
()
=>
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
{
return
Device
(
device:
s
.
device
);
})),
);
}
Widget
_buildList
(
List
<
ScanResult
>
scanResults
)
{
return
Column
(
children:
scanResults
.
map
((
v
)
=>
_buildItem
(
v
)).
toList
(),
);
}
return
MaterialApp
(
title:
'Welcome to Flutter'
,
home:
Scaffold
(
...
...
@@ -65,10 +100,80 @@ class _BluetoothState extends State<Bluetooth> {
],
),
),
body:
Center
(
child:
Text
(
'약병 내부 페이지 작업 영역'
),
body:
SingleChildScrollView
(
child:
StreamBuilder
<
List
<
ScanResult
>>(
stream:
FlutterBlue
.
instance
.
scanResults
,
initialData:
[],
builder:
(
c
,
snapshot
)
{
return
_buildList
(
snapshot
.
data
);
}),
),
floatingActionButton:
StreamBuilder
<
bool
>(
stream:
FlutterBlue
.
instance
.
isScanning
,
initialData:
false
,
builder:
(
c
,
snapshot
)
{
if
(
snapshot
.
data
)
{
return
FloatingActionButton
(
child:
Icon
(
Icons
.
stop
),
onPressed:
()
=>
FlutterBlue
.
instance
.
stopScan
(),
backgroundColor:
Colors
.
red
,
);
}
else
{
return
FloatingActionButton
(
child:
Icon
(
Icons
.
search
),
onPressed:
()
=>
FlutterBlue
.
instance
.
startScan
(
timeout:
Duration
(
seconds:
4
)));
}
},
),
),
);
}
}
class
Device
extends
StatefulWidget
{
Device
({
Key
key
,
this
.
device
})
:
super
(
key:
key
);
final
BluetoothDevice
device
;
@override
_DeviceState
createState
()
=>
_DeviceState
();
}
class
_DeviceState
extends
State
<
Device
>
{
void
initState
()
{
super
.
initState
();
widget
.
device
.
connect
();
}
@override
void
dispose
()
{
widget
.
device
.
disconnect
();
super
.
dispose
();
}
Widget
_buildIconButton
()
{
return
StreamBuilder
<
BluetoothDeviceState
>(
stream:
widget
.
device
.
state
,
initialData:
BluetoothDeviceState
.
connecting
,
builder:
(
c
,
snapshot
)
{
if
(
snapshot
.
data
!=
BluetoothDeviceState
.
connected
)
return
Icon
(
Icons
.
warning
);
return
IconButton
(
icon:
Icon
(
Icons
.
bluetooth_searching
),
onPressed:
()
=>
widget
.
device
.
discoverServices
(),
);
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
widget
.
device
.
name
),
actions:
<
Widget
>[
_buildIconButton
(),
],
),
body:
Text
(
'hello'
),
);
}
}
...
...
Please
register
or
login
to post a comment