×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    out.write() - bluetooth

    Have you ever tried to connect a client j2me midlet to a BT device not supporting java? Both supports RFCOMM connection and SPP. What I experienced is this :I set the device in discoverable mode; using jsr-82 APIs I connect the phone succesfully to the device in SPP emulating serial port; the device says that it is succesfully connected and it automatically it shows me the bytes arriving as a real serial port. Then I open InputStream and I can read succesfully on the phone bytes eventually sent by the device , but what I cannot do is to send from the phone to the device some bytes. No exception is thrown on the phone using out.write() and out.flush(), but I never see the bytes sent arriving on the device. I tried to use Thread.sleep() between the sending of bytes but having no success.

    What can be wrong? The phone is a Nokia 6230i

  2. #2
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Wink Re: out.write() - bluetooth

    Hi matrix241!

    I'm developing a MIDlet which connects to a BT device which doesn't support JAVA! That device implements BT V1.1 and the SPP profile and therefore I'm using the BT (JSR-82) API and the RFCOMM connection (SPP profile) as you!

    I receive bytes constantly from the BT device in my mobile phones Nokia 9500/ Nokia 6230...
    but I can send some "commands" to that BT device in certain moments, not at any time!

    All works perfectly but I had some problems sending "commands" to the BT device because the sending wasn't made in the appropiate moment or because the command's format was wrong!

    So you should revise several things:

    1) The moment when you made the sending (Isn't the BT device receiving the bytes correctly even if you send the "info" in the appropiate moment?).

    2) The info's format.

    3) Try to use InputStream and OutputStream if you used DataInputStream and DataOutputStream or vice versa.

    4) Use the line "StreamConnection sc=(StreamConnection)Connector.open(btURL, READ_WRITE)
    to create your StreamConnection to be sure that your BT connection is
    in write&read mode!

    javax.microedition.io
    Class Connector

    java.lang.Object
    |
    +--javax.microedition.io.Connector

    public class Connector
    extends Object

    This class is factory for creating new Connection objects.
    .................

    An optional second parameter may be specified to the open function. This is a mode flag that indicates to the protocol handler the intentions of the calling code. The options here specify if the connection is going to be read (READ), written (WRITE), or both (READ_WRITE). The validity of these flag settings is protocol dependent. For instance, a connection for a printer would not allow read access, and would throw an IllegalArgumentException. If the mode parameter is not specified, READ_WRITE is used by default.

    .................
    Best regards.

    Summerman.

  3. #3
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    thanks Summerman
    I tried to change from OutputStream to DataOutputStream, but the results are the same: I cannot see on the device the byte sent by the phone. I can succesfully read on the phone bytes sent by the device . The device is a "converter" bluetooth-RS232 and in the RS232 port I cannot see the bytes sent by the phone. But it is in a listening state.This is confirmed by my tests:

    bytes sent from a PC ->to the BT-RS232 device OK, I can read them on the device
    bytes sent from the j2me application -> to a PC with BT OK, I can read them on the PC

    so the application on the phone can send correctly the bytes to a PC but not to the device, and the device can read succesfully bytes sent by the PC, but not from the phone.
    Which kind of configuration can I have been missing?

    thanks

  4. #4
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Exclamation Re: out.write() - bluetooth

    There are problems between your mobile phone and your RS232-BT device as you say!

    Do you make the Inquiry process well? Does your device set to Discoverable.GIAC or Discoverable.LIAC mode?

    I suppose you find it correctly, don't you?

    Do you make the ServiceSearch process correctly?
    Is there a PIN to start the BT session! Did you enter it in your phone/your RS232-BT device?

    See you!

  5. #5
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    Hi Summerman,
    the BT device is discoverable for all.
    No problems in discovery device and service (the only service available is SPP).
    The phone can discovery the device, the service and then they connect succesfully. I can read bytes sent from the device to the phone on the phone. But not bytes from phone to the device on the device.
    Could be a problem with BT major-minor numbers of the device? Are there any situations in which on a correct BT connection out.write() cannot work?
    Where can I find details on implementation by NOKIA of this function on BT connection
    thanks again

  6. #6
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Arrow Re: out.write() - bluetooth

    Hi, I'm here again!

    Try to test this two lines when you make the BT connection (you found the ServiceRecord object which points to the service that you are interesting in):

    btURL=sr.getConnectionURL(ServiceRecord.AUTHENTICATE_NOENCRYPT,false);
    or
    btURL=sr.getConnectionURL(ServiceRecord.AUTHENTICATE_NOENCRYPT,true);

    This "boolean" parameter means that the remote device (not you mobile phone) wants to be the "master" in the BT connection if its value is 'true'.


    JSR-82 LIBRARY

    getConnectionURL

    public java.lang.String getConnectionURL(int requiredSecurity,
    boolean mustBeMaster)

    Returns a String including optional parameters that can be used by a client to connect to the service described by this ServiceRecord. The return value can be used as the first argument to Connector.open(). In the case of a Serial Port service record, this string might look like "btspp://0050CD00321B:3;authenticate=true;encrypt=false;master=true", where "0050CD00321B" is the Bluetooth address of the device that provided this ServiceRecord, "3" is the RFCOMM server channel mentioned in this ServiceRecord, and there are three optional parameters related to security and master/slave roles.

    If this method is called on a ServiceRecord returned from LocalDevice.getRecord(), it will return the connection string that a remote device will use to connect to this service.

    Parameters:
    requiredSecurity - determines whether authentication or encryption are required for a connection
    mustBeMaster - true indicates that this device must play the role of master in connections to this service; false indicates that the local device is willing to be either the master or the slave
    Returns:
    a string that can be used to connect to the service or null if the ProtocolDescriptorList in this ServiceRecord is not formatted according to the Bluetooth specification
    Throws:
    IllegalArgumentException - if requiredSecurity is not one of the constants NOAUTHENTICATE_NOENCRYPT, AUTHENTICATE_NOENCRYPT, or AUTHENTICATE_ENCRYPT
    See Also:
    NOAUTHENTICATE_NOENCRYPT, AUTHENTICATE_NOENCRYPT, AUTHENTICATE_ENCRYPT

    Take it and test it because it might be work!

    Good luck!
    Last edited by Summerman; 2006-10-20 at 16:48.

  7. #7
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    Hei Summerman,
    I finally get the answer to the problem.
    I tried using a nokia n91, the same application done by myself and it works well.
    Using the other phone ( 6230i) it doesn't work the function out.write() for Outputstream bluetooth.

    So I think it is a difference/problem in the implementation of jsr 82.

    thanks & regards

  8. #8
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    Hello I tried also with the same application on a s40 3rd edition ( nokia 6131 ).
    Also in this case the phone is unable to write a byte to the device ( or the device doesn't receive it ).
    Which difference between s60 3rd ed. java machine and s40 3rd ed. could cause this ?
    Is there a workaround for this ?


    thanks

  9. #9
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    HI
    other news about this problem:
    tested with a Nokia 6680 (s60) : ok sending bytes and receiving.

    It seems so then on s60 platform there is a difference from the s40 platform java implementation regarding sending bytes to a BT device.

    I cannot see a byte sent by the phone on the bt-serial converter embedded device if the phone is a s40 (tested on 6131,6230i) but I can see it properly if the byte is sent by a s60 device (tested on 6680, N91 ). In both cases (s40 and s60) the discovery and the connection are properly terminated.
    Also in both cases I can read on the phone bytes sent by the device.


    I'd like to have even a little information or trick to workaround this or to explain this problem by any Nokia expert or other people. Any comment will be appreciated.

    thanks

  10. #10
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Arrow Re: out.write() - bluetooth

    Hi matrix241,
    I don't know if it is some sense, but you can check what BT version support those S60 and S40 devices which you used in your tests.

    You can use the System.getProperty("Bluetooth.api.version") to get this value. Then, you can read the JSR-82 specification to know what BT version implements that JSR-82 version. For instance, the JSR-82 specification version 1.1 is based on the Bluetooth specification version 1.1.

    I would have a look at this specification version 1.1:
    https://opensource.motorola.com/sf/d...tion/doc1005/2

    1.2.1 Bluetooth Specification
    The specification for Bluetooth wireless communications is developed by the Bluetooth Special Interest Group (SIG) led by promoter companies 3Com, Ericsson, Intel, IBM, Agere, Microsoft, Motorola, Nokia and Toshiba. The Bluetooth specification is available from the SIG’s web site, http://www.bluetooth.org/spec. The Bluetooth specification defines protocols and application profiles but does not define any APIs.
    The JSR 82 specification defines APIs that can be used to exercise certain Bluetooth protocols defined in the Bluetooth specification volume 1 [1], and certain profiles defined in the Bluetooth specification volume 2 [2]. Those profiles are listed in Section 2.3. This API is defined in such a way as to make it possible for additional and future profiles to be built on top of this API. This assumes that future changes to the Bluetooth specification remain compatible with this API. This API is based on the Bluetooth specification version 1.1. However, nothing in this specification is intended to preclude operating with version 1.0 compliant stacks or hardware. In addition, if future versions are backward compatible with version 1.1, then implementations of this specification should operate on those versions of stacks or hardware as well.
    I advice you to check if those S40 devices support the same BT specification that your end device. Maybe, they have different versions, so those S40 devices can't send bytes to the end device!

    I don't know if these lines will help you!

    If you have a solution, please keep me inform!

    Best regards.

    Summerman.

  11. #11
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Summerman, the Bluetooth Spec version has nothing to do with the JSR-82 version. Actually, there is no single JSR-82 v1.1 device on the market, yet. All are v1.0a and come with Bluetooth Spec 1.1, 1.2, 2.0, 2.0+EDR, …

  12. #12
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    Hi Summerman and Traud !
    Yes, the BT api version is the same for a s40 device like 6131 and for a s60 one like N91.
    But for the other BT properties I can see some differences :

    for a N91 (s60) :

    bluetooth.connected.inquiry = false
    bluetooth.connected.inquiry.scan = false
    bluetooth.connected.page = false
    bluetooth.connected.page.scan = false
    bluetooth.sd.attr.retriavable.max= 65536

    but for a 6131 (s40) :

    bluetooth.connected.inquiry = true
    bluetooth.connected.inquiry.scan = true
    bluetooth.connected.page = true
    bluetooth.connected.page.scan = true
    bluetooth.sd.attr.retriavable.max= 13

    I don't know if one of these properties can make the difference s60 = ok, s40 not ok.
    Could I try the sending the byte by l2cap connection ? Is it an alternative or it's the same as flushing it by an OutputStream?

    thanks

  13. #13
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    Hi to all,
    I found this Nokia Forum very useul and I have never seen a feedback so huge for so many topics as in this forum, but what is the next step when a topic or problem like mine in this thread has no answers? Is there another place to send the query to in Nokia?
    I tried also contacting the support of the productor of the bluetooth-serial converter, but also he has no answers.

    Another tech question: at low level is there a difference if the app calls a DataOutputStream write function (writeByte, write,..) or a OutputStream write function to write a byte to a bluetooth stream?



    thanks
    regards

  14. #14
    (Retired) Nokia Developer Admin.
    Join Date
    Jan 2006
    Location
    Michigan
    Posts
    4,664

    Re: out.write() - bluetooth

    Hi Matrix,

    Be sure you post in the appropriate forum, Java questions in Mobile Java, Bluetooth questions in the Connectivity - Bluetooth technology questions

    Also do not Post two question inone message or respond to a previous thread with a new questions. Finally give all the information, clearly don't leave anything out or toss any unrrelated items in.

    So one question per message. New Threads for each question and be sure to post in the correct forum. Clear concise questions.
    That will help get your questions answered.

  15. #15
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    231

    Re: out.write() - bluetooth

    You're right Ron,
    I try to sum-up the situation in a more concise way.
    I use A -> B to indicate "A sends a byte to B" and A <- B for "B sends a byte to A"
    Using a simple java midlet that connects and opens an InputStream and an OutputStream by bluetooth SPP to a device that is a serial-bluetooth converter

    (http://www.sena.com/products/industr...al/parani_esd/ )

    I found
    s60 <-> converter OK
    s40 <- converter OK
    s40 -> converter NOT OK

    and finally
    s40 <-> s60: OK
    s40 <-> PC with BT usb dongle : OK
    converter <-> PC with usb dongle : OK

    in all the cases in which there are phones the app is not modified or recompiled. No exceptions are thrown.
    If anyone guesses or knows a possible solution for the NOT OK case, please write it!

    thanks

Similar Threads

  1. How To Make The S60 Emulator See My USB Bluetooth Dongle ?
    By Mo7ammed_01 in forum Bluetooth Technology
    Replies: 9
    Last Post: 2009-07-17, 02:33
  2. Canyon Bluetooth adapter not working with PC Suite?
    By sNNooPY in forum Bluetooth Technology
    Replies: 6
    Last Post: 2006-08-10, 08:43
  3. How To Make The S60 Emulator See My USB Bluetooth Dongle ?
    By Mo7ammed_01 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-07-25, 00:14
  4. How To Make The S60 Emulator See My USB Bluetooth Dongle ?
    By Mo7ammed_01 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-07-25, 00:12
  5. Nokia 7650 support Bluetooth audo?
    By ovjo12 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2003-07-17, 18:50

Posting Permissions

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