[android-developers] Re: Can't connect to SPP device

2010-03-25 Thread philDev
For everybody interested, I posted this question at Stackoverflow and
for the office Hours:

http://stackoverflow.com/questions/2519449/spp-socket-createrfcommsockettoservicerecord-will-not-connect

So if there is going to be a solution, I'm going to post it above.

Thank you

PhilDev

On Mar 24, 11:47 am, Gavin reason...@gmail.com wrote:
 Gui gui.ouellet at gmail.com writes:





  Hi, I currently run android 1.5 on a HTC magic. I'm trying to
  communicate from my phone to abluetoothdevice that supports SPP. I
  can't seem to be able to connect to the device. I have tryed two ways
  to connect:
  1- via the official 2.0 API using the backport-android to make it work
  on android 1.5
  2- via the unofficialbluetoothapi 0.3

  Both method give me an error around the same connection process.

  With API 2.0, I can discover devices and pair with them. Then i create
  a socket which seems to work, but when I use the .connect() method, I
  get this error in CatLog:    IOException Unable to start Service
  Discovery. This is related to doSdp() in public class
  BluetoothSocket.

 Hi,

 I have encounter the same problem (IOException: Unable to start Service) using
 the backport-android on my HTC Hero.
 I want to ask if you have solved the problem? If yes, could you share the way?
 Thanks.

 Gavin

-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-developers] Re: Android Bluetooth Development - Problem connecting

2010-03-20 Thread philDev
push

On Mar 17, 7:23 pm, philDev philipptoe...@gmail.com wrote:
 OK, but still thank you

 On Mar 17, 7:10 pm, DonFrench dcfre...@gmail.com wrote:

   BTW: There is some very important Information missing on theAndroid-
   dev Page about theBluetoothAPI. Theandroid.Permissions.INTERNET
   have to be set in the Manifest too, because without them creating a
   Socket will fail.

  I am not replying to your main question because I don't have time to
  wade through all the extraneous information, but as to this last bit
  -- I can tell you that myBluetoothapp does not have INTERNET
  permissions and it works.



-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-developers] Re: Can't connect to SPP device

2010-03-20 Thread philDev
As I wrote in my Email I got similiar Problems but I'm really certain
that your app is the client here. There is not as much Documentation
available as I hoped but here is some:

http://developer.android.com/intl/de/guide/topics/wireless/bluetooth.html

Greets

Philipp Toelle

On Mar 19, 1:12 pm, Gui gui.ouel...@gmail.com wrote:
 I guess this is kind of tricky. The device i'm trying to connect is a
 GP-GC021 made by Sure electronics, the documentation is really weak.
 In the documentation, it's a slave device. So that would mean it acts
 has a server listening for connection, and my android would be the
 client ... ?

 I can't use connect() without having a socket initialized, and using
 the listenRfcomm is for server apps, and mine is a client, so
 creatRfcomm is the right method to call...no?

 On Mar 18, 2:57 pm, moneytoo m...@seznam.cz wrote:

  createRfcommSocketToServiceRecord() is used for creating server
  socket, you can only call connect() on client socket.

  What mode does the device use you are trying to connect to?

  Please be aware that these unofficial API for 1.x doesn't work in
  server mode.

  On Mar 18, 5:00 pm, Gui gui.ouel...@gmail.com wrote:

   Hi, I currently run android 1.5 on a HTC magic. I'm trying to
   communicate from my phone to a bluetooth device that supports SPP. I
   can't seem to be able to connect to the device. I have tryed two ways
   to connect:
   1- via the official 2.0 API using the backport-android to make it work
   on android 1.5
   2- via the unofficial bluetooth api 0.3

   Both method give me an error around the same connection process.

   With API 2.0, I can discover devices and pair with them. Then i create
   a socket which seems to work, but when I use the .connect() method, I
   get this error in CatLog:    IOException Unable to start Service
   Discovery. This is related to doSdp() in public class
   BluetoothSocket.

   Searching the web, it seems this error is related to a wrong UUID ...
   but I am using the SPP UUID properly.

   So, I thought the problem could be backport android, so I tried with
   the unofficial API from Gerdavax 
   (http://code.google.com/p/android-bluetooth/
   )

   To connect to a device with this API you first create a socket, then
   you connect using the .openSocket( port number) method. The weird
   thing is, if I try with a new port, it connects, if I try a second
   time, it wont work, unless I change the port. I get a similar related
   error of SDP.

   Here is my code for API 2.0, but im pretty sure its ok.

   public class RegulVoile extends Activity {

           private BluetoothAdapter adapteurGen= null;
       private BluetoothDevice moduleDistant = null;
       public String adressTrouver = null;
       private BluetoothSocket socketBt = null;
       private static final UUID MON_UUID =
   UUID.fromString(1101--1000-8000-00805F9B34FB);
           /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);

           //final TextView modeText=
   (TextView)this.findViewById(R.id.txt_state);
           //final TextView infoText=
   (TextView)this.findViewById(R.id.txt_name);
           Button connectionBt =
   (Button)this.findViewById(R.id.btn_connexion);

           adapteurGen = BluetoothAdapter.getDefaultAdapter();

           connectionBt.setOnClickListener(new OnClickListener(){
                   public void onClick(View v){

                           //make SURE there is not a discovery going on.
                   adapteurGen.cancelDiscovery();

                           moduleDistant = 
   adapteurGen.getRemoteDevice(00:1D:
   43:00:D1:0D);

                           try{

                                   socketBt =
   moduleDistant.createRfcommSocketToServiceRecord(MON_UUID);

                           } catch (IOException e) {

                           }

                   //try the connect
                           try {

                                   socketBt.connect();
                           } catch (IOException e) {
                               try {
                                   e.printStackTrace();
                                   socketBt.close();
                               } catch (IOException e2) {
                               }
                           }

                   }
           });

       }

       @Override
           protected void onStop() {
           try {
                           socketBt.close();
                   } catch (IOException e1) {

                           e1.printStackTrace();
                   }
              super.onStop();
           }

           @Override
           protected void onDestroy() {
                   try {
                           socketBt.close();
                   } catch (IOException e1) {

                           

[android-developers] Android Bluetooth Development - Problem connecting

2010-03-17 Thread philDev
@moderator please excuse my first mail, I hit the wrong button.

Hi everybody,

I'm trying for hours and couldn't find an answer anywhere online nor
in my Logs. I'm trying to establisch an RFCOMM Link by Bluetooth
between an external Device that implements the SPP 1.04 Profile. Here
is the output from sdptool:

sudo sdptool browse
Inquiring ...

Browsing 00:0B:0D:8E:D4:33 ...
Service Name: SPP slave
Service Description: Bluetooth SPP V1.04
Service RecHandle: 0x1
Service Class ID List:
  Serial Port (0x1101)
Protocol Descriptor List:
  L2CAP (0x0100)
  RFCOMM (0x0003)
Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:0x6a
  base_offset: 0x100

The Device just provides this and doesn't  have any input or screen.
And it does work with Linux etc.

I'm using the following Code in order to establish an Connection:

UUID is set to SSDP UUID (16bit UUID = 1101)
private static final UUID MY_UUID =
UUID.fromString(1101--1000-8000-00805F9B34FB);
private static String address = 00:0B:0D:8E:D4:33;

This happens in onCreate():
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

Then in onResume:
 //Starting an discovery
mBluetoothAdapter.startDiscovery();
//getting the device
BluetoothDevice device = 
mBluetoothAdapter.getRemoteDevice(address);
Log.e(TAG, device.getName() +  connected);

   //establishing socket
   try {
btSocket = 
device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, ON RESUME: Socket creation failed., e);
}
Log.e(TAG, TRYING TO CONNECT);

   //Connecting the socket
  try {
btSocket.connect();

Log .e(TAG,ON RESUME: BT connection established, 
data transfer
link open.);
} catch (IOException e) {
  //handling of Exception output etc.
   }
If I look at the dump, everything works until I try to connect to the
socket and I don't understand why it isn't working after that. Here
ist the dump Look for the TAG ThinBTClient for Log Output.


E/THINBTCLIENT( 5991): +++ ON CREATE +++
E/THINBTCLIENT( 5991): +++ DONE IN ON CREATE, GOT LOCAL BT ADAPTER +++
E/THINBTCLIENT( 5991): ++ ON START ++
E/THINBTCLIENT( 5991): + ON RESUME +
E/THINBTCLIENT( 5991): + ABOUT TO ATTEMPT CLIENT CONNECT +
I/DTUN_CLNT( 2155): Client calling DTUN_METHOD_DM_START_DISCOVERY
(id 2)
I/( 2140): DTUN_ReceiveCtrlMsg: [DTUN] Received message
[BTLIF_DTUN_METHOD_CALL] 4354
I/( 2140): handle_method_call: handle_method_call :: received
DTUN_METHOD_DM_START_DISCOVERY (id 2), len 0
W/BTLD( 2140): bta_dm_check_av:0
I/BTL-IFS ( 2140): send_ctrl_msg: [BTL_IFS CTRL] send
BTLIF_DTUN_SIGNAL_EVT (CTRL) 4 pbytes (hdl 10)
I/ADAPTER ( 2155): Discovery session 0xc7b8 with :1.0 activated
D/ADAPTER ( 2155): session_ref(0xc7b8): ref=1
I/DTUN_CLNT( 2155): dtun-rx signal [DTUN_SIG_DM_DISCOVERY_STARTED] (id
38) len 6
D/DTUN_HCID( 2155): dtun_dm_sig_discovery_started()
I//system/bin/btld( 2139):  btapp_dm_DiscoverDevices()
I/BluetoothEventLoop.cpp( 1908): event_filter: Received signal
org.bluez.Adapter:PropertyChanged from /org/bluez/2155/hci0

E/THINBTCLIENT( 5991): BT GPS connected

D/BluetoothSocket( 5991): BluetoothSocket created fd:
-1uuid1101--1000-8000-00805f9b34fbport -1
D/BluetoothSocket.cpp( 5991): initSocketNative
I/BLZ20_WRAPPER( 5991): blz20_wrp_socket: fam 31, type 1, prot
BTPROTO_RFCOMM
D/BTL_IFC_WRP( 5991): wrp_wsock_create: (null)
D/BTL_IFC_WRP( 5991): wrp_alloc_new_sock: wrp_alloc_new_sock sub 15
D/BTL_IFC_WRP( 5991): wrp_wsock_create: 31
D/BLZ20_WRAPPER( 5991): btsk_alloc_add: success
D/BLZ20_WRAPPER( 5991): btsk_dump_list:  fd (-1:28), bta -1, rc 0,
wflags 0x0
I/BLZ20_WRAPPER( 5991): blz20_wrp_socket: return 31
D/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt:  fd (-1:31), bta -1, rc
0, wflags 0x0
I/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt: configure rfcomm lm mode
0x26, (master:0, auth 1, enc 1)
I/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt: success
D/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt:  fd (-1:31), bta -1, rc
0, wflags 0x0
I/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt: configure rfcomm sndbuf
len 71680 bytes
I/BLZ20_WRAPPER( 5991): blz20_wrp_setsockopt: success
D/BluetoothSocket.cpp( 5991): ...fd 31 created (RFCOMM, lm = 26)
D/BluetoothSocket.cpp( 5991): initSocketFromFdNative

E/THINBTCLIENT( 5991): TRYING TO CONNECT

D/BluetoothSocket( 5991): connect
D/BluetoothSocket( 5991): doSdp
I/BluetoothService.cpp( 1908): ... Object Path = /org/bluez/2155/hci0/
dev_00_0B_0D_8E_D4_33
I/BluetoothService.cpp( 1908): ... Pattern =
1101--1000-8000-00805f9b34fb, strlen = 36
D/DEVICE  ( 2155): *DiscoverServices
I/DTUN_HCID( 2155): dtun_client_get_remote_svc_channel: 

[android-developers] Android Bluetooth Development - Problem connecting

2010-03-17 Thread philDev
Hi everybody,

I'm trying for hours and couldn't find an answer anywhere online nor
in my Logs. I'm trying to establisch an RFCOMM Link by Bluetooth
between an external Device that implements the SPP 1.04 Profile. Here
is the output from sdptool:

sudo sdptool browse
Inquiring ...

Browsing 00:0B:0D:8E:D4:33 ...
Service Name: SPP slave
Service Description: Bluetooth SPP V1.04
Service RecHandle: 0x1
Service Class ID List:
  Serial Port (0x1101)
Protocol Descriptor List:
  L2CAP (0x0100)
  RFCOMM (0x0003)
Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:0x6a
  base_offset: 0x100

The Device just provides this and doesn't  have any input or screen.
And it does work with Linux etc.

I'm using the following Code in order to establish an Connection:

private static final UUID MY_UUID =
UUID.fromString(1101--1000-8000-00805F9B34FB);
private static String address = 00:0B:0D:8E:D4:33;

This happens in onCreate():
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

Then in onResume:
 //Starting an discovery
mBluetoothAdapter.startDiscovery();
//getting the device
BluetoothDevice device = 
mBluetoothAdapter.getRemoteDevice(address);
Log.e(TAG, device.getName() +  connected);

   //establishing socket
   try {
btSocket = 
device.createRfcommSocketToServiceRecord(MY_UUID);
} catch (IOException e) {
Log.e(TAG, ON RESUME: Socket creation failed., e);
}
Log.e(TAG, TRYING TO CONNECT);

   //Connecting the socket
  try {
btSocket.connect();

Log .e(TAG,ON RESUME: BT connection established, 
data transfer
link open.);
} catch (IOException e) {
  //Fehlerausgabe wenn das nicht funktioniert



-- 
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


[android-developers] Re: Android Bluetooth Development - Problem connecting

2010-03-17 Thread philDev
OK, but still thank you

On Mar 17, 7:10 pm, DonFrench dcfre...@gmail.com wrote:
  BTW: There is some very important Information missing on the Android-
  dev Page about the Bluetooth API. The android.Permissions.INTERNET
  have to be set in the Manifest too, because without them creating a
  Socket will fail.

 I am not replying to your main question because I don't have time to
 wade through all the extraneous information, but as to this last bit
 -- I can tell you that my Bluetooth app does not have INTERNET
 permissions and it works.

-- 
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