3

我在使用 android 2.3.6 的三星 Galaxy Note 上遇到蓝牙 SPP 问题 - 它可以工作一段时间,但突然连接被终止 - 在其他手机上可以连续工作。这里是它发生的日志部分

D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 43 bytes out of 43 on fd 46
D/BLZ20_ASOCKWRP(11288): asocket_write
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLOUT ] (0x4)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_write: wrote 10 bytes out of 10 on fd 46
I//system/bin/btld(11351): btlif_bts_api_data_cb: btlif_bts_api_data_cb : hdl 35, len 10
I//system/bin/btld(11351): bts_alloc_buf: hdr:0x405241a4, max 1712, offset 20, len 0 
I//system/bin/btld(11351): bts_alloc_buf: peer mtu 127
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_WRITE_EVT
I//system/bin/btld(11351): rfc_setup_rx_buf: pushed in queue p_buf #0: 0x405241a4, len:0, offset:20
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I/BluetoothPolicyService( 2767): getBluetoothDataTransferAllowed 
D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 9 bytes out of 9 on fd 46
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I/BluetoothPolicyService( 2767): getBluetoothDataTransferAllowed 
D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 67 bytes out of 67 on fd 46
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I/BluetoothPolicyService( 2767): getBluetoothDataTransferAllowed 
D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 69 bytes out of 69 on fd 46
D/BLZ20_ASOCKWRP(11288): asocket_write
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLOUT ] (0x4)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_write: wrote 10 bytes out of 10 on fd 46
I//system/bin/btld(11351): btlif_bts_api_data_cb: btlif_bts_api_data_cb : hdl 35, len 10
I//system/bin/btld(11351): bts_alloc_buf: hdr:0x405370b0, max 1712, offset 20, len 0 
I//system/bin/btld(11351): bts_alloc_buf: peer mtu 127
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_WRITE_EVT
I//system/bin/btld(11351): rfc_setup_rx_buf: pushed in queue p_buf #0: 0x405370b0, len:0, offset:20
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I/BluetoothPolicyService( 2767): getBluetoothDataTransferAllowed 
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 65 bytes out of 65 on fd 46
I/BluetoothPolicyService( 2767): getBluetoothDataTransferAllowed 
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
I//system/bin/btld(11351): jw_if_rfcomm_cl_cback: jw_if_rfcomm_cl_cback event=BTA_JV_RFCOMM_DATA_IND_EVT
I//system/bin/btld(11351): jv_forward_data_to_jni: BTA_JV_RFCOMM_DATA_IND_EVT bta hdl 2
D/BLZ20_ASOCKWRP(11288): asocket_read
I/BLZ20_WRAPPER(11288): blz20_wrp_poll: nfds 2, timeout -1 ms
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: transp poll : (fd 46) returned r_ev [POLLIN ] (0x1)
D/BLZ20_WRAPPER(11288): blz20_wrp_poll: return 1
D/BLZ20_WRAPPER(11288): blz20_wrp_read: read 0 bytes out of 0 on fd 46
I/BLZ20_WRAPPER(11288): blz20_wrp_read: connection aborted
D/BLZ20_WRAPPER(11288): blz20_wrp_read: set errno 103 (Software caused connection abort) l.1910 
D/BLZ20_ASOCKWRP(11288): asocket_abort [46,47,48]
I/BLZ20_WRAPPER(11288): blz20_wrp_shutdown: s 46, how 2
D/BLZ20_WRAPPER(11288): blz20_wrp_shutdown:  fd (-1:46), bta 2, rc 1, wflags 0x800, cflags 0x0, port 9050
I/BLZ20_WRAPPER(11288): blz20_wrp_shutdown: shutdown socket
D/BLZ20_WRAPPER(11288): blz20_wrp_write: wrote 1 bytes out of 1 on fd 48
D/BLZ20_ASOCKWRP(11288): asocket_destroy
D/BLZ20_ASOCKWRP(11288): asocket_abort [46,47,48]
I/BLZ20_WRAPPER(11288): blz20_wrp_shutdown: s 46, how 2
D/BLZ20_WRAPPER(11288): blz20_wrp_shutdown:  fd (-1:46), bta 2, rc 1, wflags 0x800, cflags 0x0, port 9050
I/BLZ20_WRAPPER(11288): blz20_wrp_shutdown: shutdown socket
D/BLZ20_WRAPPER(11288): blz20_wrp_write: wrote 1 bytes out of 1 on fd 48
I/BLZ20_WRAPPER(11288): blz20_wrp_close: s 48
D/BLZ20_WRAPPER(11288): blz20_wrp_close: std close (48)
I/BLZ20_WRAPPER(11288): blz20_wrp_close: s 47
D/BLZ20_WRAPPER(11288): blz20_wrp_close: std close (47)
I/BLZ20_WRAPPER(11288): blz20_wrp_close: s 46
D/BLZ20_WRAPPER(11288): blz20_wrp_close:  fd (-1:46), bta 2, rc 1, wflags 0x800, cflags 0x0, port 9050
4

2 回答 2

4

问题是我经常在没有可用数据的情况下进行后续的读取调用。虽然这在大多数手机上运行良好( read 只返回 0 bytes read ) - 这在某些三星手机上失败 - 一种解决方案是通过 available() 检查在读取之前是否有实际可用的数据。

于 2012-05-15T08:03:22.073 回答
0

我偶然发现的更多细节。这似乎与三星 BT 堆栈生成的垃圾邮件数量有关。我有一个每秒生成约 10.5k 数据的 BT 设备。当连接到有此问题的三星设备时,我每秒只能获得大约 3k 的数据。最终堆栈崩溃了。我知道在 android 设备上进行日志记录很昂贵,并且按照 ligi 的建议进行操作会减少堆栈生成的消息量;我认为这是根本原因。

就我而言,用 a 包装我正在读取的流BufferedInputStream似乎已经解决了问题,并使我回到 10.5 k/s。

于 2012-06-18T05:00:13.763 回答