Hello,

I've possibly just experienced success with SPP on the HTC Desire
here, and I wondered if it's worth reporting.

Bear with me here, but I am very new to phone application and Android
development (I only just started this weekend) and even Java is new to
me (though I am used to using other languages). This is my very first
post to this mailing list.

I have got a HTC Desire and I wish to create an application that
communicates with a piece of hardware that I have constructed myself,
which incorporates a CSR Bluecore-based Bluetooth module. The
objective is to create an app that can control the hardware over
Bluetooth SPP. I am doing my testing with a Bluetooth module that sits
on a development PCB, and I'm communicating with its UART lines via
HyperTerminal (the module can be controlled using modem-like AT
commands, so I can tell it to make a connection using ATD<BT_ADDR>,
and that kind of thing). So the little goal for this weekend was to
exchange characters from Hyperterminal, via the RS232 connection and
the Bluetooth module, to my Desire.

I set up and ran BluetoothChat (API 7, Android 2.1-update1) from
Eclipse using my Desire as the target. I found I could pair
BluetoothChat with my module, but attempting to connect would fail
whether I tried to initiate the connection from the Desire or from the
module itself. I did a quick bit of Googling and my heart plummeted
when I read these posts that I found about SPP not working.

Anyway, I changed the UUID to the value that DonFrench recommended, so
that I now have the line:

private static final UUID MY_UUID =
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

Now, I'm able to connect, and I'm happily exchanging characters
between the Chat application and Hyperterminal. The only issue I have
seen so far is that sometimes the connection dies when I go away from
it for a few minutes  - perhaps this is due to a timeout event;
hopefully I'll understand why as I learn more.

I only have a limited understanding of UUIDs. I know that SPP is 1101.
I also did a project a few years ago that involved making a device
that communicated with a vast array of mobile phones; I found that
99.9% of phones wouldn't accept connections to 1101 and I had to make
my Bluetooth module specify a UUID of 1103 (DUN, if I remember right).
Most phones would accept this, allow me to connect, and let me
communicate with the phone (and access its SMS, contacts, etc.) using
serial AT commands as normal. Anyway, I digress. The point is that I
understand why the "1101" is there in DonFrench's UUID string; I
recognise that as SPP. What I don't understand is why the original
example code contained a UUID that's nothing like 1101. Perhaps I need
to have a good read of RFC4122...

Anyway, if there's any comments anyone has about what I've reported
here, or if there's any more information I can let you guys know (e.g.
any firmware numbers from my phone, etc.) please shout.

Last but not least, massive thanks to DonFrench.

Trev



On May 29, 1:03 am, DonFrench <dcfre...@gmail.com> wrote:
> I notice that the UUID you are using differs slightly from the one in
> the final line of the log, where it says onUuidChanged.  Could you be
> using the wrong UUID?
>
> On May 28, 2:10 pm, Robert Armstrong <rarmstrong...@googlemail.com>
> wrote:
>
> > I managed to transfer a file from the host PC to theHTCDesireusing
> > Bluetooth - see Word document supplied 
> > here:-http://forum.vodafone.co.uk/topic/58936-htc-desire-unable-to-send-fil...
>
> > I have also tried the SDK supplied BluetoothChat example App.
>
> > But with UUI changed to:-
> >     private static final UUID MY_UUID =
> > UUID.fromString("00001124-0000-1000-8000-00805F9B34FB"); // HID class
>
> > And get a similar failure to last posting. When I click on "Menu->Connect a 
> > Device", after a short delay, I hit a breakpoint at:-
>
> > ...
> >                 mmSocket.connect();
> >             } catch (IOException e) {
> >                 connectionFailed();                          ***
> > breakpoint hit on this line
> > ...
>
> > The logCat trace shows:-
> > 05-28 21:59:00.750: ERROR/BluetoothEventLoop.cpp(75): pollData[0] is
> > revented, check next one
> > 05-28 21:59:00.760: ERROR/BluetoothService.cpp(75):
> > stopDiscoveryNative: D-Bus error in StopDiscovery:
> > org.bluez.Error.Failed (Invalid discovery session)
> > 05-28 21:59:00.770: DEBUG/BluetoothChat(1385): onActivityResult -1
> > 05-28 21:59:00.780: DEBUG/BluetoothChatService(1385): connect to:
> > 00:1B:FB:CE:61:EF
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_socket: fam
> > 31, type 1, prot BTPROTO_RFCOMM
> > 05-28 21:59:00.780: DEBUG/BTL_IFC_WRP(1385): wrp_wsock_create: BTS
> > 05-28 21:59:00.780: DEBUG/BTL_IFC_WRP(1385): wrp_alloc_new_sock:
> > wrp_alloc_new_sock sub 15
> > 05-28 21:59:00.780: DEBUG/BTL_IFC_WRP(1385): wrp_wsock_create: 49
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): btsk_alloc_add: success
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): btsk_dump_list:  fd
> > (35:35), bta 0, rc 1, wflags 0x8
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_socket: return
> > 49
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > fd (-1:49), bta -1, rc 0, wflags 0x0
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > configure rfcomm lm mode 0x26, (master:0, auth 1, enc 1)
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > success
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > fd (-1:49), bta -1, rc 0, wflags 0x0
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > configure rfcomm sndbuf len 71680 bytes
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_setsockopt:
> > success
> > 05-28 21:59:00.780: DEBUG/ASOCKWRP(1385): asocket_init
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: s 49,
> > cmd 3
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): blz20_wrp_fcntl:  fd
> > (-1:49), bta -1, rc 0, wflags 0x0
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: s 49,
> > cmd 4
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): blz20_wrp_fcntl:  fd
> > (-1:49), bta -1, rc 0, wflags 0x0
> > 05-28 21:59:00.780: DEBUG/BLZ20_WRAPPER(1385): blz20_wrp_fcntl:
> > transparant fcntl
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: s 53,
> > cmd 3
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: wsock
> > not found, pass through transparantly
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: s 53,
> > cmd 4
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_wrp_fcntl: wsock
> > not found, pass through transparantly
> > 05-28 21:59:00.780: INFO/BLZ20_WRAPPER(1385): blz20_set_asocket:
> > success (49,52,53)
> > 05-28 21:59:00.780: DEBUG/BluetoothChatService(1385): setState() 1 ->
> > 2
> > 05-28 21:59:00.780: ERROR/BluetoothChat(1385): + ON RESUME +
> > 05-28 21:59:00.790: INFO/BluetoothChatService(1385): BEGIN
> > mConnectThread
> > 05-28 21:59:00.790: ERROR/BluetoothEventLoop.cpp(75): pollData[0] is
> > revented, check next one
> > 05-28 21:59:00.790: ERROR/BluetoothService.cpp(75):
> > stopDiscoveryNative: D-Bus error in StopDiscovery:
> > org.bluez.Error.Failed (Invalid discovery session)
> > 05-28 21:59:00.790: DEBUG/DEVICE(295): BLTA -
> > *************DiscoverServices********
> > 05-28 21:59:00.790: INFO/DTUN_HCID_BZ4(295):
> > dtun_client_get_remote_svc_channel: starting discovery on
> > (uuid16=0x0035)
> > 05-28 21:59:00.790: INFO/DTUN_HCID_BZ4(295):    bdaddr=00:1B:FB:CE:
> > 61:EF
> > 05-28 21:59:00.790: INFO/DTUN_CLNT(295):     Client calling
> > DTUN_METHOD_DM_GET_REMOTE_SERVICE_CHANNEL (id 4)
> > 05-28 21:59:00.790: INFO/(259): DTUN_ReceiveCtrlMsg: [DTUN] Received
> > message [BTLIF_DTUN_METHOD_CALL] 4354
> > 05-28 21:59:00.790: INFO/(259): handle_method_call:
> > handle_method_call :: received
> > DTUN_METHOD_DM_GET_REMOTE_SERVICE_CHANNEL (id 4), len 134
> > 05-28 21:59:00.790: ERROR/BTLD(259): ****************search UUID =
> > 1124***********
> > 05-28 21:59:00.790: INFO//system/bin/btld(254):
> > btapp_dm_GetRemoteServiceChannel()
> > 05-28 21:59:00.790: INFO//system/bin/btld(254): ##### USerial_Ioctl:
> > BT_Wake, 0x8003 ####
> > 05-28 21:59:00.830: INFO/BluetoothChat(1385): MESSAGE_STATE_CHANGE: 2
> > 05-28 21:59:01.350: WARN/BTLD(259): ccb timer ticks: 2147483648
> > 05-28 21:59:01.350: WARN/BTLD(259): info:x0
> > 05-28 21:59:01.350: INFO/BTL-IFS(259): send_ctrl_msg: [BTL_IFS CTRL]
> > send BTLIF_DTUN_SIGNAL_EVT (CTRL) 10 pbytes (hdl 14)
> > 05-28 21:59:01.350: DEBUG/DTUN_HCID_BZ4(295):
> > dtun_dm_sig_link_up()
> > 05-28 21:59:01.350: INFO/DTUN_HCID_BZ4(295): dtun_dm_sig_link_up:
> > dummy_handle = 280
> > 05-28 21:59:01.350: DEBUG/ADAPTER(295): adapter_get_device(00:1B:FB:CE:
> > 61:EF)
> > 05-28 21:59:01.350: ERROR/BluetoothEventLoop.cpp(75): pollData[0] is
> > revented, check next one
> > 05-28 21:59:01.350: ERROR/BluetoothEventLoop.cpp(75): event_filter:
> > Received signal org.bluez.Device:PropertyChanged from /org/bluez/295/
> > hci0/dev_00_1B_FB_CE_61_EF
> > 05-28 21:59:01.610: WARN/BTLD(259): process_service_search_attr_rsp
> > 05-28 21:59:01.650: INFO/BTL-IFS(259): send_ctrl_msg: [BTL_IFS CTRL]
> > send BTLIF_DTUN_SIGNAL_EVT (CTRL) 13 pbytes (hdl 14)
> > 05-28 21:59:01.650: INFO/DTUN_HCID_BZ4(295):
> > dtun_dm_sig_rmt_service_channel: success=0, service=00000000
> > 05-28 21:59:01.650: ERROR/DTUN_HCID_BZ4(295): discovery unsuccessful!
> > 05-28 21:59:02.204: INFO//system/bin/btld(254): ##### USerial_Ioctl:
> > BT_Sleep, 0x8004 ####
> > 05-28 21:59:03.210: INFO//system/bin/btld(254): ##### USerial_Ioctl:
> > BT_Wake, 0x8003 ####
> > 05-28 21:59:03.300: INFO/BTL-IFS(259): send_ctrl_msg: [BTL_IFS CTRL]
> > send BTLIF_DTUN_SIGNAL_EVT (CTRL) 11 pbytes (hdl 14)
> > 05-28 21:59:03.300: DEBUG/DTUN_HCID_BZ4(295):
> > dtun_dm_sig_link_down()
> > 05-28 21:59:03.300: INFO/DTUN_HCID_BZ4(295): dtun_dm_sig_link_down
> > device = 0xf4e0 handle = 280 reason = 22
> > 05-28 21:59:03.300: ERROR/BluetoothEventLoop.cpp(75): pollData[0] is
> > revented, check next one
> > 05-28 21:59:03.300: ERROR/BluetoothEventLoop.cpp(75): event_filter:
> > Received signal org.bluez.Device:PropertyChanged from /org/bluez/295/
> > hci0/dev_00_1B_FB_CE_61_EF
> > 05-28 21:59:03.310: DEBUG/BluetoothA2dpService(75): Received intent
> > Intent { act=android.bluetooth.device.action.ACL_DISCONNECTED (has
> > extras) }
> > 05-28 21:59:03.813: INFO//system/bin/btld(254): ##### USerial_Ioctl:
> > BT_Sleep, 0x8004 ####
> > 05-28 21:59:04.810: INFO/BatteryStatsImpl(75):
> > notePhoneSignalStrengthLocked: 3->4
> > 05-28 21:59:06.801: DEBUG/BluetoothService(75): Cleaning up failed
> > UUID channel lookup: 00:1B:FB:CE:61:EF
> > 00001124-0000-1000-8000-00805f9b34fb
> > 05-28 21:59:06.810: VERBOSE/BluetoothEventRedirector(176): Received
> > android.bleutooth.device.action.UUID
> > 05-28 21:59:06.820: DEBUG/CachedBluetoothDevice(176): updating
> > profiles for <THEHOSTPC>
> > 05-28 21:59:06.820: VERBOSE/CachedBluetoothDevice(176): a2dp
> > classbits != uuid
> > 05-28 21:59:06.820: VERBOSE/CachedBluetoothDevice(176): opp classbits !
> > = uuid
> > 05-28 21:59:06.820: VERBOSE/CachedBluetoothDevice(176): Class: 1c010c
> > 05-28 21:59:06.820: VERBOSE/CachedBluetoothDevice(176): UUID:
> > 05-28 21:59:06.820: VERBOSE/CachedBluetoothDevice(176):
> > 0000110b-0000-1000-8000-00805f9b34fb
> > 05-28 21:59:06.820: ERROR/CachedBluetoothDevice(176): onUuidChanged:
> > Time since last connect4170521
>
> > Any help would be much appreciated.
>
> > Rab

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to