You Are Here:

Community: Developer Discussion Boards

#1 Old Nokia 6680 and InputStream OutputStream - 2006-04-03, 17:11

Join Date: Sep 2004
Posts: 11
eoghanconnolly
Offline
Registered User
I have an app using Bluetooth which I am trying to get working on a Nokia 6680. It seems to be working okay on a 6600, but for some reason I am getting IOExceptions on the 6680 when I try to use either an InputStream or OutputStream. I don't know why it would work on one phone and not another. Anyone got any ideas?

Client code seems to fall over on. Here out is an OutputStream:
conn = (StreamConnection)Connector.open(connString);
out = conn.openOutputStream();

Server code seems to fall over on. Here out is a ByteArrayOutputStream used to collect the input and use it. in is an InputStream:
while ((data = in.read()) != -1) {
out.write(data);
}


Thanks

Owen
Reply With Quote

#2 Old Re: Nokia 6680 and InputStream OutputStream - 2006-04-14, 19:01

Join Date: Sep 2004
Posts: 11
eoghanconnolly
Offline
Registered User
In case anyone else has the same problem and reads this post looking for a solution - the workaround suggested by Nokia (from documentation on this website) is to use L2CAP instead of RFCOMM for the application. I have implemented this and it works better. There is still another problem with the 6680, but the 6680 can receive incoming data without any problems using L2CAP.
Reply With Quote

#3 Old Re: Nokia 6680 and InputStream OutputStream - 2006-07-12, 19:30

Join Date: Jul 2006
Posts: 1
duncanray
Offline
Registered User
Owen,

I'm studying for a Masters Degree in Human Computer Interaction in the UK at the moment. For my final project I desperately need to get bluetooth working between two 6680s but none of the examples I've thus far come across seem to work on them. Sadly without the app, my whole evaluation will not work. I have to get this completed within the next week so can cheekily request a working example from you? I will be very grateful if you are able to assist me and I will personally ensure that your code will go no further than this project.

Thanks,
D
Reply With Quote

#4 Old Re: Nokia 6680 and InputStream OutputStream - 2006-07-12, 21:19

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Quote:
It seems to be working okay on a 6600, but for some reason I am getting IOExceptions on the 6680 when I try to use either an InputStream or OutputStream. I don't know why it would work on one phone and not another. Anyone got any ideas?
The 6600 has many documented differences on MIDP 2.0 for 6600 as found in

Known Issues In The Nokia 6600 MIDP 2.0 Implementation v1.7

see page 15 says:-
Quote:
2.30 Using Bluetooth Serial Port in MIDlets
Description
Reading incoming stream does not work properly. When the Bluetooth Serial Port Profile (RFCOMM protocol) is used, reading incoming stream is sometimes interrupted with IOException. .The read() method of the InputStream class may throw an IOException if the other end has closed the stream while the InputStream is still reading it
Another issue is that the InputStream cannot use a bigger array than 512 bytes when reading stream. A bigger byte array may crash the MIDlet.
Run, for example, the BtsppEcho example application to reproduce the issue.

The PC suite has a version specifically for "PC suite for Nokia 6600" the latest version 6.8 will not work properly with the 6600.

Jim
Last edited by jimgilmour1 : 2006-07-13 at 06:00.
Reply With Quote

#5 Old Re: Nokia 6680 and InputStream OutputStream - 2006-07-12, 21:34

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Quote:
For my final project I desperately need to get bluetooth working between two 6680s but none of the examples I've thus far come across seem to work on them. Sadly without the app, my whole evaluation will not work.
Well if you need Java use the Sun WTK
http://developers.sun.com/techtopics/mobility/getstart/
http://java.sun.com/products/sjwtool...nload-2_2.html

and if you and to use the bluetooth example in
C:\WTK22\apps\BluetoothDemo\src\example\bluetooth\demo which contains the java source.

See the thread Bluetooth s60 Programming

and you will need to load Carbide.c++ Express

Quote:
The first free version of a C++ IDE targeting development of Symbian OS applications on standard SDKs is now available. The tool quickly guides the newcomer though all the steps required to write, build, and deploy a Symbian OS application on a mobile phone. Developers with experience working in an Eclipse integrated development environment (IDE) will feel right at home, and experienced Symbian programmers will be able to put their skills to work right away.
-------------------------------------------------------------------
Java wtk2.2
-------------------------------------------------------------------
PHP Code:
/* FTPserviceMIDlet.jar */ 
package phone.server;
//import com.sun.midp.io.j2me.storage.File;
//import net.benhui.bluecove.spp_bt;

import java.util.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.io.file.*;

//import javax.obex.*;

//Screen Midlet and display
import javax.microedition.midlet.*;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TextField;

import javax.bluetooth.*;

// uses the de.avetana OBEX library 
import de.avetana.obexsolo.OBEXConnector;
import de.avetana.javax.obex.HeaderSet;
import de.avetana.javax.obex.Operation;
import de.avetana.javax.obex.ResponseCodes;
import de.avetana.javax.obex.ServerRequestHandler;
import de.avetana.javax.obex.SessionNotifier;

public class 
FTPserviceMIDlet extends MIDlet implements CommandListener {

   private 
FileServer fServer;
       
/** Soft button for exiting the demo. */
    
private final Command EXIT_CMD = new Command("Exit"Command.EXIT, 2);

    
/** Soft button for launching a client or sever. */
    
private final Command OK_CMD = new Command("Ok"Command.SCREEN1);

    
/** A list of menu items */
    
private static final String[] elements = { "Server""Client"};

    
/** A menu list instance */
    
private final List menu = new List("FTPservice", List.IMPLICIT,
            
elementsnull);

 
    
//JLabel spacerlabel = new JLabel(" ");

    //JButton startButton = new JButton("Start Server");
    //JTextArea textarea = new JTextArea("",20, 40);    

    
public FTPserviceMIDlet(){
                    
menu.addCommand(EXIT_CMD);
                    
menu.addCommand(OK_CMD);
                    
menu.setCommandListener(this);
        }
        public 
void startApp() {
            
show();
        }
        protected 
void destroyApp(boolean unconditional) {
        
// nothing to destroy needed as override to midlet
        

        public 
void pauseApp() {
        
// nothing to do needed as override to midlet}
        
}
   
/**
     * Responds to commands issued on "client or server" form.
     *
     * @param c command object source of action
     * @param d screen object containing actioned item
     */
    
public void commandAction(Command cDisplayable d) {
        if (
== EXIT_CMD) {
            
destroyApp(true);
            
notifyDestroyed();
            return;
        }

        switch (
menu.getSelectedIndex()) {
        case 
0:
            
fServer = new FileServer(this);
            break;
        case 
1:
 

           
//FTPClient = new FTPClient(this);
            
break;
        case 
2:
        
//uuidClient = new UUIDinput(this);
             
break;
        default:
            
System.err.println("Unexpected choice...");
            break;
        }
    }

    
/** Shows main menu of MIDlet on the screen. */
    
void show() {
        
Display.getDisplay(this).setCurrent(menu);
    }

    
/**
     * Returns the displayable object of this screen -
     * it is required for Alert construction for the error
     * cases.
     */
    
Displayable getDisplayable() {
        return 
menu;
    }


// Display the new messages

      
public void updateStatus(String stringOpMsg){
           
menu.append((String) stringOpMsgnull);
           
Display.getDisplay(this).setCurrent(menu);
      }

//    public static void main(String[] args) {
//
//        new FileServer();
//
//    }
//





See next post for file server.jar

Jim
Last edited by jimgilmour1 : 2006-07-13 at 06:19. Reason: formatting
Reply With Quote

#6 Old Re: Nokia 6680 and InputStream OutputStream - 2006-07-13, 06:24

Join Date: Dec 2005
Posts: 1,159
Location: England,UK
jimgilmour1's Avatar
jimgilmour1
Offline
Forum Nokia Champion
Hi,
Here is second part the fileserver.jar

---------------------------------------------------------------

file server
---------------------------------------------------------------
PHP Code:
/* FileServer.jar */
package phone.server;
//import com.sun.midp.io.j2me.storage.File;
//import net.benhui.bluecove.spp_bt;

import javax.bluetooth.*;

//for alert on screen
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;

// uses the de.avetana OBEX library 
import de.avetana.obexsolo.OBEXConnector;
import de.avetana.javax.obex.HeaderSet;
import de.avetana.javax.obex.Operation;
import de.avetana.javax.obex.ResponseCodes;
import de.avetana.javax.obex.ServerRequestHandler;
import de.avetana.javax.obex.SessionNotifier;

import javax.obex.*;
import java.io.OutputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;


public  class 
FileServer extends ServerRequestHandler {
      
// Bluetooth singleton object
        
LocalDevice device;
        
DiscoveryAgent agent;
        
OutputStream fos;
        
FileConnection fc;
        
    static final 
int ALERT_TIMEOUT 2000;
    private 
String fname;

       public 
FileServer(FTPserviceMIDlet parent){
//        startButton.setEnabled(false);
//        display = Display.getDisplay(this);
        
try {
            
UUID uuid = new UUID("9106"true);
                        
device LocalDevice.getLocalDevice(); // obtain reference to singleton
                        
device.setDiscoverable(DiscoveryAgent.GIAC); // set Discover mode to LIAC

            
String url "btgoep://localhost:" uuid ";name=FTP;authenticate=false;master=false;encrypt=false";

            
SessionNotifier sn = (SessionNotifier)Connector.open(url);
                              
// Retrieve the service record template
                        //ServiceRecord rec = device.getRecord( sn );
                        // set ServiceRecord ServiceAvailability (0x0008) attribute to indicate our service is available
                        // 0xFF indicate fully available status
                        // This operation is optional
                        //rec.setAttributeValue( 0x0008, new DataElement( DataElement.U_INT_1, 0xFF ) );

            
updateStatus("[server:] Now waiting for a client to connect");
            
sn.acceptAndOpen(this);
        
            
updateStatus("[server:] A client is now connected");    
        } catch (
Exception ex){
        }            
        
       }



    public 
int onConnect(HeaderSet requestHeaderSet reply) {
        
updateStatus("[server:] The client has created an OBEX session");
        return 
ResponseCodes.OBEX_HTTP_OK;
    }
    
    
    public 
int onPut (Operation op) {
                try{
                    
fname =op.getReceivedHeaders().getHeader(HeaderSet.NAME) + " type " op.getType();

                } catch (
Exception e) {
                    
String s "Operation error filename header error '"fname;
                          
                     if (
e.getMessage() != null && e.getMessage().length() > 0) {
                        
+= "\n" e;
                            }
                            
Alert alert = new Alert("Error!"snullAlertType.ERROR);         
                            
alert.setTimeout(ALERT_TIMEOUT );
 
                }
                
        try {
            
java.io.InputStream is op.openInputStream();
            
            
updateStatus("Got data bytes " is.available() + " name " fname);
            
            
// this code is for java server on PC JRE with Bluecove.jar 
            //File f = new File((String)op.getReceivedHeaders().getHeader(HeaderSet.NAME));
            //FileOutputStream fos = new FileOutputStream (f);
            // this will open file on phone
            
                    
FileConnection fc = (FileConnectionConnector.open("file:///" +
                    (String)
op.getReceivedHeaders().getHeader(HeaderSet.NAME));
                        
fc.create();
                        
// open the file stream
                        
fos fc.openOutputStream();
            
byte b[] = new byte[1000];
            
int len;
            
//copy over data while its available
            
while (is.available() > && (len is.read(b)) > 0) {
                
fos.write (b0len);
            }
            
//close output file
            
fos.close();
 
                   } catch (
Exception e) {
                            
String s "Can not create file '"fname;
                         
                            if (
e.getMessage() != null && e.getMessage().length() > 0) {
                        
+= "\n" e;
                            }
                            
Alert alert = new Alert("Error!"snullAlertType.ERROR);         
                            
alert.setTimeout(ALERT_TIMEOUT );
////                    Display.getDisplay(FileServer.menu).setCurrent(alert);
                            
e.printStackTrace(); 

            }
                        
        return 
ResponseCodes.OBEX_HTTP_OK;
    }
        

// when finished disconnect command is sent

    
    
public void onDisconnect (HeaderSet reqHeaderSet resp) {
                        
        
updateStatus("[server:] The client has disconnected the OBEX session");
                                
    }




    public 
void updateStatus(String message){

        
//textarea.append("\n" + message);

    
}





So thats it for Java Midlets.

If you want to visually debug you will need netbeans and netbeans mobility and lots of patience to learn it.

Jim
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
6680 HttpConnection Content-Length problem jhodgski Mobile Java General 10 2007-04-18 10:29
Adding picture to the contact using jsr75 (NOKIA 6630,6680) manik_jandial Mobile Java General 8 2007-04-02 10:05
InputStream problems on the 6680 iandebeer Mobile Java Networking & Messaging & Security 20 2007-03-29 05:17
SocketConnection Work on 6600&Emulators BUT NOT IN 6680 eerant Mobile Java Networking & Messaging & Security 4 2006-03-11 01:35
Nokia 6680 Player from an InputStream Problem bogdan_m Mobile Java Media (Graphics & Sounds) 1 2005-07-05 09:56

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia