Skip to content

Instantly share code, notes, and snippets.

@microwave
Last active July 25, 2016 07:30
Show Gist options
  • Save microwave/22f8500b37f91cf2ed4d to your computer and use it in GitHub Desktop.
Save microwave/22f8500b37f91cf2ed4d to your computer and use it in GitHub Desktop.
Raspberry Pi에서 bluetooth 장치 사용하기
1.먼저 bluetooth를 사용하기 위한 소프트웨어를 설치한다.
sudo apt-get update
sudo apt-get install bluetooth bluez-utils blueman
lsusb로 USB에 연결된 bluetooth 동글이 잘 인식되는지 확인하고.
hcitool scan으로 검색된 블루투스 장비들을 확인한다.
이제 준비완료.
2. 페어링(pairing)
x-windows에서 blueman GUI를 사용한 페어링은 잘 안된다.
GUI가 나오지 않는다! (에러메시지는 생략하고. 나중에 붙여넣어야지.)
그래서 커맨드라인에서 페어링하고 다른 응용프로그램에서 연결해서 사용한다.
- dbus 활성화
sudo update-rc.d -f dbus defaults
- 재부팅
sudo reboot
- bluetooth장비 확인
lsusb
hcitool scan
이 때 검색된 장비의 hardware address를 잘 적어둔다.
- pairing
sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX
여기에서 PIN을 물어본다.
사실 여기까지만 진행하면 다른 앱에서 연결해서 사용할 수 있다.
pin번호 입력까지 자동으로 하도록 스크립트 만들어둬도 될 듯. 옵션이 있나?
내가 연결하고자하는 장치의 PIN은 대부분 0000 아니면 1234라...
- 그리고 신뢰하는 장치로 추가 (사실 이 단계는 하지 않아도 됨.)
bluez-test-device trusted XX:XX:XX:XX:XX:XX yes
3. 연결(connect)
- 커맨드라인에서 연결
bluez-test-XXXX 명령어로 연결.
bluez-test-input connect XX:XX:XX:XX:XX:XX
- node js에서 serial 통신
https://github.com/eelcocramer/node-bluetooth-serial-port
참고.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment