Bluetooth unresponsive - please help!
Bluetooth unresponsive - please help!
- Subject: Bluetooth unresponsive - please help!
- From: Allan Third <email@hidden>
- Date: Fri, 08 May 2009 16:46:39 +0100
Hi,
Sorry if this is a newbie type of question but I've been banging my head
against a brick wall with this for ages. I've searched through the
archives thoroughly and I really can't find anything that seems to be
relevant - I have no doubt that it's something very very simple.
I'm trying to write an app which responds to incoming connections over
both Bluetooth and TCP/IP and engages in various kinds of chat with
clients on the other ends of both connections. So far, I'm receiving
events (NSStreamEventHasBytesAvailable, etc.) from the TCP connection
(based on TCPServer in the MiniSOAP example) and that seems to be fine.
The problem seems to be with the Bluetooth connection. I started out
with the code from RFCOMMServerSample, and adapted
ChatBluetoothServerInterface so that it publishes my own SDP record for
a new service (which works), and it registers my main object as the
delegate for the RFCOMM channel.
When a client connects, the delegate methods for receiving a remote
connection, RFCOMMOpenComplete, etc., get called successfully, I set up
my main object appropriately and send an init message over the RFCOMM
channel to the client - [mRFCOMMChannel writeSync:...] completes with
kIOReturnSuccess, so it looks like that message is being sent over the
right channel successfully. What I then expect to happen is the same as
for the TCP connection - the event handlers for new data should be
called as and when anything arrives over the connection and my own code
deciding what to do with the data should be called from the event
handlers. What in fact happens is nothing. My app isn't frozen - if I
start a TCP connection after the Bluetooth init has been sent, I still
receive those events and get the right NSLog messages. But no further
Bluetooth delegate messages are received - particularly, the new data
available callback never runs. I'm pretty sure that the client *is*
sending data - although I don't have access to its source, I'm sending
it exactly the same init messages that I send in Linux over Bluez, and
the client certainly seems to *think* it's got a connection to my
server, so I believe it will try to send the right messages back. But
I'm just not getting anything. The other RFCOMM delegate methods (which
I mostly implemented just to see if they ever happened) all get called
at least once when the new connection is made by the client, but never
again.
I've read in the archives that all Bluetooth access should be done in
the same thread. I'm not explicitly creating any separate threads, nor,
to the best of my knowledge, am I using anything like NSOperation which
creates threads in the background. But I have to say, I am thoroughly
confused about the structure of Cocoa apps so it is quite possible that
I'm doing something incredibly stupid that's causing the BT data-in
stuff never to be called.
I'd really appreciate anyone's help or advice over this. I tried to
include sample code but it made the message too long for the list. If
there's anything that it would help to see, just let me know and I'll
send it.
Thanks,
Allan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden