×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    192

    Possible to do service search without device search?

    I thought that you could carry out a service search without having to do a device search beforehand as long as you knew the address of the remote device.
    But I see that the they made the constructor of the RemoteDevice protected and there is no method setBluetoothAddress. Why do they do this? Is it to force us to always do a device search beforehand?

  2. #2
    Regular Contributor
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    66

    Re: Possible to do service search without device search?

    Hi ed,

    This document could help you a whole lot!
    http://www.forum.nokia.com/.../MIDP_Bluetooth_API_Developers_Guide_v2_0_en.pdf.html

    Here is a part of this document that could help you:

    "As an alternative to performing device inquiry, an application might use a list of preknown or cached devices. The method retrieveDevices of the DiscoveryAgent class can be used to request a list of known RemoteDevice objects. However the method retrieveDevices does not provide the COD, nor does class RemoteDevice provide that information. (See the previous paragraph about the importance of filtering devices based on their COD.)"

    Hope it helps,

    Jackson

  3. #3
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    192

    Re: Possible to do service search without device search?

    Thanks for the answer.
    The problem I have is that I have an application that stores the url of a custom service, but as the channel number can change it needs to do a service discovery on that device. Doing a complete device discovery again is a rather waste as you already have the bluetooth address.
    I tried to hack a way around it by overriding the RemoteDevice class and setting the address in the constructor and it does work on SE W550, but on Motorola V3x it fails, so it seems that it was never intended to be used that way.
    I would consider this is a very basic need, but looks like jsr82 is just not very well designed.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Did you change the header and made the constructor public instead of protected?

    Use DiscoveryAgent.selectService which is no help as it is unreliable, as it uses the unreliable getConnectionURL, and doing a device and service search under the hood anyway.

    Alternatively, just connect with that device:channel and then check whether the ServiceRecord it is still your service. Then you have a RemoteDevice instance, too, for a subsequent service search.

    Alternatively, when you realize, channel numbers change frequently, use one of the default profiles like DUN or Headset and store its channel number. I do not think these will change so often although such a service could disappear – I have seen that with devices. Alternatively, use the lowest RFCOMM channel number … there are just 30 possible channels, iterate over them.

    Unfortunately (as far as I know) it is not possible to do a service search on your own (always connecting to PSM 0x0001). As this service is there always, this would be the next solution. Again, this seems blocked as the lowest PSM must be 0x1001.

    Actually, this is no basic need as mobile device come and go normally and for best user experience their availability should rather be checked than just point and shot. Nevertheless, no one would have be hurt making that constructor public. File a bug report to the JSR …
    Last edited by traud; 2007-05-20 at 19:02.

  5. #5
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    192

    Re: Possible to do service search without device search?

    Quote Originally Posted by traud
    Did you change the header and made the constructor public instead of protected?
    Yes.
    Quote Originally Posted by traud
    Actually, this is no basic need as mobile device come and go normally and for best user experience their availability should rather be checked than just point and shot.
    In this case there is a need. The app only ever connects to one device and user will typically be connecting very frequently.

    Trying different channels is an interesting idea. If the connection fails with the orgional channel, I could just try the channel below and above.

    Anyways, thanks for the advice.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    You missed the word basic in my answer. From my experience device and service discovery is quite fast, well, whether it is fast enough for you of course depends.

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Quote Originally Posted by ed_welch
    I see that the they made the constructor of the RemoteDevice protected and there is no method setBluetoothAddress.
    There is a trick:
    Original by Bluetooth Application Programming with the Java APIs page 132 and there page 37
    Code:
    import javax.bluetooth.*;
    public class MyRemoteDevice extends RemoteDevice
    {
    	public MyRemoteDevice(String address)
    	{
    		super(address);
    	}
    }
    Quote Originally Posted by ed_welch
    Why do they do this?
    Although they are the co-authors of JSR-82, they give no rationale for this either. Perhaps there is a design pattern which I miss.

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    Re: Possible to do service search without device search?

    hi user traud
    iam siva(user:avis86) thanks for ur reply but the idea you gave was already tried,i had seen a book called java i/o they had said that it is possible to establish a connection with a known device without device discovery (using generic connection frame work via a url in RFCOMM)do u know how to perform the coding via that .... advance thanks and u r a regular contributor to all .

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    avis86, why doesn’t work this RemoteDevice subclass trick in your situation?

Similar Threads

  1. Bluetooth HID Device Service on N80
    By Camford in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-11-22, 14:58
  2. Bluetooth Security: What exactly is an untrusted device?
    By rahulmcs in forum Bluetooth Technology
    Replies: 1
    Last Post: 2005-12-02, 06:26
  3. 6680 and bluetooth service profiles
    By ceruault in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-10-08, 22:24
  4. Service Search Device Not Reachable
    By sahink in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-09-09, 13:21
  5. Replies: 5
    Last Post: 2003-02-07, 11:25

Posting Permissions

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