| Reply | « Previous Thread | Next Thread » |
|
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 ? |
| amitaggarwal |
| View Public Profile |
| Find all posts by amitaggarwal |
|
U can use CSettingInfo to get the Bluetooth status. U can refer to the ProfileExample in the forum nokia.
|
|
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. |
| amitaggarwal |
| View Public Profile |
| Find all posts by amitaggarwal |
|
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); |
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|