×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Question S40 series and OutputStream (Connector)

    Hello im getting troubled with simple data transaction from S40 device to Bluetooth ComPort. Im connected to this device but no data transfer registred at all. My question is where could be mistake.

    Code:
    connection = (StreamConnection) Connector.open(url);
    input = connection.openInputStream();
    output = connection.openOutputStream();
    then simply
    Code:
    output.write(1);
    and on other side nothing happens. I tryed to send on this other side througth another comport and works normal, also i tryed to run this Midlet in JWT 2.5.2 where it works well with server.

  2. #2
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    Hello im getting troubled with simple data transaction from S40 device to Bluetooth ComPort. Im connected to this device but no data transfer registred at all. My question is where could be mistake.

    Code:
    connection = (StreamConnection) Connector.open(url);
    input = connection.openInputStream();
    output = connection.openOutputStream();
    then simply
    Code:
    output.write(1);
    and on other side nothing happens. I tryed to send on this other side througth another comport and works normal, also i tryed to run this Midlet in JWT 2.5.2 where it works well with server.
    Can you specify the url?
    Regards,
    Pradip

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    Im using btspp://xxxxxxxxxxxxx;parameters
    where UUID im creating like UUID RF_COMM = new UUID(0x0003) or UUID(0x1101) (i tryed both)

    I was thinking, if bitrates are the same. But i dont know how JSR-82 specify bitrates, or how/where to find it out?

  4. #4
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    Hello im getting troubled with simple data transaction from S40 device to Bluetooth ComPort. Im connected to this device but no data transfer registred at all. My question is where could be mistake.

    Code:
    connection = (StreamConnection) Connector.open(url);
    input = connection.openInputStream();
    output = connection.openOutputStream();
    then simply
    Code:
    output.write(1);
    and on other side nothing happens. I tryed to send on this other side througth another comport and works normal, also i tryed to run this Midlet in JWT 2.5.2 where it works well with server.
    Hi holymanus,
    I am not getting what is your actual task from above information.I think you are communicating with bluetooth which is connected to PC.and trying to tranfer data from mobile to PC via bluetooth API,is it correct?
    Regards,
    Pradip

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    Sorry that i didnt explain that correctly, my task is to transfer data (in form of commands) from Mobile device to bluetooth modul -> which is behaving like com port - UART.

    1. side Midlet -> API -> Data ->Serial Data -> Bluetooth -> Medium (air); Master; Client
    2. side Medium (air) -> Bluetooth -> Serial Data [-> Data .....]; Slave; Server

    And my question was how to transfer data to this second side ? And how to find out which bitrate is used for transaction, because on other side is hard setted.

  6. #6
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    Sorry that i didnt explain that correctly, my task is to transfer data (in form of commands) from Mobile device to bluetooth modul -> which is behaving like com port - UART.

    1. side Midlet -> API -> Data ->Serial Data -> Bluetooth -> Medium (air); Master; Client
    2. side Medium (air) -> Bluetooth -> Serial Data [-> Data .....]; Slave; Server

    And my question was how to transfer data to this second side ? And how to find out which bitrate is used for transaction, because on other side is hard setted.
    Try to open the bluetooth connection with specifying port after bluetooth adress like-
    btspp://xxxxxxxxxxxxxort;parameters use port as 1
    Regards,
    Pradip

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    Im opening connection with this port. Address of server looks like that - btspp://0000000DECAF:1;master=false;encrypt=false;authenticate=false

  8. #8
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    Im opening connection with this port. Address of server looks like that - btspp://0000000DECAF:1;master=false;encrypt=false;authenticate=false
    then,what is the error you are getting?
    Regards,
    Pradip

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    That no data are sended/accepted on second side.

  10. #10
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    That no data are sended/accepted on second side.
    but,how you know that mobile device is sending data properly via bluetooth to you second device?
    I have communicated with bluetooth printer to print billing sleeps from mobile device,following is the thread
    Thread.sleep() is used for delay between the commands

    Code:
    class COMMReader extends Thread
        {
    
            String URL = "";
            StreamConnection sc = null;
            OutputStream outputStream = null;
            InputStream inputStream = null;
    
            public COMMReader()
            {
            }
    
            public void run()
            {
                URL = "btspp://001B350317DF:1;master=false;encrypt=false;authenticate=false";
                try
                {
                    sc = (StreamConnection) Connector.open(URL);
                    RemoteDevice remote = RemoteDevice.getRemoteDevice(sc);
                    outputStream = sc.openOutputStream();
                    byte[] bt1 =
                    {
                        (byte) 0x1B, (byte) 0x40
                    };
                    byte[] bt2 =
                    {
                        (byte) 0x00
                    };
                    byte[] bt3 =
                    {
                        (byte) 0x0C
                    };
                    outputStream.write(bt1);
                    outputStream.flush();
                    outputStream.write(bt2);
                    outputStream.flush();
                    try
                    {
                        Thread.sleep(20);
                    }
                    catch (InterruptedException ex)
                    {
                        ex.printStackTrace();
                    }
                    outputStream.write("Hello ! this is the test print".getBytes());
                    outputStream.flush();
                    outputStream.write("\r\n".getBytes());
                    outputStream.flush();
                    outputStream.write("to test the billing sleeps".getBytes());
                    outputStream.flush();
                    outputStream.write("\r\n".getBytes());
                    outputStream.flush();
                    outputStream.write("Thanks".getBytes());
                    outputStream.flush();
                    outputStream.write(bt3);
                    outputStream.flush();
                }
                catch (IOException ex)
                {
                    Dialog.show("INFO", "Unable to pair with printer", "OK", "Back");
                }
                try
                {
                    sc.close();
                    outputStream.close();
                    outputStream = null;
                }
                catch (IOException ex)
                {
                    ex.printStackTrace();
                }
            }
        }
    Last edited by pradip7; 2011-10-19 at 06:08. Reason: hint
    Regards,
    Pradip

  11. #11
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    Could you explain me why do you use this:
    RemoteDevice remote = RemoteDevice.getRemoteDevice(sc);

    Is it for getting paired ?

    Im paired with this device (other side is writing to me that Connect from Mac xxxxx) and all what im creating is succesfully created.
    Last edited by holymanus; 2011-10-19 at 08:47. Reason: Added information

  12. #12
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: S40 series and OutputStream (Connector)

    Quote Originally Posted by holymanus View Post
    Could you explain me why do you use this:
    RemoteDevice remote = RemoteDevice.getRemoteDevice(sc);

    Is it for getting paired ?

    Im paired with this device (other side is writing to me that Connect from Mac xxxxx) and all what im creating is succesfully created.
    Yes,just used for pairing.
    Regards,
    Pradip

  13. #13
    Registered User
    Join Date
    Oct 2011
    Posts
    12

    Re: S40 series and OutputStream (Connector)

    I found it, thanks to your code and advice of my college. There is on lower level protocol L2CAP which define how much bytes should be writen to this Stream that it will send it througth this bluetooth. Function flush() will enable to send it before this count of bytes is reached. Another mistake was that i sended control signs (0x01) which doesnt apear in IO terminal.

Similar Threads

  1. Input/OutputStream
    By sommeralex in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-02-08, 10:59
  2. (HttpConnection)Connector.open(url,Connector.READ_WRITE,true) throws IOException
    By chrisdon2121 in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2006-04-30, 10:10
  3. A technical Problem with Outputstream
    By ummarbhutta in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-03-27, 10:00
  4. OutputStream & images
    By filtered in forum Mobile Java General
    Replies: 1
    Last Post: 2004-04-28, 09:16
  5. OutputStream & images
    By filtered in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-04-27, 23:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •