Skip to content

Commit 5302079

Browse files
authored
Merge pull request #6 from Ambient-Node/bugfix/#5
Fix: 전원 버튼, 블루투스 연결 분리 & 연결 확인 팝업 타이밍 문제 해결 #5
2 parents cfdadc0 + fff70ab commit 5302079

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

ambient_node/lib/main.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ class _MainShellState extends State<MainShell> {
7878
}
7979

8080
void sendState() {
81-
ble.send({
82-
'powerOn': powerOn,
83-
'speed': speed,
84-
'trackingOn': trackingOn,
85-
'selectedFaceId': selectedFaceId,
86-
});
81+
// 연결되어 있을 때만 전송
82+
if (connected) {
83+
ble.send({
84+
'powerOn': powerOn,
85+
'speed': speed,
86+
'trackingOn': trackingOn,
87+
'selectedFaceId': selectedFaceId,
88+
});
89+
}
8790
}
8891

8992
@override

ambient_node/lib/services/ble_service.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class BleService {
125125
}
126126

127127
_txChar = candidate;
128-
onConnectionStateChanged?.call(true);
128+
// 연결 상태는 _startConnectionMonitoring에서 실제 연결 확인 후 설정
129129
return true;
130130
} catch (error) {
131131
print('BLE connection error: $error');
@@ -156,6 +156,7 @@ class BleService {
156156
if (_device != null) {
157157
_connectionSubscription = _device!.connectionState.listen((state) {
158158
final isConnected = state == BluetoothConnectionState.connected;
159+
print('BLE connection state: $state, connected: $isConnected');
159160
onConnectionStateChanged?.call(isConnected);
160161
if (!isConnected) {
161162
_txChar = null;

0 commit comments

Comments
 (0)