×

Discussion Board

Results 1 to 8 of 8

Thread: PeerToPeer Chat

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    18

    PeerToPeer Chat

    Hi everbody,

    I wrote peer to peer chat program . I got codes from this link. http://wiki.forum.nokia.com/index.ph...r_to_peer_chat
    When it works , I touched phone to other nokia 6131 nfc phone but nothing happend. It cant recognize other phone.

    Where is the my mistake ? How does it work ? Can you help me ?

  2. #2
    Registered User
    Join Date
    Jan 2011
    Posts
    11

    Re: PeerToPeer Chat

    Is the NFC turned on in the phone's settings ?
    Did you put the right permissions in the JAD file ?

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    18

    Re: PeerToPeer Chat

    yes, NFC is turned on. Which permission I have to put ?

  4. #4
    Registered User
    Join Date
    Jan 2011
    Posts
    11

    Re: PeerToPeer Chat

    I just checked, no particular permission is required for this to work.
    I had this example working on two 6212 and it worked fine as far as I remember.
    Are the two applications properly launched on both 6131? Do you put the phone in the right position to connect? Because sometimes the NFC antenna can be a bit capricious

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    18

    Re: PeerToPeer Chat

    Two applications are launched on two 6131. I dont know right position. I just put one 6131 next to other 6131. and I touched 6131 to other's cover.

  6. #6
    Registered User
    Join Date
    Jan 2011
    Posts
    11

    Re: PeerToPeer Chat

    If I remember well the antenna is on the top part of the phone when it's open, try aiming at that part.
    Try reading a normal tag to make sure the handsets' NFC work properly.
    Eventually consider simplifying your code to understand what happens. Something like below:

    Code:
    form.append("Waiting for connection...");
     try {
    	Connector.open(TARGET_URL /* INITIATOR_URL on the other phone */);
    } catch (IOException e) {
    	form.append(e.getMessage());
    }
    form.append("Connected!");

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    18

    Re: PeerToPeer Chat

    I wrote two program for phones. One of them has target code,other has initiator codes like as below. Both of them work with normal nfc tags . but still cant connect each other.

    Code for Target phone

    Code:
    public void run() {
    			NFCIPConnection conn = null;
    			// Reading state
    			if (reading) {
    				// Read while in reading state
    			while (reading) {
    				try {
    					// Start waiting for other phone to initiate connection,
    					// blocks until connection made or another NFCIP connection
    					// open called
    					conn = (NFCIPConnection) Connector.open(TARGET_URL);
    						// Receive data from connection
    					byte[] data = conn.receive();
    						// Send empty message to connection
    					conn.send(null);
    						// Append received string to form
    					form.append(">> " + new String(data) + "\n");
    						// Close connection
    					conn.close();
    				} catch (Exception ex) {
    				try {
    					if (conn != null) {
    					conn.close();
    					}
    				} 
    				catch (IOException e) {
    				}
    			  }
    			}
    Codes for Iniatitor Phone
    Code:
    while (writing) {
    			try {
    				// Try to connect another phone, blocks until connection
    				// made or another NFCIP connection open called
    			conn = (NFCIPConnection) Connector.open(INITIATOR_URL);
    				// Send string from TextBox to connection
    			conn.send(writeTb.getString().getBytes());
    				// Receive reply
    			conn.receive();
    				// Append sent message to form
    			form.append("<< " + writeTb.getString() + "\n");
    				// Close connection
    			conn.close();
    			display.setCurrent(form);
    			read();
    			}
    			catch (Exception ex) {
    			try {
    					if (conn != null) {
    						conn.close();
    				}
    					
    			} catch (IOException e) {}
    		}
    	  }

  8. #8
    Registered User
    Join Date
    Jan 2011
    Posts
    11

    Re: PeerToPeer Chat

    Well if, like you said, the Connector.open() method doesn't return then I have no clue of what might be the problem.

Similar Threads

  1. How to create chat server and chat client using J2ME....
    By mapetos in forum Mobile Java General
    Replies: 24
    Last Post: 2011-08-08, 13:19
  2. Chat Script
    By pandailo in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2007-10-29, 11:21
  3. need help on developing chat server for J2ME chat client
    By sheetal_21 in forum Mobile Java General
    Replies: 6
    Last Post: 2007-09-30, 07:44
  4. Scatternet Chat?!
    By TommyMo in forum Bluetooth Technology
    Replies: 3
    Last Post: 2005-06-03, 12:06
  5. Bluetooth Chat
    By adem77 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-05-31, 10:17

Posting Permissions

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