This page was last modified 04:17, 22 May 2007.
Checking the Bluetooth power state in 3rd Ed
From Forum Nokia Wiki
#include <centralrepository.h> // for CRepository #include <BTServerSDKCRKeys.h> // for KCRUidBluetoothPowerState, KBTPowerState #include <BtnotifierAPI.h> // for KPowerModeSettingNotifierUid // ---------------------------------------------------------------------------- // CBTEngine::CheckBluetoothPowerStateL() // This will check the Bluetooth power state and if switched off then ask // to switch it on. // ---------------------------------------------------------------------------- // TBool CBTEngine::CheckBluetoothPowerStateL() { if(BluetoothPowerStateL()) { return ETrue; } else { return TurnBluetoothOnL(); } } // ---------------------------------------------------------------------------- // CBTEngine::BluetoothPowerStateL() // Get the Bluetooth power state of the device. // ---------------------------------------------------------------------------- // TBool CBTEngine::BluetoothPowerStateL() { CRepository* crep = CRepository::NewLC(KCRUidBluetoothPowerState); TInt value = 0; User::LeaveIfError(crep->Get(KBTPowerState, value)); CleanupStack::PopAndDestroy(crep); return !(value == 0); } // ---------------------------------------------------------------------------- // CBTEngine::TurnBluetoothOnL() // Uses the Notifier API to ask the user to turn on Bluetooth // if it's not on already. // ---------------------------------------------------------------------------- // TBool CBTEngine::TurnBluetoothOnL() { RNotifier notifier; User::LeaveIfError( notifier.Connect() ); TPckgBuf<TBool> dummy(ETrue); TPckgBuf<TBool> reply(EFalse); TRequestStatus status; notifier.StartNotifierAndGetResponse(status, KPowerModeSettingNotifierUid, dummy, reply); User::WaitForRequest(status); notifier.CancelNotifier(KPowerModeSettingNotifierUid); notifier.Close(); return reply(); }
Related Links
Note: The code has been taken from BTFileSend, an open source project in SourceForge.net.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Current T9 input state | psousa | Symbian User Interface | 2 | 2004-04-30 19:39 |
| Get phone power "ON" status on Series 80 | WinHw | General Symbian C++ | 1 | 2004-10-19 08:34 |
| How i can solve this !! | eng.ppu | Bluetooth Technology | 3 | 2008-06-01 14:32 |
| BlueTooth vs InfraRed | gusruiz71 | Bluetooth Technology | 0 | 2004-11-17 04:27 |
| Jave Bluetooth inquiry on Nokia 6120 Classic | luftwav | Mobile Java Networking & Messaging & Security | 2 | 2007-09-23 11:23 |
