You Are Here:

Community: Developer Discussion Boards

#1 Old Check Bluetooth Status - 2004-11-23, 10:03

Join Date: Feb 2004
Posts: 605
Location: Dallas
Send a message via Yahoo to amitaggarwal
amitaggarwal
Offline
Super Contributor
I simply want to check the Bluetooth Status i.e. whether it is ON or OFF and accordingly take some action.

Can someone tell me how to do it as i am new to Bluetooth ?
Reply With Quote

#2 Old 2004-11-25, 07:56

Join Date: Aug 2004
Posts: 47
ekhoo
Offline
Registered User
U can use CSettingInfo to get the Bluetooth status. U can refer to the ProfileExample in the forum nokia.
Reply With Quote

#3 Old 2004-11-25, 08:02

Join Date: Feb 2004
Posts: 605
Location: Dallas
Send a message via Yahoo to amitaggarwal
amitaggarwal
Offline
Super Contributor
Thnx , Actually i got it by using SOcketServer and RHost Resolver but that is an expensive method .
CSettingInfo one seems better atleast for the info it provides.

Have u ever used this class ? If yes just paste the code here and i wil take the help from it.
Reply With Quote

#4 Old 2004-11-25, 08:33

Join Date: Aug 2004
Posts: 47
ekhoo
Offline
Registered User
Code taken from ProfileExample in FN

iSettings = CSettingInfo::NewL(this);

// Order notifications when profile is changed
TInt err = iSettings->NotifyChanges(SettingInfo::EActiveProfile);
if(err != KErrNone)
{
// an error occured, show message to user
iView->ShowMessageL(KErrOrderingProfileChangeNotifies);

}
if(iProperties.bthPowerName)
delete iProperties.bthPowerName;
iProperties.bthPowerName = HBufC::NewL(32);
iProperties.bthPower = 0;

// SettingInfo::EBluetoothPowerMode == 100, so value
if( ReadPropertyIndex(SettingInfo::EBluetoothPowerMode,
EProfilesExamplePropertyBluetoothMode) == KErrNone)
{
// index was read successfully
switch(iProperties.bthPower)
{
case EProfilesExampleBluetoothSleeping:
case EProfilesExampleBluetoothPoweredUp:
iProperties.bthPowerName->Des().Copy(
(*iBthPowerModes) [iProperties.bthPower] );
break;
default: // unknown type
iProperties.bthPowerName->Des().Copy(
KProfilesExampleUnknownStringProperty);
break;
}
}

// form a double type list box item string
TBuf<32> bluetoothModeListItem;
bluetoothModeListItem.AppendFormat(
(*iPropertyListTemplate)
[EProfilesExamplePropertyBluetoothMode],
iProperties.bthPowerName);

// add to view's list box
iView->AddListBoxItemL(bluetoothModeListItem);
Reply With Quote

#5 Old Re: Check Bluetooth Status - 2006-03-30, 09:12

Join Date: Mar 2003
Posts: 63
Location: Helsinki
jyrkiettila
Offline
Regular Contributor
This worked for me on Nokia 3230 to detect Bluetooth power off state:
(Symbian 7.0s Series60_v21)

LIBRARY PlatformEnv.lib

#include <SettingInfo.h>
#include <aknnotewrappers.h>

CSettingInfo* settingInfo = CSettingInfo::NewL(NULL);
CleanupStack::PushL(settingInfo);

// Get current bluetooth power mode
// Possible values in release 2.0:
// 0 (unpowered/sleeping)
// 1 (powered up and fully functional)

TInt btMode;
TInt err = settingInfo->Get( SettingInfo::EBluetoothPowerMode, btMode );

if (err != KErrNone) {
_LIT(KSettingInfoError, "CSettingInfo returned error");
CAknErrorNote* note = new(ELeave)CAknErrorNote();
note->ExecuteLD(KSettingInfoError);
} else {
if (btMode == 0) { // (unpowered/sleeping)
// Do something to switch BT on,
// e.g. show notifier using KPowerModeSettingNotifierUid
}
}
CleanupStack::PopAndDestroy(settingInfo);


- Jyrki
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia