728x90
반응형
개요
라즈베리파이 (Raspberry Pi)에는 기본적으로 블루투스 칩이 내장되어 있어서, Central 및 Pheriperal 으로 동작이 가능합니다.
다음은 라즈베리파이 (Raspberry Pi) 모델별 블루투스 지원 내역입니다.
Pi Model | Bluetooth Chipset | Bluetooth Supported |
---|---|---|
Raspberry Pi 3 Model A+ | Broadcom BCM43438 | Bluetooth 4.1 |
Raspberry Pi 3 Model B | Broadcom BCM43438 | Bluetooth 4.1 |
Raspberry Pi Model 3B+ | Cypress CYW43455 | Bluetooth 4.2 |
Raspberry Pi 4 Model B | Cypress CYW43455 | Bluetooth 5.0 |
블루투스 장치 확인 및 활성화하기
기본적으로 "hciconfig" 명령을 이용하여 내장된 블루투스 장치를 확인할 수 있습니다.
# hciconfig
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:2B:EC:7C ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:3282 acl:46 sco:0 events:142 errors:0
TX bytes:3581 acl:44 sco:0 commands:95 errors:0
정상적인 경우에는 위와 같이 활성된 내중 블루투스 장치가 표시되나, 아무런 결과를 반환하지 않는 경우가 있습니다.
부팅시 블루투스 모듈이 정상적으로 활성화되어 로딩되었는지 확인합니다.
# dmesg | grep -i bluetooth
[ 153.212092] Bluetooth: Core ver 2.22
[ 153.212193] Bluetooth: HCI device and connection manager initialized
[ 153.212223] Bluetooth: HCI socket layer initialized
[ 153.212237] Bluetooth: L2CAP socket layer initialized
[ 153.212276] Bluetooth: SCO socket layer initialized
위 결과는 "hciconfig"에서 아무런 결과를 반환하지 않았을 경우에 대한 결과입니다. 블루투스 장치 연동에 필요한 모든 모듈이 로딩되지 않은 상태입니다.
다음은 "hciuart.service" 서비스 상태를 확인합니다.
# sudo systemctl status hciuart.service
● hciuart.service - Configure Bluetooth Modems connected by UART
Loaded: loaded (/lib/systemd/system/hciuart.service; disabled; vendor preset: enabled)
Active: inactive (dead)
위와 같이 "hciuart.service" 서비스가 비활성화 되어 있어서 내장 블루투스가 정상적으로 로딩되지 않았습니다.
"hciuart.service" 서비스를 다음과 같이 활성화합니다.
# sudo systemctl enable hciuart.service
Created symlink /etc/systemd/system/multi-user.target.wants/hciuart.service → /lib/systemd/system/hciuart.service.
# sudo systemctl start hciuart.service
# sudo systemctl status hciuart.service
● hciuart.service - Configure Bluetooth Modems connected by UART
Loaded: loaded (/lib/systemd/system/hciuart.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-07-31 11:39:19 KST; 1h 2min ago
Process: 1269 ExecStart=/usr/bin/btuart (code=exited, status=0/SUCCESS)
Main PID: 1295 (hciattach)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/hciuart.service
└─1295 /usr/bin/hciattach /dev/serial1 bcm43xx 921600 noflow - b8:27:eb:2b:ec:7c
7월 31 11:39:14 raspberrypi systemd[1]: Starting Configure Bluetooth Modems connected by UART...
7월 31 11:39:19 raspberrypi btuart[1269]: bcm43xx_init
7월 31 11:39:19 raspberrypi btuart[1269]: Flash firmware /lib/firmware/brcm/BCM43430A1.hcd
7월 31 11:39:19 raspberrypi btuart[1269]: Set BDADDR UART: b8:27:eb:2b:ec:7c
7월 31 11:39:19 raspberrypi btuart[1269]: Set Controller UART speed to 921600 bit/s
7월 31 11:39:19 raspberrypi btuart[1269]: Device setup complete
7월 31 11:39:19 raspberrypi systemd[1]: Started Configure Bluetooth Modems connected by UART.
이 후에 다시 블루투스 모듈 로딩여부를 확인해 보면 다음과 같이 필요한 모든 모듈이 로딩된 것을 확인할 수 있습니다.
$ dmesg | grep -i bluetooth
[ 153.212092] Bluetooth: Core ver 2.22
[ 153.212193] Bluetooth: HCI device and connection manager initialized
[ 153.212223] Bluetooth: HCI socket layer initialized
[ 153.212237] Bluetooth: L2CAP socket layer initialized
[ 153.212276] Bluetooth: SCO socket layer initialized
[ 1436.203479] Bluetooth: HCI UART driver ver 2.3
[ 1436.203499] Bluetooth: HCI UART protocol H4 registered
[ 1436.203597] Bluetooth: HCI UART protocol Three-wire (H5) registered
[ 1436.203815] Bluetooth: HCI UART protocol Broadcom registered
[ 1436.472109] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 1436.472119] Bluetooth: BNEP filters: protocol multicast
[ 1436.472135] Bluetooth: BNEP socket layer initialized
[ 1436.520901] Bluetooth: RFCOMM TTY layer initialized
[ 1436.520934] Bluetooth: RFCOMM socket layer initialized
[ 1436.520969] Bluetooth: RFCOMM ver 1.11
"hciuart.service" 서비스가 정상적으로 실행된 이후에는 "hciconfig" 명령이 정상적으로 수행됩니다.
"hcitool" 명령을 이용하여 간단하게 블루투스 장치를 검색해 볼 수 있습니다.
# hcitool scan
Scanning ...
A4:50:46:0E:84:02 POCOPHONE
참고자료
- "Control Bluetooth LE Devices From a Raspberry Pi":https://www.instructables.com/id/Control-Bluetooth-LE-Devices-From-A-Raspberry-Pi/
- "USING BLE DEVICES WITH A RASPBERRY PI":https://www.argenox.com/library/bluetooth-low-energy/using-raspberry-pi-ble/ ; 라즈베리파이에서 블루투스 사용을 위한 기초적인 설명 ; 최초 연결, 기타 설정 부분 등
- "[RaspberryPi3] 블루투스 사용하기 (Command line)":https://inmile.tistory.com/11 ; bluetoothctl 명령에 대한 간단한 사용법 소개
- "help with bluetooth (hcitool), RPI 3B+":https://www.raspberrypi.org/forums/viewtopic.php?t=222203
- "RaspberryPi - 라즈베리파이에서 블루투스 사용하기":https://sleep365.tistory.com/75
- "RPi Bluetooth LE":https://elinux.org/RPi_Bluetooth_LE
- "noble / node-bluetooth-hci-socket":https://github.com/noble/node-bluetooth-hci-socket ; Bluetooth HCI socket binding for Node.js
'Linux,Unix,BSD > RaspberryPI' 카테고리의 다른 글
[RPi] SD card 및 USB memory serial 정보 구하기 (0) | 2022.06.21 |
---|---|
[RPi] 무선 공유기 모드 설정하기(Routed Wireless Access Point) (0) | 2022.06.14 |
RPi - 라즈베리파이에서 파티션 자동 확장하기 (0) | 2022.06.11 |
[RPi] 고정(static) IP 설정하기 (0) | 2021.12.02 |
[RPi] 내장 와이파이(WiFi), 블루투스(Bluetooth) 장치 비활성화 (0) | 2021.06.29 |