×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    16

    Using non-UI guided Bluetooth device inquiry -- issues

    Hello,

    I have previously asked a few questions regarding more 'programmatic' inquiry into Bluetooth Device Inquiry (i.e. not using the User Interface provided by RNotifier) and have seen the example code and instructions regarding RHostResolver and I am very thankful for those pointers. However, I seem to be running into a small problem.

    I start with the usual example code, for my test case:

    RHostResolver hr;
    User::LeaveIfError(hr.Open(socketServ,pInfo.iAddrFamily,pInfo.iProtocol));

    TInquirySockAddr addr;
    TNameEntry entry;
    addr.SetIAC(KGIAC);
    addr.SetAction(KHostResInquiry|KHostResName);
    TRequestStatus status;
    hr.GetByAddress(addr, entry, status);
    User::WaitForRequest(status);


    Then I successfully extract the devicename of the other BT device in my vicinity (I'm using the Emulator with BT card as the 'inquirer' and a Nokia 3650 as the other device). That is to say, the following code succeeds and properly prints the device's name.

    TPtrC deviceName;
    if (status == KErrNone)
    deviceName.Set(entry().iName);

    iEikonEnv->InfoMsg( deviceName );

    However, I seem to be completely unable to extract the other device's Bluetooth Address. I am a bit unsure of where I should be looking? Do I extract the BT Address from the "entry" TNameEntry object like I have extracted the name? Would I do so in a fashion such as this:

    TBTSockAddr testBTSockAddr = entry().iAddr;

    I have tried that and it did not appear to succeed.

    I suppose what I'm trying to ask is: after the proper completion of "RHostResolver::GetByAddress", while doing a Bluetooth Inquiry, where does the Bluetooth address of the remote device get placed and how do I properly extract it?

    Many thanks in advance.

    -Tal

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    16
    Well, seems that after a number of hours banging my head against it, I have come to a conclusion. I hope that my experience helps others.

    First off: After GetHostByAddress is called, the Bluetooth address of the first remote device can be accessed by first creating a TBTSockADDR from the TNameEntry buffer:

    TBTSockAddr iBTSockAddr( entry().iAddr);

    And then using that object's .BTAddr() call as follows:

    iBTSockAddr.BTAddr()

    Which returns the TBTDevAddr.


    I had a good deal of trouble with this because many bluetooth socket operations will fail, at least if the emulator is a client, if you leave a RHostResolver object open while trying to attempt them. For some reason, you must close any open RHostResolvers declared in that function block for things like socket connectivity to work and this was hindering my ability to test the proper inquiry of addresses.

    I hope this helps.

Posting Permissions

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