×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Berlin
    Posts
    7

    Bluetooth discovery with device scanning

    Hi Symbian guru's!

    I develope bluetooth application which will scan all neighbourhood bt device's and discover service attributes from those device's.

    Steps are next: 1. Scan 1st device
    2. Discover service atrributes from the 1 st
    device
    3. Scan next device
    4. Discover service atrributes from the next
    device
    5. Scan.....

    I use ListServicesL() method from the Discovery example to list service attributes. After ListServicesL() call I have a request which will wait until service attributes are listed before application will scan a new device.

    My problem is that if I use request (WaitForRequest or SetActive)after ListServicesL() call, ListServicesL method will not list service attributes any more.
    If I don't use request after ListServicesL, application will scan next device before service attributes are listed from the former device.
    I have also edited little bit ListServicesL method so that it has now TRequestStatus& aObserverRequestStatus. Now it will chance aObserverRequestStatus if service listing is finished.


    My code is here:

    void CDiscoverTest::ScanL()
    {
    User::LeaveIfError(iSocketServer.FindProtocol(_L("BTLinkManager"), protocolInfo));

    User::LeaveIfError(iHr.Open(iSocketServer,protocolInfo.iAddrFamily,protocolInfo.iProtocol));

    iAddr.SetIAC(KGIAC);
    iAddr.SetAction(KHostResName|KHostResInquiry);
    iHr.GetByAddress(iAddr, iRemoteDeviceName, iStatus);
    User::WaitForRequest(iStatus);
    iNotifier->Print(_L("Device's are scanned"));

    if(iStatus.Int()==KErrNone)
    {
    iDevAddr = TBTSockAddr(iRemoteDeviceName ().iAddr).BTAddr();
    deviceName.Set(iRemoteDeviceName().iName);
    iNotifier->Print(deviceName);
    PrintLine(_L("Retrieving services..."));
    iDiscoverer->ListServicesL(iDevAddr,iStatus2);
    User::WaitForRequest(iStatus2); /*or SetActive() if using active object. PROBLEM is here, this will block service listing*/
    }
    else
    {
    iNotifier->Print(_L("no bt device found!"));
    }

    if(iStatus.Int()==KErrNone)
    {
    while(iHr.Next(iRemoteDeviceName) != KErrHostResNoMoreResults)
    {
    iDevAddr = TBTSockAddr(iRemoteDeviceName().iAddr).BTAddr();
    deviceName.Set(iRemoteDeviceName().iName);
    iNotifier->Print(deviceName);
    PrintLine(_L("Retrieving services..."));
    iDiscoverer->ListServicesL(iDevAddr,iStatus2);
    User::WaitForRequest(iStatus2); /*or SetActive() if using active object, PROBLE is here*/
    }
    iNotifier->Print(_L("no more bt device's found!"));
    }

    iHr.Close();
    }



    Br AK

  2. #2
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    You can't have two Bluetooth requests like device inquiry and service discovery active at the same time. First discover *all* devices (until KErrEof == KErrHostResNoMoreResults) and keep a local copy of the found devices. Then go through the results and discover their services.

    Lauri

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Berlin
    Posts
    7
    Thanks Lauri, I got idea.

Posting Permissions

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