×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    161

    bluetooth power-off

    How to determine whether bluetooth device was powered off while reading info?
    Our application just pending on read operation.
    Code:
    	TBuf8<1>bufT;
    	TSockXfrLength iLen;
    	TRequestStatus status;
    	iSock.CancelRead();
    	iSock.RecvOneOrMore(bufT,0,status,iLen);
    	User::WaitForRequest(status);
    i try use timer for interupt pending, but get CBASE46 error in this code:
    Code:
    	TBuf8<1>bufT;
    	TSockXfrLength iLen;
    	TRequestStatus status;
    	iSock.CancelRead();
    	iSock.RecvOneOrMore(bufT,0,status,iLen);
    	RTimer timer;
    	TRequestStatus timerstatus;
    	timer.CreateLocal();
    	timer.After(timerstatus,5000000);
    	User::WaitForAnyRequest();
    	bool readed=EFalse;
    	if(timerstatus!=KRequestPending)
    	{
    		timer.Cancel();
    		readed=ETrue;
    	}
    	timer.Close();
        if(status!=KRequestPending)
    	{
    		iSock.CancelRecv();
    		iSock.CancelRead();
    		closeSocket();
    	}
    I wounder if somebody knows how to check RFCOMM connection state(offline/online bt device).

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: bluetooth power-off

    Here is the Code

    Code:
    CRepository *cRepository = CRepository::NewL(KCRUidBluetoothPowerState);
    TInt bluetoothStatus=0;
    User::LeaveIfError( cRepository ->Get(KBTPowerState, bluetoothStatus) );

  3. #3
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: bluetooth power-off

    hi,
    I would ask you to implement CActive rather working it on User::WaitForRequest(). Once the BT is turned off on reading it returns an error code or -36 ( Disconnected) hopefully.Check the value of iStatus.

    and about the timer issue, you could check this thread. it explains well on the implementation..

    http://discussion.forum.nokia.com/fo...d.php?t=102307

    Priju

  4. #4
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    161

    Re: bluetooth power-off

    Quote Originally Posted by skumar_rao
    Here is the Code

    Code:
    CRepository *cRepository = CRepository::NewL(KCRUidBluetoothPowerState);
    TInt bluetoothStatus=0;
    User::LeaveIfError( cRepository ->Get(KBTPowerState, bluetoothStatus) );
    thanx but i cant find implementation of CRepository on 6.1 platform (

  5. #5
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: bluetooth power-off

    Sorry for the confusion as you have not mentioned SDK version !!!

    For Pre V9 use function below

    Code:
    TBool IsBluetoothOn() // BTONOFF 
    { 
    	// Create and initialise an RHostResolver 
    	RHostResolver hr; 
    	TInt res = false; 
    	TBool ret; 
     
    	RSocketServ socketServer; 
    	User::LeaveIfError(socketServer.Connect()); 
    	CleanupClosePushL(socketServer); 
     
    	res = hr.Open(socketServer, KBTAddrFamily, BTLinkManager); 
     
    	if (KErrNone != res) { 
    	// if not success, this means bluetooth is not on 
    	ret = EFalse; 
    	} 
     
    	else 
    	{ 
    	ret = ETrue; // Bluetooth is already ON 
    	hr.Close(); 
    	} 
     
    	CleanupStack::PopAndDestroy(1); 
     
    	return ret; 
    }

  6. #6
    Registered User
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747

    Re: bluetooth power-off

    Quote Originally Posted by StasV
    thanx but i cant find implementation of CRepository on 6.1 platform (
    But unfortunately the CRepository is not a part of Symbian OS v6.1, you have to go for a later version of SDK or go for some other alternative if any available.

  7. #7
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    161

    Re: bluetooth power-off

    Quote Originally Posted by vin2ktalks
    But unfortunately the CRepository is not a part of Symbian OS v6.1, you have to go for a later version of SDK or go for some other alternative if any available.
    Unfortunately, but we have to stay on pre v9.
    res = hr.Open(socketServer, KBTAddrFamily, BTLinkManager);
    BTLinkManager??? %000

  8. #8
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    161

    Re: bluetooth power-off

    Quote Originally Posted by skumar_rao
    IsBluetoothOn()
    it doesn work (. return allways ETrue
    Code:
    TBool IsBluetoothOn() // BTONOFF 
    { 
    	// Create and initialise an RHostResolver 
    	RHostResolver hr; 
    	TInt res = false; 
    	TBool ret; 
    	TProtocolDesc pInfo;
    	RSocketServ socketServer; 
    	User::LeaveIfError(socketServer.Connect()); 
    	CleanupClosePushL(socketServer); 
    	_LIT(BTLinkManager, "BTLinkManager"); 
    	TInt FindRet = socketServer.FindProtocol(BTLinkManager(),pInfo);
    	res = hr.Open(socketServer, pInfo.iAddrFamily, pInfo.iProtocol); 
    	if (KErrNone != res) { 
    		// if not success, this means bluetooth is not on 
    		ret = EFalse; 
    	} 
    
    	else 
    	{ 
    		ret = ETrue; // Bluetooth is already ON 
    		hr.Close(); 
    	} 
    
    	CleanupStack::PopAndDestroy(1); 
    
    	return ret; 
    }

  9. #9
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: bluetooth power-off

    It rather worked for me. The piece of code posted by rao, should be fine.
    If BT is off the Open() of RHostResolver should return an error code rather than KErrNone.

    Priju

  10. #10
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: bluetooth power-off

    For 2nd edition I found it easier to use CBTMCMSettings

    http://discussion.forum.nokia.com/fo...1&postcount=13

Similar Threads

  1. Bluetooth power class
    By rapajic in forum Bluetooth Technology
    Replies: 7
    Last Post: 2009-02-03, 09:26
  2. How to turn on the power of bluetooth?
    By xhsoldier in forum Symbian
    Replies: 6
    Last Post: 2007-05-11, 13:11
  3. Bluetooth transmission power control / API?
    By kuno.meyer in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-06-16, 08:59
  4. Nokia 7650 support Bluetooth audo?
    By ovjo12 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2003-07-17, 18:50
  5. Bluetooth transmission power of the Nokia 7650
    By FelixEshed in forum Bluetooth Technology
    Replies: 1
    Last Post: 2002-08-29, 09:51

Posting Permissions

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