2014년 2월 4일 화요일

[Mango-DSC-Board] Linux BlueTooth SPP 테스트 방법



Linux BlueTooth SPP 테스트 방법 § Mango24 공부방전체공개2014.02.04 22:23
답변 0 
조회 18
추천0

Buildroot에서 bluez-utils가 되어 있는지 확인 하고, 안되어 있으면, 체크하고 다시 컴파일 해줍니다.

$ make menuconfig
Package Selection for the target ---> Networking applications --->

kernel소스에서 bluetooth관련 프로토콜이 되어 있는지 확인 하고, 안되어 있으면, 체크 하고 다시 컴파일 해줍니다.
[*] Networking support ---> <*> Bluetooth subsystem support --->
Bluetooth device drivers --->


부팅시 bt 드라이버를 올려주는지 확인!!! 없으면 수동으로 해주거나, 아래 파일 수정해서 재부팅 하면 됩니다.

# vi /etc/init.d/S39marvell
#!/bin/sh
#
# load marvell wifi ....
#

case "$1" in
start)
echo "Loading marvell SD8787 wifi/BT driver"
insmod /root/mlan.ko
insmod /root/sd8787.ko
insmod /root/mbtchar.ko
insmod /root/bt8787.ko
;;
stop)
echo -n "unloading marvell SD8787 wifi/BT..."
rmmod /root/sd8787.ko
rmmod /root/mlan.ko
rmmod /root/bt8787.ko
rmmod /root/mbtchar.ko
;;
restart|reload)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit $?





rfcomm.conf 파일을 수정합니다. device는 target 장치(핸드폰)의 블루투스 어드레스를 입력하시면 됩니다.
# vi /etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#

rfcomm0 {
# Automatically bind the device at startup
bind no;

# Bluetooth address of the device
device 11:22:33:44:55:66;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "Example Bluetooth device";
}

부팅 이후, 아래 명령을 차례대로 실행합니다.

# hciconfig hci0 up
# hciconfig hci0 piscan (이 녀석이 search가능하도록 하게 하는 놈입니다.)
# sdptool add --channel=1 SP (SPP 가능 하도록 설정)
Serial Port service registered
# rfcomm listen 0 1&
# Waiting for connection on channel 1

꼭 백그라운드로 돌려야 합니다.





























안드로이드 어플 [ Bluetooth spp pro ] 파일을 이용해서 테스트 하시면 됩니다.
다른 bluetooth관련 어플은 연결이 되지 않습니다.

해당 장비가 Search가 되는 것을 확인 할 수 있습니다. 이것은 위에서 Search가능하도록 해주었기 때문에 가능합니다. 아니면, 검색조차 되지 않습니다.


사용가능한 Profile에 대한 UUID입니다. 자세한 사항은 Bluetooth uuid검색해서 참조 하시면 됩니다. 안드로이드에서 공용으로 사용되는 것입니다. Connect를 눌러서 연결은 합니다.
어떤 것으로 테스트해도 가능 하지만, Byte Stream mode가 터미널 창 같이 실시간으로 주고 받을수 있습니다.






실행이 되면, 아래와 같은 창이 뜹니다.







DSC 보드에서 확인해 보면, 블루투스가 연결이 되면, 아래와 같이 로그가 나옵니다.

Connection from 6C:83:36:9A:66:EB to /dev/rfcomm0
Press CTRL-C for hangup


보드의 터미널 창에서 아래와 같은 명령으로 송수신을 확인 할 수 있습니다.
# cat /dev/rfcomm0 &
# echo asdfasd > /dev/rfcomm0



안드로이드 어플에서도, 아래와 같이 확인 할 수 있습니다.
1번은 Tx 데이터 이고, 2번은 Rx데이터 입니다.

기타 bluez관련 명령어.

SP(Serial Port)가 가능한 장비 찾는 방법
# sdptool search SP
Inquiring ...
Searching for SP on 6C:83:36:9A:66:EB ...
Service Name: BluetoothChat
Service RecHandle: 0x10009
Service Class ID List:
UUID 128: 00001101-0000-1000-8000-00805f9b34fb
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 17

해당 장비의 가능한 Profile 찾는 방법
# sdptool browser 00:22:58:6E:8B:95
Browsing 00:22:58:6E:8B:95 ...
Service Name: Headset Audio Gateway
Service RecHandle: 0x10000
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 12
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0102

Service Name: Hands-Free Audio Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 13
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105

Service Name: Audio Source
Service RecHandle: 0x10002
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x102
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0102

Service Name: AVRCP TG
Service RecHandle: 0x10003
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x103
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0103

Service Name: AVRCP CT
Service RecHandle: 0x10004
Service Class ID List:
"AV Remote" (0x110e)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x103
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0100

Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10005
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100

댓글 없음:

댓글 쓰기