蓝点工坊(http://www.bluedrum.cn) 创始人,App和嵌入式产品开发。同时也做相应培训和外包工作。 详细介绍 http://pan.baidu.com/s/1y2g88
全部博文(311)
分类: LINUX
2010-09-29 02:10:12
解压
./configure CFLAGS="-DOBEX_DEBUG=4 -DOBEX_DUMP=2" --enable-apps --enable-bluetooth BLUETOOTH_CFLAGS="-I/usr/local/lib" BLUETOOTH_LIBS="-L/usr/local/lib -lbluetooth"
#--enable-apps 是要生obex_test这个应用工具。
#CFLAGS="-DOBEX_DEBUG=4 -DOBEX_DUMP=2" 增加调试信息,如果觉得信息太多可以去掉这个选项。
编译 make
安装make install
这样会生成libopenobex和obex_打头一系列测试工具.
用which obex_test应该能看到在/usr/local/bin下面.
3.使用obexsend脚本
obex_test使用有一定麻烦性,所有有人开发了obex-send.sh来简单发送操作
下载 :
拷贝文件到/usr/local/bin下
cp obexsend.sh /usr/local/bin
二.向手机发送文件
-------------------------------------
关于用openObex收发文件过程参见.
1.联接蓝牙设备
hciconfig hci0 up
hcitool scan
hcitool cc
2.查找 蓝牙网络支持obex文件接收的设备
接收服务采用FTRN,而发送服务是OPUSH.这样手机支持FTRN服务,而LINUX支持OPUSH服务.
在本地增加所有服务
sdptool add --channel=1 DID SP DUN LAN FAX OPUSH FTP HS HF SAP NAP GN PANU HID CIP CTP A2SRC A2SNK SYNCML NOKID PCSUITE SR1
这里RHEL版的sdptool 搜索有一个奇怪的特性。直接用class名字(OPUSH/FTRN)是无法查找网络任何服务.必得用它的代号。其中OPUSH是 0x1105,FTP是0x1106
sdptool search 0x1106 #sdptool search FTRN
扫描到我的M8手机
[root@huisen apps]# sdptool search 0x1106
|
上述命令查找到 00:21:19:A4:E0:F1 ,它在channel 1支持FTP服务
扫描到我的乐Phone手机
[root@huisen apps]# sdptool search 0x1106 Class 0x1106 Inquiring ... Searching for 0x1106 on 00:0B:6B:F1:3B:1B ... Service Name: File Transfer Service Description: OBEX File Transfer Protocol Service RecHandle: 0x10002 Service Class ID List: "OBEX File Transfer" (0x1106) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 7 "OBEX" (0x0008) |
3.用obex_test 联接手机发送文件
注意它是采用rfcomm来传输文件的,因此rfcomm的配置必须要正确.
rfcomm bind /dev/rfcomm0 <远端地址> <远端通道>
rfcomm bind /dev/rfcomm0 00:0B:6B:F1:3B:1B 7
obex_test -b <远端接收手机> <远端channel>
其中-b表示采用蓝牙,否则默认是红外线,通道是7
obex_test -b 00:0B:6B:F1:3B:1B 7
4.查看远程目录列表
obexftp -b 00:0B:6B:F1:3B:1B -B 7 --list
Connecting..\done
Tried to connect for 717ms
Receiving "(null)"...|
done
Disconnecting../done
5.用obexftp发送文件
obexftp发送文件,要求对方一直可见。
obexftp -b 00:0B:6B:F1:3B:1B -B 7 -c apk -p /home/huisen/ks.jpg Connecting..\done Tried to connect for 719ms Sending "apk"...|done Sending "/home/huisen/ks.jpg"...|done Disconnecting../done |
sdptool search 0x1105 #查找OPUSH服务
sdptool search 0x1105 [root@huisen apps]# |
然后用如下命令来发送
obex_test -b 00:21:19:A4:E0:F1 9
进入obex_test 控制台后用c命令来联接手机,注意手机这边要及时确认接收,否则因超时而失败
[root@huisen apps]# obex_test -b 00:21:19:A4:E0:F1 1
Using Bluetooth RFCOMM transport
OBEX Interactive test client/server.
> c
BtOBEX_TransportConnect():
btobex_connect_request():
obex_create_socket():
btobex_connect_request(): transport mtu=1024
obex_object_setrsp():
obex_object_setcmd(): 00
obex_insert_connectframe():
obex_object_addheader():
obex_object_addheader(): Fit one packet!
obex_object_addheader(): BS header size 6
insert_byte_stream_header():
OBEX_Request():
obex_client():
obex_client(): STATE_START
obex_object_send():
obex_object_send(): Adding 4 bytes of non-headerdata
obex_object_send(): 4
obex_object_send(): Adding non-body header
obex_object_send(): Sending package with opcode 128
obex_data_request(): len = 16 bytes
obex_transport_write():
do_write(): sending 16 bytes
Made some progress...
OBEX_HandleInput():
obex_transport_handle_input():
obex_transport_handle_input(): Data available on client socket
obex_data_indication():
obex_transport_read(): Request to read max 3 bytes
obex_data_indication(): Got 3 bytes
obex_transport_read(): Request to read max 9 bytes
obex_data_indication(): Got 9 bytes msg len=12
Rx: A0 00 0C 10 00 04 00 CB 00 00 00 05
obex_client():
obex_client(): STATE_REC
obex_client(): We expect a connect-rsp
obex_parse_connect_header():
obex_parse_connect_header(): Len: 12
obex_parse_connect_header(): version=10
obex_parse_connect_header(): requested MTU=400, used MTU=400
obex_object_receive():
obex_object_receive(): Command has 4 bytes non-headerdata
obex_object_receive(): Header: cb
obex_object_receive(): Copying 4 bytes
obex_object_receive(): Pulling 5 bytes
obex_client(): Done! Rsp=20!
Server request finished!
server_done() Command (00) has now finished
obex_object_delete():
free_headerq():
free_headerq():
free_headerq():
OBEX_HandleInput():
obex_transport_handle_input():
Timeout waiting for data. Aborting
三.蓝牙扩展测试
----------------------------
ObexFTP移植
下载
生成Makefile
./configure --enable-bluetooth --disable-tcl --disable-swig --disable-perl --disable-python --disable-ruby BLUETOOTH_CFLAGS="-I/usr/local/lib" BLUETOOTH_LIBS="-L/usr/local/lib -lbluetooth" OPENOBEX_CFLAGS="-I/usr/local/include" OPENOBEX_LIBS="-L/usr/local/lib -lopenobex"
编译 make
安装 make install
它主要生成libobexftp和obexftp这个应用程序
Obexd的移植
scr2012-04-13 14:36:27
To teaco77:
出錯:
checking for USB... yes
checking for /tmp1/libs/lib/pkgconfig/libusb.pc... configure: error: cannot check for file existence when cross compiling
直接在./configure去mark
line 12346~12363
或是
修改./acinclude.m4(下載openobex-libusb-check.patch看到)
# AC_CHECK_FILE(${prefix}/lib/pkgconfig/libusb.pc, REQUIRES="libusb")