Android到蓝牙设备(WT-11)通信/连接

时间:2011-10-05 05:41:44

标签: android bluetooth rfcomm

所以我们有一个Android应用程序应该与Bluegiga WT-11蓝牙模块配对,然后在服务器套接字上侦听来自设备的连接。我们使用SPP和RFCOMM与“众所周知的”UUID 00001101-0000-1000-8000-00805F9B34FB进行通信。配对工作正常,但接受服务器套接字上的连接(使用listenUsingRfcommWithServiceRecord()创建,然后等待accept())无法正常工作。它在某些时候确实有效,但有时会停止工作,或者在其他时间间歇工作。

最令人困惑的是,手机似乎正在从设备获取连接,向LogCat吐出几行,然后完全忽略连接;设备认为连接失败,应用程序永远不会在accept()上获得任何连接。

这是LogCat,当手机(Galaxy S II)获得连接但没有对它做任何事情时(我现在在几部手机上试过这个,如果你需要来自其他手机或日志的日志,请告诉我来自成功的联系):

10-05 05:13:14.255: DEBUG/(3341): >>> START GKI_timer_update(), wake_lock_count:3
10-05 05:13:14.255: DEBUG/(3341): >>> RESTARTED GKI_timer_update(): run_cond: 1
10-05 05:13:14.430: WARN/(3341): info:x10
10-05 05:13:14.430: INFO/DTUN_CLNT(3492): dtun-rx signal [DTUN_SIG_DM_LINK_UP] (id 51) len 12
10-05 05:13:14.430: DEBUG/DTUN_HCID4(3492):         dtun_dm_sig_link_up()
10-05 05:13:14.430: INFO/DTUN_HCID4(3492): dtun_dm_sig_link_up: dummy_handle = 375
10-05 05:13:14.435: ERROR/BluetoothEventLoop.cpp(2785): event_filter: Received signal     org.bluez.Device:PropertyChanged from /org/bluez/3492/hci0/dev_00_07_80_4D_B8_E7
10-05 05:13:14.445: INFO//system/bin/btld(3339): send_ctrl_msg: [BTL_IFS CTRL] send     BTLIF_DTUN_SIGNAL_EVT (CTRL) 10 pbytes (hdl 28)
10-05 05:13:14.530: WARN/(3341): amp_find_llcb_by_cid search for CID:0x0040 entry LCID:0x0000 in use 0 CID:0x0001
10-05 05:13:14.910: WARN/(3341): BTA_DM_LINK_DOWN_EVT::bdaddr 00:07:80:4d:b8:e7 reason x13
10-05 05:13:14.910: INFO/DTUN_CLNT(3492): dtun-rx signal [DTUN_SIG_DM_LINK_DOWN] (id 49) len 13
10-05 05:13:14.910: DEBUG/DTUN_HCID4(3492):         dtun_dm_sig_link_down()
10-05 05:13:14.910: INFO/DTUN_HCID4(3492): dtun_dm_sig_link_down device = 0x11c18  handle = 375 reason = 19
10-05 05:13:14.915: ERROR/BluetoothEventLoop.cpp(2785): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/3492/hci0/dev_00_07_80_4D_B8_E7
10-05 05:13:14.915: INFO//system/bin/btld(3339): send_ctrl_msg: [BTL_IFS CTRL] send BTLIF_DTUN_SIGNAL_EVT (CTRL) 11 pbytes (hdl 28)
10-05 05:13:14.930: INFO/BluetoothHIDService(2785): Received intent Intent { act=android.bluetooth.device.action.ACL_DISCONNECTED (has extras) }, device = 00:07:80:4D:B8:E7
10-05 05:13:14.930: INFO/BluetoothHIDService(2785):     ...ACL disconnected
10-05 05:13:15.865: DEBUG/BatteryService(2785): update start
10-05 05:13:15.870: ERROR/BatteryService(2785): TMU status = 0
10-05 05:13:15.870: DEBUG/BatteryService(2785): updateBattery level:97 scale:100 status:2 health:2 present:true voltage: 4176 temperature: 270 technology: Li-ion AC powered:false USB powered:true icon:17302229
10-05 05:13:15.895: INFO/StatusBarPolicy(2903): BAT. S:2 H:2
10-05 05:13:16.165: DEBUG/(3341): >>> STOP GKI_timer_update(), wake_lock_count:2
10-05 05:13:16.165: DEBUG/(3341): >>> SUSPENDED GKI_timer_update()

@WBAN你能帮忙解决这个问题吗?我看到你做了类似的事情。

非常感谢任何帮助!

谢谢!

0 个答案:

没有答案