×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    6

    How to detect p2p devices with timeout? / Random p2p UID

    Hello programmers!


    I'm currently making my first steps with the Nokia 6131 NFC / J2ME programming. I'm trying to create a program that is able to enumerate remote devices in range. Therefore I use the TargetListener pattern as described in various posts and examples. That works just fine, I add the TargetListener to the DiscoveryManager for a given amount of time and remove it afterwards. All discovered devices are recorded meantime. I hope this is the correct way to do this.
    Afterwards (or before that, that shouldn't matter, or am I wrong?) I try to detect a remote peer-to-peer device and that's where my problems start: I can only determine if there is a remote device by trying to establishing a connection, as far as i know. But because the function call to establish the connection is blocking and doesn't offer a timeout mechanism, I've to put it into a thread. So I start the thread, wait for a given amount of time and and check if the thread detected the remote device. If so, I close the connection and every thing's just fine. But what if there is no remote device? My thread is blocked (for ever?) and the main program has to abort the thread somehow. At the moment I do this by setting the thread-variable holding the instance of the thread to null and this works. Although I'm new to Java programming, it seems like a terribly wrong way to do this. My question: How to abort the blocking function call to establish a peer-to-peer connection after a given amount of time without violating the paradigms of the Java programming language and without leaving the NFC connection object in an undefined state.

    Another question: Is it possible to get the (random) UID used for an peer-to-peer connection?

    I hope I explained my problem well enough, if not so, feel free to post questions. I can also post Java code if required.


    Greetings, Korexio

  2. #2
    Regular Contributor
    Join Date
    Jul 2007
    Location
    Lisbon - Portugal
    Posts
    96

    Re: How to detect p2p devices with timeout? / Random p2p UID

    You can indeed set a timeout.

    See this.

    In that page, search for "timeout".

    Opening the connection with "nfc:rf;type=nfcip;mode=initiator;timeout=5000", will get you a 5 sec timeout.

    Cheers.

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

    Thumbs up [Solved]

    Thanks for the link, that helped!

Similar Threads

  1. cannot detect devices
    By theinvincibleironman in forum General Development Questions
    Replies: 1
    Last Post: 2007-12-03, 08:44
  2. Network timeout on Series 40 devices
    By mpo in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2006-11-30, 17:27
  3. How to detect side volume key in Series 40 devices.
    By gimmins in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-05-12, 08:06
  4. detect the model of the found devices
    By jlressia in forum Bluetooth Technology
    Replies: 1
    Last Post: 2006-05-11, 16:25
  5. Discovering BT devices with HostResolver: Timeout question
    By tvollmer in forum Bluetooth Technology
    Replies: 2
    Last Post: 2003-10-20, 09:37

Posting Permissions

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