epoc32/include/btdevice.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 // Copyright (c) 1999-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef BTDEVICE_H
    17 #define BTDEVICE_H
    18 
    19 #include <e32std.h>
    20 #include <e32base.h>
    21 #include <s32mem.h>
    22 
    23 #include <bluetooth/hci/hciopcodes.h>
    24 #include <bluetooth/hci/hciconsts.h>
    25 
    26 /** The maximum length of a bluetooth device name, as stored in CBTDevice.
    27 @publishedAll
    28 @released
    29 **/
    30 static const TInt KMaxBluetoothNameLen = KHCILocalDeviceNameMaxLength;
    31 
    32 /** The maximum length of the user-assinged friendly name for a bluetooth device, as stored in CBTDevice.
    33 @publishedAll
    34 @released
    35 **/
    36 static const TInt KMaxFriendlyNameLen = 100;
    37 
    38 /** Length of a bluetooth device name. Retained for binary compatibility.
    39 @internalComponent
    40 @deprecated
    41 **/
    42 static const TInt KMaxBCBluetoothNameLen = 256;
    43 
    44 //forward declarations
    45 class TBTDeviceClass;
    46 class CBTDevice;
    47 class TBTServiceSecurityPerDevice;
    48 
    49 /** A typedef'ed array of CBTDevice objects.
    50 @publishedAll
    51 @released
    52 **/
    53 typedef CArrayPtrFlat<CBTDevice> CBTDeviceArray;
    54 
    55 /** A typedef'ed array of TBTServiceSecurityPerDevice objects.
    56 @publishedAll
    57 @released
    58 **/
    59 typedef RArray<TBTServiceSecurityPerDevice> RBTSecurityArray;
    60 
    61 /** Wide descriptor of correct length to hold a bluetooth device name.
    62 @publishedAll
    63 @released
    64 **/
    65 typedef TBuf<KMaxBCBluetoothNameLen> TBTDeviceName;
    66 
    67 /** Narrow descriptor of correct length to hold a bluetooth device name.
    68 
    69 @publishedAll
    70 @released
    71 **/
    72 typedef TBuf8<KMaxBluetoothNameLen> TBTDeviceName8;
    73 
    74 /** Utility class to convert between a wide TBTDeviceName and a narrow TBTDeviceName8.
    75 @publishedAll
    76 @released
    77 **/
    78 class BTDeviceNameConverter
    79 	{
    80 public:
    81 	IMPORT_C static TBTDeviceName ToUnicodeL(const TBTDeviceName8& aName);
    82 	IMPORT_C static TBTDeviceName8 ToUTF8L(const TBTDeviceName& aName);
    83 	};
    84 	
    85 /** Defines the granularity of the arrays used in CBTDevice.
    86 @internalComponent
    87 @released
    88 **/
    89 const TInt KSecurityGranularity=1;
    90 
    91 /** Cleanup utility for CBTDeviceArrays.
    92 
    93 Creates a TCleanupItem that calls ResetAndDestroy and then deletes the array.
    94 
    95 @publishedAll
    96 @released
    97 */
    98 class BTDeviceArrayCleanupStack
    99 
   100 	{
   101 public:
   102 	IMPORT_C static void PushL(CBTDeviceArray* aBTDeviceArray);
   103 private:
   104 	static void ResetAndDestroy(TAny* aBTDeviceArray);
   105 	};
   106 
   107 /** Enum used to describe the Bluetooth major service classes.  
   108 
   109 See the bluetooth specification for more details.
   110 
   111 @publishedAll
   112 @released
   113 **/
   114 enum TBTMajorServiceClass
   115 	{												//23        13	<- bit number
   116 	/** Limited discoverable mode **/
   117 	EMajorServiceLimitedDiscoverableMode = 0x01,	//00000000001
   118 	/** Positioning **/
   119 	EMajorServicePositioning = 0x08,				//00000001000
   120 	/** Networking **/
   121 	EMajorServiceNetworking = 0x10,					//00000010000
   122 	/** Rendering **/
   123 	EMajorServiceRendering = 0x20,					//00000100000
   124 	/** Capturing **/
   125 	EMajorServiceCapturing = 0x40,					//00001000000
   126 	/** Object transfer **/
   127 	EMajorServiceObjectTransfer = 0x80,				//00010000000
   128 	/** Audio **/
   129 	EMajorServiceAudio = 0x100,						//00100000000
   130 	/** Telephony **/
   131 	EMajorServiceTelephony = 0x200,					//01000000000
   132 	/** Information **/
   133 	EMajorServiceInformation = 0x400,				//10000000000
   134 	/**
   135 	 * Old name kept for SC.
   136 	 * @deprecated
   137 	 * @see EMajorServiceAudio
   138 	 */
   139 	EMajorServiceAudioService = 0x100				//00100000000
   140 	};
   141 
   142 /** Enum used to describe the Bluetooth major device classes.  
   143 
   144 See the bluetooth specification for more details.
   145 
   146 @publishedAll
   147 @released
   148 **/
   149 enum TBTMajorDeviceClass
   150 	{												//12  8	<- bit number
   151 	/** Miscellaneous device **/
   152 	EMajorDeviceMisc = 0x0,							//00000
   153 	/** Computer device **/
   154 	EMajorDeviceComputer = 0x1,						//00001
   155 	/** Phone device **/
   156 	EMajorDevicePhone = 0x2,						//00010
   157 	/** LAN access point device **/
   158 	EMajorDeviceLanAccessPoint = 0x3,				//00011
   159 	/** Audio-video device **/
   160 	EMajorDeviceAV = 0x4,							//00100
   161 	/** Peripheral device **/
   162 	EMajorDevicePeripheral = 0x5,					//00101
   163 	/** Imaging device **/
   164 	EMajorDeviceImaging = 0x6,						//00110
   165 	/** Wearable device **/
   166 	EMajorDeviceWearable = 0x7,						//00111
   167 	/** Toy device **/
   168 	EMajorDeviceToy = 0x8,							//01000
   169 	/** Unclassified device **/
   170 	EMajorDeviceUnclassified = 0x1F,				//11111
   171 	/**
   172 	 * Old name kept for SC.
   173 	 * @deprecated
   174 	 * @see EMajorDeviceAV
   175 	 */
   176 	EMajorDeviceAudioDevice = 0x4,					//00100
   177 	/**
   178 	 * Old name kept for SC.
   179 	 * @deprecated
   180 	 * @see EMajorDeviceUnclassified
   181 	 */
   182 	EMajorDeviceDeviceUnclassified = 0x1F			//11111
   183 	};
   184 
   185 /** Enum used to describe the Bluetooth minor device classes relating to the "Computer" major device class.
   186 
   187 See the bluetooth specification for more details.
   188 
   189 @publishedAll
   190 @released
   191 **/
   192 enum TBTMinorDeviceClassComputer
   193 	{										//7    2	<- bit number
   194 	/** Unclassified computer device **/
   195 	EMinorDeviceComputerUnclassified = 0x0,	//000000
   196 	/** Desktop computer device **/
   197 	EMinorDeviceComputerDesktop = 0x1,		//000001
   198 	/** Server computer device **/
   199 	EMinorDeviceComputerServer = 0x2,		//000010
   200 	/** Laptop computer device **/
   201 	EMinorDeviceComputerLaptop = 0x3,		//000011
   202 	/** Handheld computer device **/
   203 	EMinorDeviceComputerHandheld = 0x4,		//000100
   204 	/** Palm computer device **/
   205 	EMinorDeviceComputerPalmSize = 0x5,		//000101
   206 	/** Wearable computer device **/
   207 	EMinorDeviceComputerWearable = 0x6		//000110
   208 	};
   209 
   210 /** Enum used to describe the Bluetooth minor device classes relating to the "phone" major device class.
   211 
   212 See the bluetooth specification for more details.
   213 
   214 @publishedAll
   215 @released
   216 **/
   217 enum TBTMinorDeviceClassPhone
   218 	{										//7    2	<- bit number
   219 	/** Unclassified phone device **/
   220 	EMinorDevicePhoneUnclassified = 0x0,	//000000
   221 	/** Cellular phone device **/
   222 	EMinorDevicePhoneCellular = 0x1,		//000001
   223 	/** Cordless phone device **/
   224 	EMinorDevicePhoneCordless = 0x2,		//000010
   225 	/** Smart phone device **/
   226 	EMinorDevicePhoneSmartPhone = 0x3,		//000011
   227 	/** Wired modem phone device **/
   228 	EMinorDevicePhoneWiredModem = 0x4,		//000100
   229 	/** ISDN phone device **/
   230 	EMinorDevicePhoneCommonISDNAccess = 0x5	//000101
   231 	};
   232 
   233 /** Enum used to describe the Bluetooth minor device classes relating to the "LAN" major device class.
   234 
   235 See the bluetooth specification for more details.
   236 @publishedAll
   237 @released
   238 **/
   239 enum TBTMinorDeviceClassLAN
   240 	{										//7    2	<- bit number
   241 	/** LAN is currently 0% utilitized **/
   242 	EMinorDeviceLANFullyAvailable = 0x0,	//000000
   243 	/** LAN is currently 1-17% utilitized **/
   244 	EMinorDeviceLANServiceOne = 0x8,		//001000
   245 	/** LAN is currently 17-33% utilitized **/
   246 	EMinorDeviceLANServiceTwo = 0x10,		//010000
   247 	/** LAN is currently 33-50% utilitized **/
   248 	EMinorDeviceLANServiceThree = 0x18,		//011000
   249 	/** LAN is currently 50-67% utilitized **/
   250 	EMinorDeviceLANServiceFour = 0x20,		//100000
   251 	/** LAN is currently 67-83% utilitized **/
   252 	EMinorDeviceLANServiceFive = 0x28,		//101000
   253 	/** LAN is currently 83-99% utilitized **/
   254 	EMinorDeviceLANServiceSix = 0x30,		//110000
   255 	/** LAN is currently 100% utilitized **/
   256 	EMinorDeviceLANNoService = 0x38			//111000
   257 	};
   258 
   259 /** Enum used to describe the Bluetooth minor device classes relating to the "AV" major device class.
   260 
   261 See the bluetooth specification for more details.
   262 
   263 @publishedAll
   264 @released
   265 **/
   266 enum TBTMinorDeviceClassAV
   267 	{												//7    2
   268 	/** Unclassified AV Device **/
   269 	EMinorDeviceAVUnclassified = 0x0,				//000000
   270 	/** Headset AV Device **/
   271 	EMinorDeviceAVHeadset = 0x1,					//000001
   272 	/** Handsfree AV Device **/
   273 	EMinorDeviceAVHandsfree = 0x2,					//000010
   274 	/** Microphone AV Device **/
   275 	EMinorDeviceAVMicrophone = 0x4,					//000100
   276 	/** Loudspeaker AV Device **/
   277 	EMinorDeviceAVLoudspeaker = 0x5,				//000101
   278 	/** Headphone AV Device **/
   279 	EMinorDeviceAVHeadphones = 0x6,					//000110
   280 	/** Portable audio AV Device **/
   281 	EMinorDeviceAVPortableAudio = 0x7,				//000111
   282 	/** Car audio AV Device **/
   283 	EMinorDeviceAVCarAudio = 0x8,					//001000
   284 	/** Set top box AV Device **/
   285 	EMinorDeviceAVSetTopBox = 0x9,					//001001
   286 	/** Hifi audio AV Device **/
   287 	EMinorDeviceAVHiFiAudio = 0xA,					//001010
   288 	/** VCR AV Device **/
   289 	EMinorDeviceAVVCR = 0xB,						//001011
   290 	/** Video camera AV Device **/
   291 	EMinorDeviceAVVideoCamera = 0xC,				//001100
   292 	/** Camcorder AV Device **/
   293 	EMinorDeviceAVCamcorder = 0xD,					//001101
   294 	/** Video monitor AV Device **/
   295 	EMinorDeviceAVVideoMonitor = 0xE,				//001110
   296 	/** Video display and loudspeaker AV Device **/
   297 	EMinorDeviceAVVideoDisplayAndLoudspeaker = 0xF,	//001111
   298 	/** Video conferencing AV Device **/
   299 	EMinorDeviceAVVideoConferencing = 0x10,			//010000
   300 	/** Gaming toy AV Device **/
   301 	EMinorDeviceAVGamingToy = 0x12					//010010
   302 	};	
   303 	
   304 /** Enum used to describe the Bluetooth minor device classes relating to the "Peripheral" major device class.
   305 
   306 See the bluetooth specification for more details.
   307 @publishedAll
   308 @released
   309 **/
   310 enum TBTMinorDeviceClassPeripheral
   311 	{													//7    2
   312 	/** Keyboard peripheral device.
   313 	
   314 	Note that the keyboard bit can be independently
   315 	or'd with all other bits.
   316 	**/
   317 	EMinorDevicePeripheralKeyboard = 0x10,				//010000
   318 	/** Pointer peripheral device.
   319 	
   320 	Note that the pointer bit can be independently
   321 	or'd with all other bits.
   322 	**/
   323 	EMinorDevicePeripheralPointer = 0x20,				//100000
   324 	//
   325 	// All other bits are mutually exclusive
   326 	//
   327 	/** Uncategorized peripheral device **/
   328 	EMinorDevicePeripheralUncategorized = 0x00,			//000000
   329 	/** Joystick peripheral device **/
   330 	EMinorDevicePeripheralJoystick = 0x01,				//000001
   331 	/** Gamepad peripheral device **/
   332 	EMinorDevicePeripheralGamepad = 0x02,				//000010
   333 	/** Remote control peripheral device **/
   334 	EMinorDevicePeripheralRemoteControl = 0x03,			//000011
   335 	/** Sensing peripheral device **/
   336 	EMinorDevicePeripheralSensingDevice = 0x04,			//000100
   337 	/** Digitizer tablet peripheral device **/
   338 	EMinorDevicePeripheralDigitizerTablet = 0x05,		//000101
   339 	/** Card reader peripheral device **/
   340 	EMinorDevicePeripheralCardReader = 0x06				//000110
   341 	};
   342 
   343 /** Enum used to describe the Bluetooth minor device classes relating to the "Imaging" major device class.
   344 
   345 See the bluetooth specification for more details.
   346 @publishedAll
   347 @released
   348 
   349 **/
   350 enum TBTMinorDeviceClassImaging
   351 	{											//7    2
   352 	/** Display imaging device **/
   353 	EMinorDeviceImagingDisplay = 0x04,			//000100
   354 	/** Camera imaging device **/
   355 	EMinorDeviceImagingCamera = 0x08,			//001000
   356 	/** Scanner imaging device **/
   357 	EMinorDeviceImagingScanner = 0x10,			//010000
   358 	/** Printer imaging device **/
   359 	EMinorDeviceImagingPrinter = 0x20,			//100000
   360 	};
   361 
   362 /** Enum used to describe the Bluetooth minor device classes relating to the "Wearable" major device class.
   363 
   364 See the bluetooth specification for more details.
   365 @publishedAll
   366 @released
   367 
   368 **/
   369 enum TBTMinorDeviceClassWearable
   370 	{											//7    2
   371 	/** Wrist watch wearable device **/
   372 	EMinorDeviceWearableWatch = 0x01,			//000001
   373 	/** Pager wearable device **/
   374 	EMinorDeviceWearablePager = 0x02,			//000010
   375 	/** Jacket wearable device **/
   376 	EMinorDeviceWearableJacket = 0x03,			//000011
   377 	/** Helmet wearable device **/
   378 	EMinorDeviceWearableHelmet = 0x04,			//000100
   379 	/** Glasses wearable device **/
   380 	EMinorDeviceWearableGlasses = 0x05,			//000101	
   381 	};
   382 
   383 /** Enum used to describe the Bluetooth minor device classes relating to the "Toy" major device class.
   384 
   385 See the bluetooth specification for more details.
   386 @publishedAll
   387 @released
   388 
   389 **/
   390 enum TBTMinorDeviceClassToy
   391 	{											//7    2
   392 	/** Robot toy device **/
   393 	EMinorDeviceToyRobot = 0x01,				//000001
   394 	/** Vehicle toy device **/
   395 	EMinorDeviceToyVehicle = 0x02,				//000010
   396 	/** Doll toy device **/
   397 	EMinorDeviceToyDoll = 0x03,					//000011
   398 	/** Controller toy device **/
   399 	EMinorDeviceToyController = 0x04,			//000100
   400 	/** Game toy device **/
   401 	EMinorDeviceToyGame = 0x05,					//000101	
   402 	};
   403 
   404 
   405 /** Minor Device class headset.
   406 @deprecated
   407 @internalComponent
   408 @see TBTMinorDeviceClassAV
   409 **/
   410 enum TBTMinorDeviceClassHeadset
   411 	{										//7    2
   412 	EHeadsetUnclassified = 0x0,				//000000
   413 	EHeadsetProfile = 0x1,					//000001
   414 	};
   415 	
   416 /** Encapsulation of device class definitions.
   417 
   418 Contains a single TInt as member data and methods to extract the major, minor and service
   419 class information from that TInt.
   420 @publishedAll
   421 @released
   422 **/
   423 NONSHARABLE_CLASS(TBTDeviceClass)
   424 	{
   425 public:
   426 	IMPORT_C TBTDeviceClass();
   427 	IMPORT_C TBTDeviceClass(TUint32 aDeviceClass);
   428 	IMPORT_C TBTDeviceClass(TUint16 aMajorServiceClass, TUint8 aMajorDeviceClass,
   429 							TUint8 aMinorDeviceClass);
   430 
   431 	IMPORT_C TUint16 MajorServiceClass() const;
   432 	IMPORT_C TUint8 MajorDeviceClass() const;
   433 	IMPORT_C TUint8 MinorDeviceClass() const;
   434 	IMPORT_C TUint32 DeviceClass() const;
   435 	
   436 	IMPORT_C TBool operator==(const TBTDeviceClass& aDeviceClass) const;
   437 	IMPORT_C TBTDeviceClass& operator=(const TBTDeviceClass& aDeviceClass);
   438 	
   439 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   440 	IMPORT_C void InternalizeL(RReadStream& aStream);
   441 private:
   442 	static const TUint32 KStreamVersion = 0x00000001;
   443 private:
   444 	TUint32 iDeviceClass;
   445 	
   446 	// This data padding has been added to help prevent future binary compatibility breaks	
   447 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   448 	TUint32     iPadding1; 
   449 	TUint32     iPadding2; 
   450 	};
   451 
   452 /** Class to store the security override parameters for a particular remote device.
   453 
   454 @publishedAll
   455 @released
   456 */
   457 NONSHARABLE_CLASS(TBTDeviceSecurity)
   458 	{
   459 public:
   460 	/** Enumeration to provide select MITM protection required. */
   461 	enum TMitmRequired
   462 		{
   463 		EMitmUnspecified,	/*!< No specific MITM protection requirements */
   464 		EMitmRequired		/*!< Require the link is MITM protected */
   465 		};
   466 	
   467 public:
   468 	IMPORT_C TBTDeviceSecurity();
   469 	IMPORT_C TBTDeviceSecurity(TUint8 aSecurity);
   470 	IMPORT_C TBTDeviceSecurity(TUint8 aSecurity, TUint aPasskeyMinLength);
   471 	IMPORT_C TBTDeviceSecurity(TBool aNoAuthenticate, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
   472 	IMPORT_C TBTDeviceSecurity(TMitmRequired aMitmRequirements, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
   473 	
   474 	IMPORT_C void SetNoAuthenticate(TBool aDecision);
   475 	IMPORT_C void SetMitmRequirements(TMitmRequired aDecision);
   476 	IMPORT_C void SetNoAuthorise(TBool aDecision);
   477 	IMPORT_C void SetEncrypt(TBool aDecision);
   478 	IMPORT_C void SetBanned(TBool aDecision);
   479 	
   480 	IMPORT_C TBool NoAuthenticate() const;
   481 	IMPORT_C TMitmRequired MitmRequirements() const;
   482 	IMPORT_C TBool NoAuthorise() const;
   483 	IMPORT_C TBool Encrypt() const;
   484 	IMPORT_C TBool Banned() const;
   485 	IMPORT_C TUint PasskeyMinLength() const;
   486 	
   487 	
   488 	IMPORT_C TUint8 SecurityValue() const;
   489 	IMPORT_C void SetSecurityValue(TUint8 aDeviceSecurity);
   490 	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
   491 	
   492 	
   493 	IMPORT_C TBool operator==(const TBTDeviceSecurity& aDeviceSecurity) const;
   494 	IMPORT_C TBool operator!=(const TBTDeviceSecurity& aDeviceSecurity) const;
   495 	
   496 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   497 	IMPORT_C void InternalizeL(RReadStream& aStream);
   498 
   499 public:
   500 	/** Enumeration to assist in parsing of security settings. */
   501 	enum TBTDeviceSecuritySettings
   502 		{
   503 		ENoAuthenticate	= 0x01, /*!< Don't authenticate the link */
   504 		ENoAuthorise = 0x02, /*!< Don't authorise the connection */
   505 		EEncrypt = 0x04, /*!< Encrypt the link */
   506 		EBanned					= 0x08, /*!< Don't connect to the device */
   507 		EMitmProtectionRequired	= 0x10, /*!< Require the link is MITM protected */
   508 		};
   509 	
   510 private:
   511 	static const TUint32 KStreamVersion = 0x00000001;
   512 
   513 private:
   514 	TUint8 iSecurity;
   515 	TUint  iPasskeyMinLength;	
   516 	
   517 	// This data padding has been added to help prevent future binary compatibility breaks	
   518 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   519 	TUint32     iPadding1; 
   520 	TUint32     iPadding2; 
   521 	};
   522 
   523 /** Class to tie a service uid with a device security setting.
   524 
   525 This allows us to have service-specific security settings for a device.
   526 
   527 @publishedAll
   528 @released
   529 */
   530 NONSHARABLE_CLASS(TBTServiceSecurityPerDevice)
   531 	{
   532 public:
   533 	IMPORT_C TBTServiceSecurityPerDevice();
   534 	IMPORT_C TBTServiceSecurityPerDevice(const TBTDevAddr& aDevice, const TBTDeviceSecurity& aSecuritySettings);
   535 	IMPORT_C TBTServiceSecurityPerDevice(const TBTServiceSecurityPerDevice&);
   536 	
   537 	IMPORT_C void SetDeviceSecurity(const TBTDeviceSecurity& aSecuritySettings);
   538 	IMPORT_C void SetAddress(const TBTDevAddr& aAddress);
   539 
   540 	IMPORT_C const TBTDeviceSecurity& DeviceSecurity() const;
   541 	IMPORT_C const TBTDevAddr& DeviceAddress() const;
   542 	
   543 	IMPORT_C void operator=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice);
   544 	IMPORT_C TBool operator==(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
   545 	IMPORT_C TBool operator!=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
   546 	
   547 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   548 	IMPORT_C void InternalizeL(RReadStream& aStream);
   549 private:
   550 	static const TUint32 KStreamVersion = 0x00000001;
   551 private:
   552 	TBTDevAddr			iDeviceAddress;		/*!< the address of the device for the overriding security **/
   553 	TBTDeviceSecurity	iDeviceSecurity;	/*!< the overriding security */
   554 	
   555 	// This data padding has been added to help prevent future binary compatibility breaks	
   556 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
   557 	TUint32     iPadding1; 
   558 	TUint32     iPadding2; 	
   559 	};
   560 		
   561 /** For Symbian use only
   562 @internalAll	
   563 */
   564 NONSHARABLE_CLASS(TBTBasebandParameters)
   565 	{
   566 public:
   567 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   568 	IMPORT_C void InternalizeL(RReadStream& aStream);			
   569 
   570 	TUint8 iPageScanRepetitionMode;			/*!< Page Scan repetition mode of remote device ( valid if > 0 ) */
   571 	TUint8 iPageScanPeriodMode;				/*!< Page scan period mode of remote device */
   572 	TUint8 iPageScanMode;					/*!< Page scan mode of remote device ( valid if > 0 ) */
   573 	TUint16 iClockOffset;					/*!< clock off set of remote device ( valid if > 0 ) */
   574 	
   575 private:
   576 	static const TUint32 KStreamVersion = 0x00000001;
   577 	};
   578 
   579 
   580 
   581 /** Stores parameters for a nameless device.
   582 
   583 A class which stores useful parameters concerning a remote device
   584 But *not* including names
   585 @see CBTDevice
   586 @publishedAll
   587 @released
   588 */
   589 NONSHARABLE_CLASS(TBTNamelessDevice)
   590 	{
   591 friend class CBTDevice;
   592 public:
   593 	
   594 	IMPORT_C TBTNamelessDevice();	
   595 	IMPORT_C const TBTDevAddr& Address() const;	
   596 	IMPORT_C const TBTDeviceClass& DeviceClass() const;	
   597 	IMPORT_C const TBTLinkKey& LinkKey() const;	
   598 	IMPORT_C TBTLinkKeyType LinkKeyType() const;
   599 	IMPORT_C TUint8 PageScanRepMode() const;	
   600 	IMPORT_C TUint8 PageScanMode() const;	
   601 	IMPORT_C TUint8 PageScanPeriodMode() const;	
   602 	IMPORT_C TUint16 ClockOffset() const;	
   603 	IMPORT_C const TTime& Seen() const;		
   604 	IMPORT_C const TTime& Used() const;		
   605 	IMPORT_C const TBTDeviceSecurity& GlobalSecurity() const;	
   606 	IMPORT_C void SetAddress(const TBTDevAddr& aBDAddr);	
   607 	IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);		
   608 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
   609 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
   610 	IMPORT_C void SetPageScanRepMode(TUint8 aPageScanRepMode);
   611 	IMPORT_C void SetPageScanPeriodMode(TUint8 aPageScanPeriodMode);
   612 	IMPORT_C void SetPageScanMode(TUint8 aPageScanMode);
   613 	IMPORT_C void SetClockOffset(TUint16 aClockOffSet);
   614 	IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting); 
   615 	IMPORT_C void SetUsed(const TTime& aDateTime);
   616 	IMPORT_C void SetSeen(const TTime& aDateTime);
   617 	IMPORT_C TBool IsValidAddress() const;
   618 	IMPORT_C TBool IsValidDeviceClass() const;
   619 	IMPORT_C TBool IsValidLinkKey() const;
   620 	IMPORT_C TBool IsValidGlobalSecurity() const;
   621 	IMPORT_C TBool IsValidPageScanRepMode() const;
   622 	IMPORT_C TBool IsValidPageScanMode() const;
   623 	IMPORT_C TBool IsValidPageScanPeriodMode() const;
   624 	IMPORT_C TBool IsValidClockOffset() const;
   625 	IMPORT_C TBool IsValidUsed() const;
   626 	IMPORT_C TBool IsValidSeen() const;
   627 	IMPORT_C void DeleteLinkKey();
   628 	IMPORT_C void Update(const TBTNamelessDevice& aDevice);
   629 	IMPORT_C TBTNamelessDevice& operator=(const TBTNamelessDevice& aDevice);
   630 	IMPORT_C TBool operator==(const TBTNamelessDevice& aDevice) const;
   631 	IMPORT_C TBool operator!=(const TBTNamelessDevice& aDevice) const;
   632 	IMPORT_C TUint CompareTo(const TBTNamelessDevice& aDevice) const;
   633 	IMPORT_C TBool IsPaired() const;
   634 	IMPORT_C void SetPaired(TBool aPaired);
   635 	IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
   636 	IMPORT_C TBool IsValidPaired() const;
   637 	IMPORT_C const TBTPinCode& PassKey() const;		
   638 	IMPORT_C void  SetPassKey(const TBTPinCode& aPassKey);		
   639 	IMPORT_C TBool IsValidPassKey() const;
   640 	IMPORT_C TUint PassKeyLength() const;
   641 	IMPORT_C TBool IsValidUiCookie() const;
   642 	IMPORT_C void SetUiCookie(TUint32 aUiCookie);
   643 	IMPORT_C TUint32 UiCookie() const;
   644 	
   645 	/**	Bitfield of TBTNamelessDevice attributes
   646 	@publishedPartner
   647 	@released
   648 	*/	
   649 	enum TBTDeviceSet
   650 		{
   651 		EAddress				= 0x000001, /*!< Device address */
   652 		EDeviceClass			= 0x000002, /*!< Device class */
   653 		ELinkKey				= 0x000004, /*!< Link key */
   654 		EGlobalSecurity			= 0x000008, /*!< Global security settings */
   655 		EPageScanRepMode		= 0x000010, /*!< Page scan repition mode */
   656 		EPageScanMode           = 0x000020, /*!< Page scan mode */
   657 		EPageScanPeriodMode     = 0x000040, /*!< Page scan period */
   658 		EClockOffset			= 0x000080, /*!< Clock offset */
   659 		EUsed					= 0x000100, /*!< Last used */
   660 		ESeen					= 0x000200, /*!< Last seen */
   661 		EIsPaired				= 0x000400, /*!< Is paired */
   662 		EPassKey				= 0x000800, /*!< PassKey */
   663 		EUiCookie				=	0x001000, /*!< User interface specific cookie */
   664 
   665 		EAllNamelessProperties	= 0x00ffffff, /*!< All nameless properties set */
   666 		// Two highest nibbles used by CBTDevice
   667 		};
   668 
   669 private:
   670 	TUint32					iSetMask;		/*!< Bit mask indicating the data members that have been set */
   671 	TBTDevAddr				iBDAddr; 		/*!< The BT address of the remote device */
   672 	TBTDeviceClass			iDeviceClass;	/*!< The class(es) of the remote device */
   673 	TBTLinkKey				iLinkKey;		/*!< The link key */
   674 	TBTDeviceSecurity		iGlobalSecurity;/*!< The overall security criteria for all services which this device may wish to use */
   675 	TBTBasebandParameters	iBasebandParams;/*!< The baseband parameters */
   676 	TTime					iUsed;			/*!< when last connect from/to */
   677 	TTime					iSeen;			/*!< when last seen in inquiry */
   678 	TBool					iPaired;		/*!< Whether this device is paired */
   679 	TBTPinCode				iPassKey;       /*!< PassKey */
   680 	TBTLinkKeyType			iLinkKeyType;	/*!< Link Key Type */
   681 	TUint32					iUiCookie;		/*!< The cookie attached to this device by the UI */
   682 	
   683 	// This data padding has been added to help prevent future binary compatibility breaks	
   684 	// iPadding1 has been used for iLinkKeyType
   685 	// iPadding2 has been used for iUiCookie 
   686 	TUint32     iPadding3; 
   687 	TUint32		iPadding4; 
   688 	};
   689 
   690 
   691 /** Encapsulates all information that must be known about a device.
   692 
   693 Stores useful information concerning a remote device, including names
   694 
   695 @publishedAll
   696 @released
   697 */
   698 NONSHARABLE_CLASS(CBTDevice) : public CBase
   699 	{
   700 friend class TBTNamelessDevice;
   701 public:
   702 	
   703 	IMPORT_C static CBTDevice* NewL(const TBTDevAddr& aBDAddr);	
   704 	IMPORT_C static CBTDevice* NewLC(const TBTDevAddr& aBDAddr);
   705 	IMPORT_C static CBTDevice* NewL(const TBTNamelessDevice& aNamelessDevice);
   706 	IMPORT_C static CBTDevice* NewLC(const TBTNamelessDevice& aNamelessDevice);	
   707 	IMPORT_C static CBTDevice* NewL();
   708 	IMPORT_C static CBTDevice* NewLC();
   709 	IMPORT_C ~CBTDevice();
   710 	IMPORT_C CBTDevice* CopyL() const;
   711 	IMPORT_C void UpdateL(const CBTDevice& aDevice);
   712 	IMPORT_C void AssignL(CBTDevice& aDevice);
   713 	IMPORT_C const TDesC8& DeviceName() const;
   714 	IMPORT_C const TDesC& FriendlyName() const;
   715 	IMPORT_C void SetDeviceNameL(const TDesC8& aName);
   716 	IMPORT_C void SetFriendlyNameL(const TDesC& aName);
   717 	IMPORT_C TBool IsValidDeviceName() const;
   718 	IMPORT_C TBool IsValidFriendlyName() const;
   719 	IMPORT_C TBool operator==(const CBTDevice& aDevice) const;
   720 	IMPORT_C TBool operator!=(const CBTDevice& aDevice) const;
   721 	IMPORT_C TUint CompareTo(const CBTDevice& aDevice) const;
   722 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   723 	IMPORT_C void InternalizeL(RReadStream& aStream);
   724 	IMPORT_C const TBTDevAddr& BDAddr() const;
   725 	IMPORT_C const TBTLinkKey& LinkKey() const;
   726 	IMPORT_C TBTLinkKeyType LinkKeyType() const;
   727 	IMPORT_C TBTDeviceClass DeviceClass() const;
   728 	IMPORT_C const TBTDeviceSecurity GlobalSecurity() const;
   729 	IMPORT_C void SetDeviceAddress(const TBTDevAddr& aBDAddr);
   730 	IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);
   731 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
   732 	IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
   733 	IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting);
   734 	IMPORT_C void DeleteLinkKey();
   735 	IMPORT_C TBool IsValidBDAddr() const;
   736 	IMPORT_C TBool IsValidDeviceClass() const;
   737 	IMPORT_C TBool IsValidLinkKey() const;
   738 	IMPORT_C TBool IsValidGlobalSecurity() const;
   739 	IMPORT_C const TTime& Seen() const;	
   740 	IMPORT_C const TTime& Used() const;
   741 	IMPORT_C void SetUsed(const TTime& aDateTime);
   742 	IMPORT_C void SetSeen(const TTime& aDateTime);
   743 	IMPORT_C TBool IsValidUsed() const;
   744 	IMPORT_C TBool IsValidSeen() const;
   745 	IMPORT_C TBTNamelessDevice& AsNamelessDevice();	
   746 	IMPORT_C const TBTNamelessDevice& AsNamelessDevice() const;
   747 	IMPORT_C TBool IsPaired() const;
   748 	IMPORT_C void SetPaired(TBool aPaired);
   749 	IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
   750 	IMPORT_C TBool IsValidPaired() const;
   751 	IMPORT_C const TBTPinCode& PassKey() const;		
   752 	IMPORT_C void  SetPassKey(const TBTPinCode& aPassKey);		
   753 	IMPORT_C TBool IsValidPassKey() const;
   754 	IMPORT_C TUint PassKeyLength() const;
   755 	IMPORT_C TBool IsValidUiCookie() const;
   756 	IMPORT_C void SetUiCookie(TUint32 aUiCookie);
   757 	IMPORT_C TUint32 UiCookie() const;
   758 	
   759 private:
   760 	CBTDevice();
   761 	void ConstructL();
   762 	void ConstructL(const TBTDevAddr& aAddr);
   763 	void ConstructL(const TBTNamelessDevice& aNamelessDevice);
   764 	void CommonConstructL();
   765 		
   766 public:
   767 	/** Describes the similarities between two devices. */
   768 	enum TBTDeviceNameSelector // not very encapsulated - we extend the enum of TBTNamelessDevice
   769 		{
   770 		/** Device name. */
   771 		EDeviceName		= 0x40000000,
   772 		/** Friendly name. */
   773 		EFriendlyName	= 0x80000000,
   774 		/** 
   775 		All name properties
   776 		*/
   777 		EAllNameProperties = 0xff000000,
   778 		/** Last enum. This is NOT a name property */
   779 		ELast 			= KMaxTUint,
   780 		// All but two highest nibbles used by TBTNamelessDevice
   781 		};
   782 private:
   783 	static const TUint32 KStreamVersion = 0x00000001;
   784 private:
   785 	HBufC8*	iDeviceName;
   786 	HBufC*	iFriendlyName;
   787 	TBTNamelessDevice iDevice;
   788 	};
   789 
   790 
   791 /**Number of bytes in an AFH Host Channel Classification. 
   792 
   793 Size and Length of the TBTAFHHostChannelClassification Descriptor
   794 
   795 @see TBTAFHHostChannelClassification
   796 @publishedAll
   797 @released
   798 */
   799 const TUint8 KHCIAFHHostChannelClassificationSize=10;
   800 
   801 
   802 /**Required number of unknown channels in an AFH Host Channel Classification.
   803 
   804 That is least number of channels in the 79 channel set that must be left
   805 NOT set to bad. In AFH host channel classification a channel may labelled
   806 'bad' (implies do not use) or 'unknown' (implies that it is up to the 
   807 controller to decide if should be used). An attempt to create a 
   808 TBTAFHHostChannelClassification with more than KAFHMinUnknownChannels 
   809 set to 'bad' will result in a KErrUnderflow error being returned.
   810 
   811 @see TBTAFHHostChannelClassification
   812 @publishedAll
   813 @released
   814 */
   815 const TUint8 KAFHMinUnknownChannels=20;
   816 
   817 
   818 /**Number of channels in the Bluetooth channel set that is used with AFH
   819 
   820 The Bluetooth channel set is the set of frequencies used in the Bluetooth
   821 hopping sequence. AFH allows a connection to opt not to use some of the 
   822 frequencies in this set.
   823 
   824 @see TBTAFHHostChannelClassification
   825 @publishedAll
   826 @released
   827 */
   828 const TUint8 KAFHNumChannels=79;
   829 
   830 
   831 /**Descriptor class that should be used to help set up an 
   832 AFH host channel classification for the controller.
   833 
   834 The bits in each byte of this descriptor are used
   835 to tell the controller which channels the host
   836 anticipates will become busy and so advisable for
   837 Bluetooth to avoid. Such channels are referred to 
   838 as 'bad', and are represented by bits set to 0.  
   839 Channels that are not 'bad' are referred to as 'unknown' implying
   840 simply that the host has no knowledge that they are, or
   841 are about to become 'bad'. These are represented by bits set to 1.
   842 Note: The Bluetooth specification demands that at least 20 channels 
   843 must be set to 'unknown'. Any attempt by the user of this class
   844 to set too many 'bad' channels will result in the return of a 
   845 KErrNotSupported error, and the attempt having no effect.
   846 
   847 
   848 @publishedAll
   849 @released
   850 */
   851 NONSHARABLE_CLASS(TBTAFHHostChannelClassification) : public TBuf8<KHCIAFHHostChannelClassificationSize>
   852 	{
   853 public:
   854 	IMPORT_C TBTAFHHostChannelClassification();
   855 	IMPORT_C void Reset();
   856 	IMPORT_C TInt Validate() const;
   857 	IMPORT_C TInt SetChannelBad(const TUint8 aChannel);
   858 	IMPORT_C TInt SetChannelRangeBad(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest);
   859 	
   860 private:
   861 	TInt DoSetChannelBad(const TUint8 aChannel);
   862 	TInt BitByteIndices(TUint8& aByteIndex, TUint8& aBitIndex, const TUint8 aChannel) const;
   863 	TUint8 NumUnknownsWithinRange(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest) const;
   864 	
   865 	// This data padding has been added to help prevent future binary compatibility breaks
   866 	// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used	
   867 	TUint32     iPadding1; 
   868 	TUint32     iPadding2;	
   869     };
   870 
   871 
   872 /** Class used to exchange the local settings with the Registry server.
   873 
   874 	Not a complete set of details of the local device
   875 
   876 	@publishedPartner
   877 	@released
   878 
   879 */
   880 NONSHARABLE_CLASS(TBTLocalDevice)
   881 	{
   882 public:
   883 	IMPORT_C TBTLocalDevice();	
   884 	IMPORT_C const TBTDevAddr& Address() const;
   885 	IMPORT_C TUint32 DeviceClass() const;	
   886 	IMPORT_C const TDesC8& DeviceName() const;	
   887 	IMPORT_C THCIScanEnable ScanEnable() const;	
   888 	IMPORT_C TBool LimitedDiscoverable() const;	
   889 	IMPORT_C TUint8 PowerSetting() const;
   890 	IMPORT_C TBool AFHChannelAssessmentMode() const;
   891 	IMPORT_C TBool AcceptPairedOnlyMode() const;
   892 	IMPORT_C void SetAddress(const TBTDevAddr& aAddr);	
   893 	IMPORT_C void SetDeviceClass(TUint32 aCod);	
   894 	IMPORT_C void SetDeviceName(const TDesC8& aName);	
   895 	IMPORT_C void SetScanEnable(THCIScanEnable aEnable);	
   896 	IMPORT_C void SetLimitedDiscoverable(TBool aOn);	
   897 	IMPORT_C void SetPowerSetting(TUint8 aPowerSetting);	
   898 	IMPORT_C void SetAFHChannelAssessmentMode(TBool aOn);	
   899 	IMPORT_C void SetAcceptPairedOnlyMode(TBool aOn);	
   900 	IMPORT_C TBool IsValidAddress() const;	
   901 	IMPORT_C TBool IsValidDeviceClass() const;	
   902 	IMPORT_C TBool IsValidDeviceName() const;	
   903 	IMPORT_C TBool IsValidScanEnable() const;	
   904 	IMPORT_C TBool IsValidLimitedDiscoverable() const;	
   905 	IMPORT_C TBool IsValidPowerSetting() const;
   906 	IMPORT_C TBool IsValidAFHChannelAssessmentMode() const;
   907 	IMPORT_C TBool IsValidAcceptPairedOnlyMode() const;
   908 
   909 protected:
   910 	enum
   911 		{
   912 		EAddress					= 0x0001,
   913 		ECoD						= 0x0002,
   914 		EDeviceName					= 0x0004,
   915 		EPowerSetting				= 0x0008,
   916 		EScanEnable					= 0x0010,
   917 		ELimitedDiscoverable 		= 0x0020,
   918 		EAFHChannelAssessmentMode	= 0x0040,
   919 		EAcceptPairedOnlyMode 		= 0x0080,
   920 		};	///< Used for indicating if a setting has been set (i.e. not a default/random value) @see iBitMask
   921 		
   922 private:		
   923 	enum
   924 		{
   925 		EAFHChannelAssessmentModeValue	= 0x0001,
   926 		EAcceptPairedOnlyModeValue		= 0x0002,
   927 		};	///< Used for settings requiring little space: allows new settings ot be introduced without increasing the size of this class @see iSimpleSettings
   928 			
   929 		
   930 
   931 	TUint			iSetMask;		 ///< Bit mask indicating the data members that have been set
   932 	TBTDevAddr		iAddress;
   933 	TUint32			iCod;
   934 	TBTDeviceName8	iLocalName;
   935 	TUint8			iPowerSetting;
   936 	THCIScanEnable	iScanEnable;
   937 	TBool			iLimitedDiscoverable;
   938 	TUint32			iSimpleSettings; ///< Only first two bits currently used - for AFH Channel Assessment Mode, and Accept Paired Only Mode
   939 	};
   940 
   941 
   942 #endif