×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    S60 Bluetooth issue

    Hello,

    we’re currently implementing a J2ME application printing bills using a portable printer over Bluetooth (RFCOMM interface).

    The device and service discovery is done according to the rules.

    Application runs fine on two devices running the S40 Developer Platform (6111 & 6230i).

    Problem is that the target device must be a S60 Developer Platform device mainly due to the screen size…

    Problems appear as soon as we want to use the Bluetooth interface on the S60 devices.
    We’re getting a “java.lang.NullPointerException 0” as soon as we open the connection.

    in the code:
    // device discovery: OK
    // service discovery: OK
    serviceRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false );
    // the following line causes the NPException
    StreamConnection con = (StreamConnection) Connector.open(url);

    The connection String is, of course, not null…

    What we noticed is that the connection URL changes according to the device it is running on:

    - On S40 phones, getConnectionURL() returns: btspp://000E6DCE3A4D:2;authenticate=false;encrypt=false;master=false

    - On S60 phones, getConnectionURL() returns: btgoep://000E6DCE3A4D:1;authenticate=false;encrypt=false;master=false

    The printer would support OBEX but this is not our target. We must use it on a pure RFCOMM level.

    Why do S60 phones want to use the OBEX protocol?
    Trying to use the S40 connection URL on the S60 causes the same NPException....

    Where is the problem?

    I would be really glad if someone could give us a hint on how to get it running!

    Thanks a lot in advance.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    For which service are you searching? This UUID is either wrong or not unique when it comes to your printer. Which S60 (Model or Edition and Feature Pack) are you using anyway?

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Re: S60 Bluetooth issue

    Hi and thanks for the prompt reply.
    Our Test Phone is a Nokia 6670.
    We are using S60 2nd Edition, Feature Pack 1 (Series 60 MIDP SDK 2.1 for Symbian OS )

    Code:
    public void doDiscoverService(RemoteDevice remote) {
    
    try {
    
       RuntimeObjects.agent.searchServices(null, // attributes to retrieve from remote device
       new UUID[] { new UUID(0x0003) }, // search criteria,
       // 0x0003 = RFCOMM
       // 0x0100 = L2CAP
       remote, new BluetoothPrinterDiscoveryListener()); 
       // direct
       // discovery
       // response
       // to
       // Listener object
    } catch (BluetoothStateException e) {
               showExceptionAlert(e);
    }
    One service is discovered.This is correct.

    Afterwards serviceRecord.getAttributeValue(0x0003) returns 'null'.

    We are going to try to extract the uuid from a S40 Phone and use it to connect to our device
    Last edited by markdevries; 2006-08-29 at 09:57.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    As anticipated – no, you cannot search for RFCOMM. You will get all RFCOMM based services returned. Have a look at your service discovery, there will be several services returned.

    You have to connect to the service UUID of the service profile you are connecting to. If you do not know this UUID, output the whole service database of your printer. This can be done on a PC like BlueZ sdptool in Linux or another MIDlet either your own or a off-the-shelf one. Make sure to search for L2CAP in these tools. Then nearly all services get listed.

    You cannot search for RFCOMM in your current MIDlet. It is just luck, that it is working in your Nokia Series 40 device.

    No, 0x0003 does not help here. You need the unique UUID of 0x0001 which is neither L2CAP, RFCOMM nor SPP. This 0x0001 attribute is a DATSEQ of UUIDs. Either the first or last one is the one you are looking for.
    Last edited by traud; 2006-08-29 at 11:04.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Re: S60 Bluetooth issue

    Hi and Thanks for your Help,

    so you mean something like this?

    Code:
    Object first = null, last = null, temp = null;
    
    Enumeration e = (Enumeration) ((DataElement) serviceRecord.getAttributeValue(0x0001)).getValue();
    
    	
    		while (e.hasMoreElements()) {
    			if (temp == null) {
    				first = e.nextElement();
    				temp = first;
    			}
    			else
    				temp = e.nextElement();
    		}
    		last = temp;
    
    
    
    
    
    RuntimeObjects.agent.searchServices(null, 					
    					new UUID[] { new UUID((String) ((DataElement) last).getValue(),false ) },RemoteDevice, new BluetoothPrinterDiscoveryListener());
    I'm still looking for the error ... works neighter with first nor last... .


    We did a copy and paste with the first and last UUID´s in the list like this...

    new UUID[] { new UUID("11010000100080000084559fb34fd",false) }

    But we still hit that same NPException.
    Last edited by markdevries; 2006-08-29 at 17:48.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Not sure what you are doing there. For your current MIDlet you need the correct UUID. This cannot be RFCOMM or L2CAP.

    For your debugging MIDlet (to get the above UUID), you just retrive all services and output all UUIDs of attribute 0x0001. Then you have the UUID (and so more) you are looking from. Now you use each one of these UUIDs in your main MIDlet until it works. Then you know the UUID for sure and you can forget all other UUIDs.

    Or you take a Nokia Series 40 and extract attribute 0x0001 with the found service, because there it works you write.

    Or even better, look up the documentation of this printer and figure the UUID from there.

    Quote Originally Posted by markdevries
    11010000100080000084559fb34fd
    That is wrong – I think – as it is SPP…
    Last edited by traud; 2006-08-29 at 17:58.

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Re: S60 Bluetooth issue

    There is only one UUID in the List:

    serviceRecord.getAttributeValue(0x0001)).getValue();

    I didn't pay attention to the posibility that this could be the case when i tested the first and last UUID in the List (which are identical)



    What we are trying to do is to print from a 6670 to BT Printer.
    In the Printer Manual following Diagram is shown.

    Code:
    ---------------------------------------------
                Printer Application                           |
    ---------------------------------------------
                ^                       ^
                |                       |
                v                       |
              OPP                       |
               ^                        |
               |                        |
               v                        |
           | OBEX |                     v
    ----------------------------------------
    SDP |             RFCOM              | 
    ----------------------------------------
    L2CAP
    -----------------------
    HostControlerInterface
    -----------------------
    ......
    Sorry for the ASCII Art =;-)

    We are trying to connect to the printer application via RFCOM since the 6670 doesn´t support the obex protocol.
    Last edited by markdevries; 2006-08-30 at 10:14.

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Well, there must be more UUIDs. When you want to connect to the OBEX Push service, why not searching for it: 0x1105. Then use the returned service, forget ServiceRecord.getConnectionURL(…) – this is buggy in Nokia S60 anyway – and extract the RFCOMM channel ID yourself.
    Code:
    			DataElement protocolDescriptorList = record.getAttributeValue(0x0004);
    			Enumeration e = (Enumeration) protocolDescriptorList.getValue(); // DATSEQ | DATALT
    			e.nextElement(); // L2CAP (ignored)
    			DataElement protocolDescriptorRFCOMM = (DataElement) e.nextElement();
    			e = (Enumeration) protocolDescriptorRFCOMM.getValue(); // DATSEQ
    			e.nextElement(); // UUID (ignored)
    			DataElement channelRFCOMM = (DataElement) e.nextElement();
    			long channel;
    			if (DataElement.U_INT_8  == channelRFCOMM.getDataType() ||
    				DataElement.U_INT_16 == channelRFCOMM.getDataType() ||
    				DataElement.INT_16   == channelRFCOMM.getDataType() )
    			{
    				byte[] bytes = (byte[]) channelRFCOMM.getValue();
    				channel = bytes[0]; // Range (decimal): 1 up to 30
    			}
    			else
    			{
    				channel = channelRFCOMM.getLong(); // U_INT_1
    			}
    			
    			StringBuffer nameBuffer = new StringBuffer(5+3+12+1+2+19+14+13);
    			nameBuffer.append("btspp");
    			nameBuffer.append("://");
    			nameBuffer.append(record.getHostDevice().getBluetoothAddress());
    			nameBuffer.append(":");
    			nameBuffer.append(channel);
    			nameBuffer.append(";authenticate=false");
    			nameBuffer.append(";encrypt=false");
    			nameBuffer.append(";master=false");
    			
    			String name = nameBuffer.toString();
    			clientConn = (StreamConnection) Connector.open(name);
    Then you do OBEX yourself. Even when a JSR-82 devices does not ship with OBEX on board, you as application programmer can implement OBEX over RFCOMM yourself.

    Which services does this printer have at all? It has at least two as there are two different RFCOMM channel IDs visible in your previous posts.

  9. #9
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Re: S60 Bluetooth issue

    Hello again and thanks for the code snippet.

    It has 2 Services one for printing over the obex and one to print over the spp.

    If the spp one is selected

    ServiceRecord.getConnectionURL(…) delivers the same String that your code does...

    Hmm seems as is if the
    clientConn = (StreamConnection) Connector.open(name);

    Doesn´t throw that NPE, not sure yet though.

    Thanks for your help so far...we´ll post more as we advance.

  10. #10
    Registered User
    Join Date
    Aug 2006
    Posts
    6

    Re: S60 Bluetooth issue

    Hi,
    unfortunately we had another Bug in our App and so it looked as if the URL wasn't the Problem ... but it was... .

    Somehow our url got screwed up in our Midlet, but using your code Snippet and fixing the readout of the url out of our recordset fixed the Problem

    You were right all along... .

    Can't thank you enough for your help on solving this Problem !!!
    Thanks a lot.

  11. #11
    Registered User
    Join Date
    Jun 2007
    Posts
    45

    Re: S60 Bluetooth issue

    Hello,

    well..I would like to know how to choose a printer? are there any specific specs that we must look for before buying a BT printer.

    Our basic requirement is communicating with POS printer.

    After looking at this thread, i think we should know the UUID of the printer n the basis communication protocol (RFCOMM/L2CAP)

    Thanks in advance.

    Jinen

Similar Threads

  1. Problem with s60 emulator when bluetooth server is listening
    By TD-A in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-04-08, 16:05
  2. Draw a bitmap on screen -- The compatibility issue in S60 and S60_FP3
    By steveyzhang in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-03-16, 09:20
  3. PC Suite not detect 6600 with Bluetooth connection
    By spinacle in forum Bluetooth Technology
    Replies: 29
    Last Post: 2004-03-14, 23:24
  4. Suggestion for resolving PC suite connection via bluetooth
    By Kazi in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-03-14, 19:35
  5. Nokia 6210 Bluetooth Connectivity Pack
    By peter-h-hansen in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-08-19, 12:52

Posting Permissions

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