Develop Note

[RaspberryPi3] 블루투스 사용하기 (Command line) 본문

개발 (Ko)/Raspberry Pi

[RaspberryPi3] 블루투스 사용하기 (Command line)

Chalsu 2017. 10. 28. 16:37

라즈베리파이3 (model B)에는 블루투스가 내장되어 사용이 가능하다.


bluetoothctl 명령을 사용해 다른 블루투스 기기를 스캔/페어링/연결해 본다.

핸드폰(갤럭시S7)을 사용해 연결 테스트를 진행했다.


* 보안 문제로 mac 주소 일부는 XX..XX로 표현하였다.


// 블루투스 컨트롤 시작 $ sudo bluetoothctl

[NEW] Controller B8:27:XX:XX:XX:XX raspberrypi [default] [bluetooth]# power on Changing power on succeeded // 주변 블루투스 기기 스캔 [bluetooth]# scan on Discovery started [CHG] Controller B8:27:XX:XX:XX:XX Discovering: yes [NEW] Device E4:XX:XX:XX:XX:XX Samsung Galaxy S7


// agent 등록 [bluetooth]# agent on Agent registered // 장치 페어링(Paring)

// 페어링 시 핸드폰에서 연결을 수락해야 한다. [bluetooth]# pair E4:XX:XX:XX:XX:XX Attempting to pair with E4:XX:XX:XX:XX:XX [CHG] Device E4:XX:XX:XX:XX:XX Connected: yes Request confirmation [agent] Confirm passkey 414317 (yes/no): yes [CHG] Device E4:XX:XX:XX:XX:XX Modalias: bluetooth:v0075p0100d0200 [CHG] Device E4:XX:XX:XX:XX:XX UUIDs: ... [CHG] Device E4:XX:XX:XX:XX:XX Paired: yes Pairing successful [CHG] Device E4:XX:XX:XX:XX:XX Connected: no // 신뢰하는 장치로 설정 [bluetooth]# trust E4:XX:XX:XX:XX:XX [CHG] Device E4:XX:XX:XX:XX:XX Trusted: yes Changing E4:XX:XX:XX:XX:XX trust succeeded // 장치 연결 [bluetooth]# connect E4:XX:XX:XX:XX:XX Attempting to connect to E4:XX:XX:XX:XX:XX [CHG] Device E4:XX:XX:XX:XX:XX Connected: yes Connection successful


라즈베리파이3 - 핸드폰 간의 장치 연결이 성립되면 간단한 파일 전송 테스트를 진행해 본다.



Comments