×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    21

    Bluetooth pulls me to hell !!!!!!

    Hi,
    I want to connect phone to pc with bluetooth through rfcomm. the functions have no error, but in pc side, HyperTerminal can not receive any chars. who can help me out of the hell.

    the test code is

    Code:
     StartC32();
        User::LeaveIfError(iSocketServ.Connect());
    
        // Try to open bluetooth selection dialog to get the name and address of the device
        TBTDeviceResponseParamsPckg aResponse;
        
        RNotifier notifier;
        User::LeaveIfError(notifier.Connect());
      
        TBTDeviceSelectionParamsPckg selectionFilter;
    
        TRequestStatus status;
        notifier.StartNotifierAndGetResponse(
            status,
            KDeviceSelectionNotifierUid,
            selectionFilter,
            aResponse
        );
    
        User::WaitForRequest(status);
    
        if (status.Int() != KErrNone)
        {
            notifier.CancelNotifier(KDeviceSelectionNotifierUid);
            notifier.Close();
        }
    
        notifier.CancelNotifier(KDeviceSelectionNotifierUid);
        notifier.Close();
        
        iName = aResponse().DeviceName();
        iAddr = aResponse().BDAddr();
    
        // load protocol, RFCOMM
        TProtocolDesc pdesc;
        User::LeaveIfError(iSocketServ.FindProtocol(_L("RFCOMM"), pdesc));
    
        // open socket
        User::LeaveIfError(iSock.Open(iSocketServ, pdesc.iAddrFamily,pdesc.iSockType,KRFCOMM));
        // set address and port
        TBTSockAddr addr;
        addr.SetBTAddr(iAddr);
            
        // get listening channel
        TInt channel;
        User::LeaveIfError(iSock.GetOpt(KRFCOMMGetAvailableServerChannel, 
                KRFCOMM, channel));
        addr.SetPort(1);
        
        // connect socket
        TRequestStatus cstatus;
        iSock.Connect(addr, cstatus);
        User::WaitForRequest(cstatus);
        User::LeaveIfError(iStatus.Int());
    
        _LIT8(buf,"123123123123");
        iSock.Write(buf, iStatus);
        User::WaitForRequest(iStatus);
        User::LeaveIfError(iStatus.Int());

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Bluetooth pulls me to hell !!!!!!

    This is not the way how BT works. "GetAvailableServerChannel" gets the port where you (on the device) could start offering a service.
    For finding out the channel you would have to connect to, you have to do service discovery, the CSdpAgent-stuff, and get the Protocol Desciptor List. Check existing BT examples in order to find out the details.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    21

    Re: Bluetooth pulls me to hell !!!!!!

    Hi, wizard_hu_
    Thanks a lot.
    I have know how bluetooth work. There are many steps to use bluetooth, my code do not find out the service, so the SetPort is wrong.
    do you mean my code is only need service discovery?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Bluetooth pulls me to hell !!!!!!

    There are many steps to use bluetooth, my code do not find out the service, so the SetPort is wrong.
    It does not even tries, you have hard coded "1" as port. Service discovery would provide better results I think.

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    21

    Re: Bluetooth pulls me to hell !!!!!!

    Thank you for your reply. I will try to service discovery to find out a port.

Similar Threads

  1. detecting if bluetooth is enabled (Series 40)
    By dspoeri in forum Mobile Java General
    Replies: 2
    Last Post: 2009-05-01, 13:08
  2. Successfully Connected Using Bluetooth with Pc Suite
    By zrilo in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-04-09, 04:21
  3. PC Suite not detect 6600 with Bluetooth connection
    By spinacle in forum Bluetooth Technology
    Replies: 29
    Last Post: 2004-03-14, 23:24
  4. Nokia 6210 Bluetooth Connectivity Pack
    By peter-h-hansen in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-08-19, 12:52

Posting Permissions

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