×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    1

    javax.io.IOException and P2Pexample problems

    Hi all,

    I am doing tests about P2P NFC functionality with Nokia 6131 NFC.

    I have two problems:

    1) First, I am doing these steps:

    1.a) Show a main Form with a Send button. Inside the send method I show a alert with a back button and call this fuction:

    Code:
    conn = (NFCIPConnection) Connector.open(INITIATOR_URL);
    1.b) With this function, the mobile waits until a Target is in the near field. When it is detected, I call send/receive functions. Untill this point, all is fine.

    1.c) After send/receive is complete, I call

    Code:
    conn.close();
    and in the same Alert, I show "Transfer complete".

    1.d.1) I press back button and return to main Form and do again from 1.a) step and the execution
    is fine.

    1.d.2) But if I press back button in this line:

    Code:
    conn = (NFCIPConnection) Connector.open(INITIATOR_URL);
    Then in the next attempt, I always get the exception:

    Code:
    javax.io.IOException;
    in that point:

    Code:
    conn = (NFCIPConnection) Connector.open(INITIATOR_URL);

    Main code:

    Code:
      NFCIPConnection conn = null;
    
      public void run() {
            try {
                conn = (NFCIPConnection) Connector.open(INITIATOR_URL); //if i press back button in this point, I get javax.io.IOException the next time is called
                
                if (conn == null) {
                    midlet.showError("conn is null");
                    return;
                } else {
                    setString("found target!");
                }
    
                conn.send(sendBuffer);
                byte[] receiveBuffer = conn.receive();
                            
               
                if (receiveBuffer == null) {
                    setType(AlertType.ERROR);
                    setString("receive buffer is null");
                } else {
                    setType(AlertType.CONFIRMATION);
                    setString("Transfer complete!");
                }
                
                
            } catch (Exception ioe) {
                String msg = ioe.getClass().getName() + " " + ioe.getMessage();
    
                if (ioe instanceof NFCException) {
                    msg += (" code=" + ((NFCException) ioe).getErrorCode());
                }
                
                setString("Error: " + msg);
    
            } finally {
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (IOException e) {
                        midlet.showError("IOException " + e.getMessage());
                    }
                }
            }
        }
    
        public void commandAction(Command command, Displayable displayable) {
            if (command == commandBack) {
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (IOException e) {
                        midlet.showError("IOException " + e.getMessage());
                    }
                }              
                //Back to main form
                midlet.showInit();
            }
        }

    Any ideas about this situation?

    2) I bought two Nokia 6131 NFC mobile phones from toptunniste. With one of them, the P2Pexample works without problems in initiator mode but in the other does not.

    Anyone has the same problem?


    Thanks very much!

    Kind regards,
    Eduardo
    Last edited by EduHdez; 2007-09-27 at 08:53.

Posting Permissions

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