bthci/bthci2/dutmode/src/dutmode.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include <bluetooth/dutmode.h>
       
    22 
       
    23 #include <bluetooth/hciserverclient.h>
       
    24 #include <bluetooth/hci/hciipc.h>
       
    25 #include <bluetooth/logger.h>
       
    26 
       
    27 #ifdef __FLOG_ACTIVE
       
    28 _LIT8(KLogComponent, LOG_COMPONENT_DUT_MODE);
       
    29 #endif
       
    30 
       
    31 EXPORT_C RBluetoothDutMode::RBluetoothDutMode()
       
    32 	: iHCIServerSession(NULL)
       
    33 	{
       
    34 	}
       
    35 
       
    36 /**
       
    37 Opens the handle to the Bluetooth DUT Mode Service
       
    38 
       
    39 @return KErrNone if successful, otherwise a standard Symbian error code
       
    40 */
       
    41 EXPORT_C TInt RBluetoothDutMode::Open()
       
    42 	{
       
    43 	LOG_FUNC
       
    44 	__ASSERT_ALWAYS(!iHCIServerSession, PANIC(KBluetoothDutModePanic, EHandleIsAlreadyOpen));
       
    45 	
       
    46 	TInt err = KErrNoMemory;
       
    47 	iHCIServerSession = new RHCIServerSession;
       
    48 	if(iHCIServerSession)
       
    49 		{
       
    50 		err = iHCIServerSession->Open(KHCIBluetoothDutModeManagerUid);
       
    51 		if(err != KErrNone)
       
    52 			{
       
    53 			delete iHCIServerSession;
       
    54 			iHCIServerSession = NULL;
       
    55 			}
       
    56 		}
       
    57 	return err;
       
    58 	}
       
    59 
       
    60 /**
       
    61 Closes the handle to the Bluetooth DUT Mode Service
       
    62 
       
    63 Note that it is safe to call this multiple times.
       
    64 */
       
    65 EXPORT_C void RBluetoothDutMode::Close()
       
    66 	{
       
    67 	LOG_FUNC
       
    68 	if(iHCIServerSession)
       
    69 		{
       
    70 		iHCIServerSession->Close();
       
    71 		delete iHCIServerSession;
       
    72 		iHCIServerSession = NULL;
       
    73 		}
       
    74 	}
       
    75 
       
    76 /**
       
    77 Activate Device Under Test mode
       
    78 
       
    79 @return KErrNone if successful, otherwise a standard Symbian error code
       
    80 */
       
    81 EXPORT_C TInt RBluetoothDutMode::ActivateDutMode() const
       
    82 	{
       
    83 	LOG_FUNC
       
    84 	__ASSERT_ALWAYS(iHCIServerSession, PANIC(KBluetoothDutModePanic, EApiUsedWhenHandleIsNotOpen));
       
    85 	return iHCIServerSession->SendSync(EHCIActivateDutMode);
       
    86 	}
       
    87 
       
    88 
       
    89 /**
       
    90 Deactivate Device Under Test mode
       
    91 
       
    92 @return KErrNone if successful, otherwise a standard Symbian error code
       
    93 */
       
    94 EXPORT_C TInt RBluetoothDutMode::DeactivateDutMode() const
       
    95 	{
       
    96 	LOG_FUNC
       
    97 	__ASSERT_ALWAYS(iHCIServerSession, PANIC(KBluetoothDutModePanic, EApiUsedWhenHandleIsNotOpen));
       
    98 	return iHCIServerSession->SendSync(EHCIDeactivateDutMode);
       
    99 	}