Hi,

I've try to add delay before, after, before and after but the result still
unchanger...

It's not a headset it's a device used to protect your valuables, it checks
the bluetooth connection and when it to far from the mobile phone (=> loose
the bluetooth connection)  an alarm is started.

Any more idea ?

Thank you

  Best regards


SECU4 SA
Laurent Lugon Moulin

Technical & Development Assistant
 Technopôle 5
3960 Sierre – Switzerland

Office  :   +4127 4567 931
Fax      :   +4127 4567
935
Mobile :   +4179 4509 566

Skype :   laurent.lugon.moulin

www.secu4.com






On Wed, Feb 9, 2011 at 05:02, Ajith Kamath <[email protected]> wrote:

> Hi
>
> Checked the logs. Everything seems to be fine.
> I'm not sure what the prob is. Try adding some delay before bluetooth
> socket connect takes place.
> this might be needed if you are connecting to some headsets/handsfree.
>
> If Still it doesn solve the problem.. Add logs upto jni level and send the
> logs.
> The logs which you have added so far does not point out any problems .
>
> Also tell what kind of device are you trying to connect to you mobile.?
>
> Regards,
> Ajith
>
> On Tue, Feb 8, 2011 at 7:40 PM, Laurent Lugon <[email protected]>wrote:
>
>> Hi Ajith,
>>
>> I've add logs in the connectThread and connectedThread.
>>
>> See the result in attached files.
>>
>>
>> Thank you for your help !
>>
>>   Best regards
>>
>>
>> SECU4 SA
>> Laurent Lugon Moulin
>>
>> Technical & Development Assistant
>> Technopôle 5
>> 3960 Sierre – Switzerland
>>
>> Office  :   +4127 4567 931 <+41274567931>
>> Fax      :   +4127 4567 935 <+41274567935>
>>
>> Mobile :   +4179 4509 566 <+41794509566>
>>
>> Skype :   laurent.lugon.moulin
>>
>> www.secu4.com
>>
>>
>>
>>
>>
>>
>> On Tue, Feb 8, 2011 at 06:10, Ajith Kamath <[email protected]> wrote:
>>
>>> Hi
>>>
>>> Sorry I rechecked logs again. *BEGIN mConnectedThread *seems to be
>>> called.
>>> my bad.
>>>
>>> Still please add logs before and after connect and send
>>>
>>> Regards,
>>> Ajith
>>>
>>>   On Tue, Feb 8, 2011 at 10:39 AM, Ajith Kamath <[email protected]>wrote:
>>>
>>>>
>>>> Hi
>>>>
>>>> From the attached logs, its unclear what is the error.
>>>> Discovery seems to be stopped in an odd manner, but that should not
>>>> generate any problem
>>>> You need to rig the code , add more logs.
>>>>
>>>> Since the connect thread was called, add more logs in Connect thread
>>>> It seems that "*BEGIN mConnectedThread*" is never displayed.
>>>> I think there exists problem in connect thread. Please check this.
>>>>
>>>> Also what I meant by my previous question is that, What kind of h/w are
>>>> you trying to connect to your mobile(Ex: headset, handsfree, carkit etc 
>>>> etc)
>>>>
>>>> Regards,
>>>> Ajith
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Feb 7, 2011 at 6:16 PM, Laurent Lugon 
>>>> <[email protected]>wrote:
>>>>
>>>>> Hi Ajith,
>>>>>
>>>>> You will find the logs attached.
>>>>>
>>>>> I use our own hardware device. It's the product we develop :
>>>>> http://www.secu4.com/en/product.html
>>>>> It's works realy good with the actual software so it's not a hardware
>>>>> issue. I'm developing the new version of the software related to our 
>>>>> product
>>>>> and we change different things on the bluetooth connection procedure.
>>>>>
>>>>>   Best regards
>>>>>
>>>>>
>>>>> SECU4 SA
>>>>> Laurent Lugon Moulin
>>>>>
>>>>> Technical & Development Assistant
>>>>> Technopôle 5
>>>>> 3960 Sierre – Switzerland
>>>>>
>>>>> Office  :   <+41274567931>+4127 4567 931 <+41274567931>
>>>>>
>>>>> Fax      :   <+41274567935>+4127 4567 935 <+41274567935>
>>>>>
>>>>> Mobile :   <+41794509566>+4179 4509 566 <+41794509566>
>>>>> Skype :   laurent.lugon.moulin
>>>>>
>>>>> www.secu4.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Feb 7, 2011 at 12:01, Ajith Kamath <[email protected]>wrote:
>>>>>
>>>>>> please paste the logs. And what bluetooth h/w are you trying to
>>>>>> connect to your mobile device
>>>>>>
>>>>>> Regards,
>>>>>> Ajith
>>>>>>
>>>>>>   On Mon, Feb 7, 2011 at 4:21 PM, Laurent Lugon <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>>  Hi all,
>>>>>>>
>>>>>>> I use a hardware bluetooth device and I need to connect it to my
>>>>>>> mobile phone. I've follow the instruction on developer.android.comto 
>>>>>>> set up a bluetooth connection but I still have a problem. When I'm
>>>>>>> connecting to the Bluetooth Socket with bluetoothSocket.connect() I 
>>>>>>> don't
>>>>>>> catch any exception so according to the docs, that mean I'm connected 
>>>>>>> to my
>>>>>>> device. The problem is I'm not... Here is my code :
>>>>>>>
>>>>>>>     private class AcceptThread extends Thread {
>>>>>>>         // The local server socket
>>>>>>>         private final BluetoothServerSocket mmServerSocket;
>>>>>>>
>>>>>>>         public AcceptThread() {
>>>>>>>             BluetoothServerSocket tmp = null;
>>>>>>>
>>>>>>>             // Create a new listening server socket
>>>>>>>             try {
>>>>>>>                 tmp = mAdapter
>>>>>>>                         .listenUsingRfcommWithServiceRecord(NAME,
>>>>>>> MY_UUID);
>>>>>>>             } catch (IOException e) {
>>>>>>>                 Log.e(TAG, "listen() failed", e);
>>>>>>>             }
>>>>>>>             mmServerSocket = tmp;
>>>>>>>         }
>>>>>>>
>>>>>>>         public void run() {
>>>>>>>             if (D)
>>>>>>>                 Log.d(TAG, "BEGIN mAcceptThread" + this);
>>>>>>>             setName("AcceptThread");
>>>>>>>             BluetoothSocket socket = null;
>>>>>>>
>>>>>>>             // Listen to the server socket if we're not connected
>>>>>>>             while (mState != STATE_CONNECTED) {
>>>>>>>                 try {
>>>>>>>                     // This is a blocking call and will only return
>>>>>>> on a
>>>>>>>                     // successful connection or an exception
>>>>>>>                     socket = mmServerSocket.accept();
>>>>>>>                 } catch (IOException e) {
>>>>>>>                     Log.e(TAG, "accept() failed", e);
>>>>>>>                     break;
>>>>>>>                 }
>>>>>>>
>>>>>>>                 // If a connection was accepted
>>>>>>>                 if (socket != null) {
>>>>>>>                     synchronized (BluetoothConnectionService.this) {
>>>>>>>                         switch (mState) {
>>>>>>>                         case STATE_LISTEN:
>>>>>>>                         case STATE_CONNECTING:
>>>>>>>                             // Situation normal. Start the connected
>>>>>>> thread.
>>>>>>>                             connected(socket,
>>>>>>> socket.getRemoteDevice());
>>>>>>>                             break;
>>>>>>>                         case STATE_NONE:
>>>>>>>                         case STATE_CONNECTED:
>>>>>>>                             // Either not ready or already connected.
>>>>>>> Terminate
>>>>>>>                             // new socket.
>>>>>>>                             try {
>>>>>>>                                 socket.close();
>>>>>>>                             } catch (IOException e) {
>>>>>>>                                 Log.e(TAG, "Could not close unwanted
>>>>>>> socket", e);
>>>>>>>                             }
>>>>>>>                             break;
>>>>>>>                         }
>>>>>>>                     }
>>>>>>>                 }
>>>>>>>             }
>>>>>>>             if (D)
>>>>>>>                 Log.i(TAG, "END mAcceptThread");
>>>>>>>         }
>>>>>>>
>>>>>>>         public void cancel() {
>>>>>>>             if (D)
>>>>>>>                 Log.d(TAG, "cancel " + this);
>>>>>>>             try {
>>>>>>>                 if (mmServerSocket != null)
>>>>>>>                     mmServerSocket.close();
>>>>>>>             } catch (Exception e) {
>>>>>>>                 Log.e(TAG, "close() of server failed", e);
>>>>>>>             }
>>>>>>>         }
>>>>>>>     }
>>>>>>>
>>>>>>>     /**
>>>>>>>      * This thread runs while attempting to make an outgoing
>>>>>>> connection with a
>>>>>>>      * device. It runs straight through; the connection either
>>>>>>> succeeds or
>>>>>>>      * fails.
>>>>>>>      */
>>>>>>>     private class ConnectThread extends Thread {
>>>>>>>         private final BluetoothSocket mmSocket;
>>>>>>>         private final BluetoothDevice mmDevice;
>>>>>>>
>>>>>>>
>>>>>>>         public ConnectThread(BluetoothDevice device) {
>>>>>>>             mmDevice = device;
>>>>>>>             BluetoothSocket connection = null;
>>>>>>>
>>>>>>>             // Get a BluetoothSocket for a connection with the
>>>>>>>             // given BluetoothDevice
>>>>>>>             try {
>>>>>>>                 // device.createRfcommSocketToServiceRecord(MY_UUID);
>>>>>>>                 Method m =
>>>>>>> device.getClass().getMethod("createRfcommSocket",
>>>>>>>                         new Class[] { int.class });
>>>>>>>                 connection = (BluetoothSocket) m.invoke(device, 1);
>>>>>>>                 Utils.pause(100);
>>>>>>>             } catch (Exception e) {
>>>>>>>                 Log.e(TAG, "create() failed", e);
>>>>>>>             }
>>>>>>>             mmSocket = connection;
>>>>>>>         }
>>>>>>>
>>>>>>>         public void run() {
>>>>>>>             Log.i(TAG, "BEGIN mConnectThread");
>>>>>>>             setName("ConnectThread");
>>>>>>>
>>>>>>>             if (mmSocket != null) {
>>>>>>>                 // Always cancel discovery because it will slow down
>>>>>>> a
>>>>>>>                 // connection
>>>>>>>                     mAdapter.cancelDiscovery();
>>>>>>>
>>>>>>>                 // Make a connection to the BluetoothSocket
>>>>>>>                 try {
>>>>>>>                     // This is a blocking call and will only return
>>>>>>> on a
>>>>>>>                     // successful connection or an exception
>>>>>>>                     mmSocket.connect();
>>>>>>>                 } catch (Exception e1) {
>>>>>>>
>>>>>>>                     Log.e(TAG, "connect failed", e1);
>>>>>>>                     connectionFailed();
>>>>>>>
>>>>>>>                     // Close the socket
>>>>>>>                     try {
>>>>>>>                         mmSocket.close();
>>>>>>>                     } catch (IOException e2) {
>>>>>>>                         Log.e(TAG,
>>>>>>>                                 "unable to close() socket during
>>>>>>> connection failure",
>>>>>>>                                 e2);
>>>>>>>                     }
>>>>>>>                     // Start the service over to restart listening
>>>>>>> mode
>>>>>>>                     BluetoothConnectionService.this.start();
>>>>>>>                     return;
>>>>>>>                 }
>>>>>>>                 // Reset the ConnectThread because we're done
>>>>>>>                 synchronized (BluetoothConnectionService.this) {
>>>>>>>                     mConnectThread = null;
>>>>>>>                 }
>>>>>>>
>>>>>>>                 // Start the connected thread
>>>>>>>                 connected(mmSocket, mmDevice);
>>>>>>>             } else {
>>>>>>>                 connectionFailed();
>>>>>>>                 BluetoothConnectionService.this.start();
>>>>>>>             }
>>>>>>>         }
>>>>>>>
>>>>>>>         public void cancel() {
>>>>>>>             try {
>>>>>>>                 if (mmSocket != null) {
>>>>>>>                     mmSocket.close();
>>>>>>>                 }
>>>>>>>             } catch (IOException e) {
>>>>>>>                 Log.e(TAG, "close() of connect socket failed", e);
>>>>>>>             }
>>>>>>>         }
>>>>>>>     }
>>>>>>>
>>>>>>>     /**
>>>>>>>      * This thread runs during a connection with a remote device. It
>>>>>>> handles all
>>>>>>>      * incoming and outgoing transmissions.
>>>>>>>      */
>>>>>>>     private class ConnectedThread extends Thread {
>>>>>>>         private final BluetoothSocket mmSocket;
>>>>>>>         private final DataInputStream mmInStream;
>>>>>>>         private final OutputStream mmOutStream;
>>>>>>>
>>>>>>>         public ConnectedThread(BluetoothSocket socket) {
>>>>>>>             Log.d(TAG, "create ConnectedThread");
>>>>>>>             mmSocket = socket;
>>>>>>>             InputStream tmpIn = null;
>>>>>>>             OutputStream tmpOut = null;
>>>>>>>
>>>>>>>             // Get the BluetoothSocket input and output streams
>>>>>>>             try {
>>>>>>>                 tmpIn = socket.getInputStream();
>>>>>>>                 tmpOut = socket.getOutputStream();
>>>>>>>                 isConnected = true;
>>>>>>>             } catch (IOException e) {
>>>>>>>                 Log.e(TAG, "temp sockets not created", e);
>>>>>>>                 isConnected = false;
>>>>>>>             }
>>>>>>>
>>>>>>>             mmInStream = new DataInputStream(tmpIn);
>>>>>>>             mmOutStream = tmpOut;
>>>>>>>         }
>>>>>>>
>>>>>>>         public void run() {
>>>>>>>             Log.i(TAG, "BEGIN mConnectedThread");
>>>>>>>
>>>>>>>             while (isConnected) {
>>>>>>>                 Utils.pause(5);
>>>>>>>                 isConnected = checkConnection();
>>>>>>>             }
>>>>>>>         }
>>>>>>>
>>>>>>>         /**
>>>>>>>          * Check if the connection is still alive
>>>>>>>          *
>>>>>>>          * @return true or false
>>>>>>>          */
>>>>>>>         private boolean checkConnection() {
>>>>>>>             synchronized (mmInStream) {
>>>>>>>                 try {
>>>>>>>                     int len = mmInStream.available();
>>>>>>>                     if (len > 0) {// Checks the available amount
>>>>>>>                         byte b[] = new byte[len];
>>>>>>>                         mmInStream.readFully(b, 0, len);
>>>>>>>                         mHandler.obtainMessage(MESSAGE_READ, len, -1,
>>>>>>> b)
>>>>>>>                                 .sendToTarget();
>>>>>>>                     }
>>>>>>>                     return true;
>>>>>>>                 } catch (IOException ioe) {
>>>>>>>                     Log.e(TAG, "disconnected", ioe);
>>>>>>>                     connectionLost();
>>>>>>>                     return false; // Connection is lost.
>>>>>>>                 }
>>>>>>>             }
>>>>>>>         }
>>>>>>>
>>>>>>>
>>>>>>> Thank you for your help !
>>>>>>>
>>>>>>>   Best regards
>>>>>>>
>>>>>>>
>>>>>>> SECU4 SA
>>>>>>> Laurent Lugon Moulin
>>>>>>>
>>>>>>> Technical & Development Assistant
>>>>>>> Technopôle 5
>>>>>>> 3960 Sierre – Switzerland
>>>>>>>
>>>>>>> Office  :   <+41274567931> <+41274567931>+4127 4567 931<+41274567931>
>>>>>>>
>>>>>>> Fax      :   <+41274567935> <+41274567935>+4127 4567 935<+41274567935>
>>>>>>>
>>>>>>> Skype :   laurent.lugon.moulin
>>>>>>>
>>>>>>> www.secu4.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Android Developers" group.
>>>>>>> To post to this group, send email to
>>>>>>> [email protected]
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> [email protected]
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/android-developers?hl=en
>>>>>>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Android Developers" group.
>>>>>> To post to this group, send email to
>>>>>> [email protected]
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected]
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/android-developers?hl=en
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Android Developers" group.
>>>>> To post to this group, send email to
>>>>> [email protected]
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/android-developers?hl=en
>>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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

Reply via email to