JAVA

Java/BlueTooth LE device call sequence

cskimair 2023. 10. 8. 21:37

opensource: simple_bluetooth_le_terminal

 

 

0) 최초 실행시  MainActivity에서  fragment에  DeviceFragment()를 추가해준다.
> MainActivity.java onCreate() 에서 DeviceFragment.java DeviceFragment() 를 호출함

DeviceFragment.java 
+-> OnCreate() =>
...
+-> onOptionsItemSelected()
  +->startScan()
     ..+->new Thread(() -> bluetoothAdapter.startLeScan(null, leScanCallback), "startLeScan")

1) scan 버튼 누르고 BLE device list에서 1개 선택할때
DeviceFragment.java / onListItemClick()
+-> new TerminalFragment() 로 이동함

.simple_bluetooth_le_terminal D/ViewRootImpl@6a45722[MainActivity]: ViewPostIme pointer 0
.simple_bluetooth_le_terminal D/ViewRootImpl@6a45722[MainActivity]: ViewPostIme pointer 1
l D/BluetoothAdapter: startLeScan(): null
l D/BluetoothAdapter: STATE_ON
l I/chatty: uid=10580(de.kai_morich.simple_bluetooth_le_terminal) startLeScan identical 1 line
l D/BluetoothAdapter: STATE_ON
l D/BluetoothLeScanner: Start Scan with callback
 D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=12 mScannerId=0
 I/oth_le_termina: Compiler allocated 4MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
 D/BluetoothAdapter: stopLeScan()
 D/BluetoothAdapter: STATE_ON
 D/BluetoothAdapter: STATE_ON
 D/BluetoothLeScanner: Stop Scan with callback
 D/ViewRootImpl@6a45722[MainActivity]: ViewPostIme pointer 0
 D/ViewRootImpl@6a45722[MainActivity]: ViewPostIme pointer 1
 D/AbsListView: onTouchUp() mTouchMode : 0
 D/SerialSocket: connect D0:B5:C2:95:12:7C
 D/SerialSocket: connectGatt,LE
 D/BluetoothAdapter: STATE_ON
 D/BluetoothGatt: connect() - device: D0:B5:C2:95:12:7C, auto: false
 D/BluetoothAdapter: isSecureModeEnabled
 D/BluetoothGatt: registerApp()
 D/BluetoothGatt: registerApp() - UUID=ec5de07c-7488-4183-b214-eaa25e98e8f2
 D/BluetoothGatt: onClientRegistered() - status=0 clientIf=12
 D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=12 device=D0:B5:C2:95:12:7C
 D/SerialSocket: connect status 0, discoverServices
 D/BluetoothGatt: discoverServices() - device: D0:B5:C2:95:12:7C
 D/BluetoothGatt: onConnectionUpdated() - Device=D0:B5:C2:95:12:7C interval=6 latency=0 timeout=500 status=0
 D/BluetoothGatt: onSearchComplete() = Device=D0:B5:C2:95:12:7C Status=0
 D/SerialSocket: servicesDiscovered, status 0
 D/SerialSocket: service cc254x uart
 D/SerialSocket: request max MTU
 D/BluetoothGatt: configureMTU() - device: D0:B5:C2:95:12:7C mtu: 512
 D/BluetoothGatt: onConnectionUpdated() - Device=D0:B5:C2:95:12:7C interval=39 latency=0 timeout=500 status=0
 D/BluetoothGatt: onConfigureMTU() - Device=D0:B5:C2:95:12:7C mtu=23 status=0
 D/SerialSocket: mtu size 23, status=0
 D/SerialSocket: payload size 20
 D/BluetoothGatt: setCharacteristicNotification() - uuid: 0000ffe1-0000-1000-8000-00805f9b34fb enable: true
 D/SerialSocket: enable read notification
 D/SerialSocket: writing read characteristic descriptor
 D/SerialSocket: writing read characteristic descriptor finished, status=0
 D/SerialSocket: connected
 D/SerialSocket: read, len=3,data:AT
 D/SerialSocket: read, len=17,data:0MyConnected,000
 D/BluetoothGatt: onConnectionUpdated() - Device=D0:B5:C2:95:12:7C interval=9 latency=0 timeout=100 status=0
 D/SerialSocket: read, len=17,data:0MyConnected,000
 D/SerialSocket: read, len=11,data:21,1,1,1,0
 D/SerialSocket: read, len=11,data:21,1,1,1,0
 D/SerialSocket: read, len=11,data:21,1,1,1,0


 

*참고:  Activity vs Fragment life cycle

https://developer88.tistory.com/69

 

Activity 와 Fragment 의 lifecycle (생명주기)

안드로이드는 에서 Activity와 Fragment의 lifecycle(생명주기)에 맞추어 개발을 하는 것이 매우 중요한데요. 오늘은 Activity와 Fragment의 생명주기에 관해서 정리해보겠습니다. 1. Activity 생명주기 먼저, Ac

developer88.tistory.com