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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
23 #include <bluetooth/hci/hciopcodes.h>
24 #include <bluetooth/hci/hciconsts.h>
26 /** The maximum length of a bluetooth device name, as stored in CBTDevice.
30 static const TInt KMaxBluetoothNameLen = KHCILocalDeviceNameMaxLength;
32 /** The maximum length of the user-assinged friendly name for a bluetooth device, as stored in CBTDevice.
36 static const TInt KMaxFriendlyNameLen = 100;
38 /** Length of a bluetooth device name. This is not to be used outside of the sub-system. Retained for binary compatibility.
42 static const TInt KMaxBCBluetoothNameLen = 256;
44 //forward declarations
47 class TBTServiceSecurityPerDevice;
49 /** A typedef'ed array of CBTDevice objects.
53 typedef CArrayPtrFlat<CBTDevice> CBTDeviceArray;
55 /** A typedef'ed array of TBTServiceSecurityPerDevice objects.
59 typedef RArray<TBTServiceSecurityPerDevice> RBTSecurityArray;
61 /** Wide descriptor of correct length to hold a bluetooth device name.
65 typedef TBuf<KMaxBCBluetoothNameLen> TBTDeviceName;
67 /** Narrow descriptor of correct length to hold a bluetooth device name.
72 typedef TBuf8<KMaxBluetoothNameLen> TBTDeviceName8;
74 /** Utility class to convert between a wide TBTDeviceName and a narrow TBTDeviceName8.
78 class BTDeviceNameConverter
81 IMPORT_C static TBTDeviceName ToUnicodeL(const TBTDeviceName8& aName);
82 IMPORT_C static TBTDeviceName8 ToUTF8L(const TBTDeviceName& aName);
85 /** Cleanup utility for CBTDeviceArrays.
87 Creates a TCleanupItem that calls ResetAndDestroy and then deletes the array.
92 class BTDeviceArrayCleanupStack
96 IMPORT_C static void PushL(CBTDeviceArray* aBTDeviceArray);
98 static void ResetAndDestroy(TAny* aBTDeviceArray);
101 /** Enum used to describe the Bluetooth major service classes.
103 See the bluetooth specification for more details.
108 enum TBTMajorServiceClass
109 { //23 13 <- bit number
110 /** Limited discoverable mode **/
111 EMajorServiceLimitedDiscoverableMode = 0x01, //00000000001
113 EMajorServicePositioning = 0x08, //00000001000
115 EMajorServiceNetworking = 0x10, //00000010000
117 EMajorServiceRendering = 0x20, //00000100000
119 EMajorServiceCapturing = 0x40, //00001000000
120 /** Object transfer **/
121 EMajorServiceObjectTransfer = 0x80, //00010000000
123 EMajorServiceAudio = 0x100, //00100000000
125 EMajorServiceTelephony = 0x200, //01000000000
127 EMajorServiceInformation = 0x400, //10000000000
129 * Old name kept for SC.
131 * @see EMajorServiceAudio
133 EMajorServiceAudioService = 0x100 //00100000000
136 /** Enum used to describe the Bluetooth major device classes.
138 See the bluetooth specification for more details.
143 enum TBTMajorDeviceClass
144 { //12 8 <- bit number
145 /** Miscellaneous device **/
146 EMajorDeviceMisc = 0x0, //00000
147 /** Computer device **/
148 EMajorDeviceComputer = 0x1, //00001
150 EMajorDevicePhone = 0x2, //00010
151 /** LAN access point device **/
152 EMajorDeviceLanAccessPoint = 0x3, //00011
153 /** Audio-video device **/
154 EMajorDeviceAV = 0x4, //00100
155 /** Peripheral device **/
156 EMajorDevicePeripheral = 0x5, //00101
157 /** Imaging device **/
158 EMajorDeviceImaging = 0x6, //00110
159 /** Wearable device **/
160 EMajorDeviceWearable = 0x7, //00111
162 EMajorDeviceToy = 0x8, //01000
163 /** Unclassified device **/
164 EMajorDeviceUnclassified = 0x1F, //11111
166 * Old name kept for SC.
168 * @see EMajorDeviceAV
170 EMajorDeviceAudioDevice = 0x4, //00100
172 * Old name kept for SC.
174 * @see EMajorDeviceUnclassified
176 EMajorDeviceDeviceUnclassified = 0x1F //11111
179 /** Enum used to describe the Bluetooth minor device classes relating to the "Computer" major device class.
181 See the bluetooth specification for more details.
186 enum TBTMinorDeviceClassComputer
187 { //7 2 <- bit number
188 /** Unclassified computer device **/
189 EMinorDeviceComputerUnclassified = 0x0, //000000
190 /** Desktop computer device **/
191 EMinorDeviceComputerDesktop = 0x1, //000001
192 /** Server computer device **/
193 EMinorDeviceComputerServer = 0x2, //000010
194 /** Laptop computer device **/
195 EMinorDeviceComputerLaptop = 0x3, //000011
196 /** Handheld computer device **/
197 EMinorDeviceComputerHandheld = 0x4, //000100
198 /** Palm computer device **/
199 EMinorDeviceComputerPalmSize = 0x5, //000101
200 /** Wearable computer device **/
201 EMinorDeviceComputerWearable = 0x6 //000110
204 /** Enum used to describe the Bluetooth minor device classes relating to the "phone" major device class.
206 See the bluetooth specification for more details.
211 enum TBTMinorDeviceClassPhone
212 { //7 2 <- bit number
213 /** Unclassified phone device **/
214 EMinorDevicePhoneUnclassified = 0x0, //000000
215 /** Cellular phone device **/
216 EMinorDevicePhoneCellular = 0x1, //000001
217 /** Cordless phone device **/
218 EMinorDevicePhoneCordless = 0x2, //000010
219 /** Smart phone device **/
220 EMinorDevicePhoneSmartPhone = 0x3, //000011
221 /** Wired modem phone device **/
222 EMinorDevicePhoneWiredModem = 0x4, //000100
223 /** ISDN phone device **/
224 EMinorDevicePhoneCommonISDNAccess = 0x5 //000101
227 /** Enum used to describe the Bluetooth minor device classes relating to the "LAN" major device class.
229 See the bluetooth specification for more details.
233 enum TBTMinorDeviceClassLAN
234 { //7 2 <- bit number
235 /** LAN is currently 0% utilitized **/
236 EMinorDeviceLANFullyAvailable = 0x0, //000000
237 /** LAN is currently 1-17% utilitized **/
238 EMinorDeviceLANServiceOne = 0x8, //001000
239 /** LAN is currently 17-33% utilitized **/
240 EMinorDeviceLANServiceTwo = 0x10, //010000
241 /** LAN is currently 33-50% utilitized **/
242 EMinorDeviceLANServiceThree = 0x18, //011000
243 /** LAN is currently 50-67% utilitized **/
244 EMinorDeviceLANServiceFour = 0x20, //100000
245 /** LAN is currently 67-83% utilitized **/
246 EMinorDeviceLANServiceFive = 0x28, //101000
247 /** LAN is currently 83-99% utilitized **/
248 EMinorDeviceLANServiceSix = 0x30, //110000
249 /** LAN is currently 100% utilitized **/
250 EMinorDeviceLANNoService = 0x38 //111000
253 /** Enum used to describe the Bluetooth minor device classes relating to the "AV" major device class.
255 See the bluetooth specification for more details.
260 enum TBTMinorDeviceClassAV
262 /** Unclassified AV Device **/
263 EMinorDeviceAVUnclassified = 0x0, //000000
264 /** Headset AV Device **/
265 EMinorDeviceAVHeadset = 0x1, //000001
266 /** Handsfree AV Device **/
267 EMinorDeviceAVHandsfree = 0x2, //000010
268 /** Microphone AV Device **/
269 EMinorDeviceAVMicrophone = 0x4, //000100
270 /** Loudspeaker AV Device **/
271 EMinorDeviceAVLoudspeaker = 0x5, //000101
272 /** Headphone AV Device **/
273 EMinorDeviceAVHeadphones = 0x6, //000110
274 /** Portable audio AV Device **/
275 EMinorDeviceAVPortableAudio = 0x7, //000111
276 /** Car audio AV Device **/
277 EMinorDeviceAVCarAudio = 0x8, //001000
278 /** Set top box AV Device **/
279 EMinorDeviceAVSetTopBox = 0x9, //001001
280 /** Hifi audio AV Device **/
281 EMinorDeviceAVHiFiAudio = 0xA, //001010
282 /** VCR AV Device **/
283 EMinorDeviceAVVCR = 0xB, //001011
284 /** Video camera AV Device **/
285 EMinorDeviceAVVideoCamera = 0xC, //001100
286 /** Camcorder AV Device **/
287 EMinorDeviceAVCamcorder = 0xD, //001101
288 /** Video monitor AV Device **/
289 EMinorDeviceAVVideoMonitor = 0xE, //001110
290 /** Video display and loudspeaker AV Device **/
291 EMinorDeviceAVVideoDisplayAndLoudspeaker = 0xF, //001111
292 /** Video conferencing AV Device **/
293 EMinorDeviceAVVideoConferencing = 0x10, //010000
294 /** Gaming toy AV Device **/
295 EMinorDeviceAVGamingToy = 0x12 //010010
298 /** Enum used to describe the Bluetooth minor device classes relating to the "Peripheral" major device class.
300 See the bluetooth specification for more details.
304 enum TBTMinorDeviceClassPeripheral
306 /** Keyboard peripheral device.
308 Note that the keyboard bit can be independently
309 or'd with all other bits.
311 EMinorDevicePeripheralKeyboard = 0x10, //010000
312 /** Pointer peripheral device.
314 Note that the pointer bit can be independently
315 or'd with all other bits.
317 EMinorDevicePeripheralPointer = 0x20, //100000
319 // All other bits are mutually exclusive
321 /** Uncategorized peripheral device **/
322 EMinorDevicePeripheralUncategorized = 0x00, //000000
323 /** Joystick peripheral device **/
324 EMinorDevicePeripheralJoystick = 0x01, //000001
325 /** Gamepad peripheral device **/
326 EMinorDevicePeripheralGamepad = 0x02, //000010
327 /** Remote control peripheral device **/
328 EMinorDevicePeripheralRemoteControl = 0x03, //000011
329 /** Sensing peripheral device **/
330 EMinorDevicePeripheralSensingDevice = 0x04, //000100
331 /** Digitizer tablet peripheral device **/
332 EMinorDevicePeripheralDigitizerTablet = 0x05, //000101
333 /** Card reader peripheral device **/
334 EMinorDevicePeripheralCardReader = 0x06 //000110
337 /** Enum used to describe the Bluetooth minor device classes relating to the "Imaging" major device class.
339 See the bluetooth specification for more details.
344 enum TBTMinorDeviceClassImaging
346 /** Display imaging device **/
347 EMinorDeviceImagingDisplay = 0x04, //000100
348 /** Camera imaging device **/
349 EMinorDeviceImagingCamera = 0x08, //001000
350 /** Scanner imaging device **/
351 EMinorDeviceImagingScanner = 0x10, //010000
352 /** Printer imaging device **/
353 EMinorDeviceImagingPrinter = 0x20, //100000
356 /** Enum used to describe the Bluetooth minor device classes relating to the "Wearable" major device class.
358 See the bluetooth specification for more details.
363 enum TBTMinorDeviceClassWearable
365 /** Wrist watch wearable device **/
366 EMinorDeviceWearableWatch = 0x01, //000001
367 /** Pager wearable device **/
368 EMinorDeviceWearablePager = 0x02, //000010
369 /** Jacket wearable device **/
370 EMinorDeviceWearableJacket = 0x03, //000011
371 /** Helmet wearable device **/
372 EMinorDeviceWearableHelmet = 0x04, //000100
373 /** Glasses wearable device **/
374 EMinorDeviceWearableGlasses = 0x05, //000101
377 /** Enum used to describe the Bluetooth minor device classes relating to the "Toy" major device class.
379 See the bluetooth specification for more details.
384 enum TBTMinorDeviceClassToy
386 /** Robot toy device **/
387 EMinorDeviceToyRobot = 0x01, //000001
388 /** Vehicle toy device **/
389 EMinorDeviceToyVehicle = 0x02, //000010
390 /** Doll toy device **/
391 EMinorDeviceToyDoll = 0x03, //000011
392 /** Controller toy device **/
393 EMinorDeviceToyController = 0x04, //000100
394 /** Game toy device **/
395 EMinorDeviceToyGame = 0x05, //000101
398 /** Encapsulation of device class definitions.
400 Contains a single TInt as member data and methods to extract the major, minor and service
401 class information from that TInt.
405 NONSHARABLE_CLASS(TBTDeviceClass)
408 IMPORT_C TBTDeviceClass();
409 IMPORT_C TBTDeviceClass(TUint32 aDeviceClass);
410 IMPORT_C TBTDeviceClass(TUint16 aMajorServiceClass, TUint8 aMajorDeviceClass,
411 TUint8 aMinorDeviceClass);
413 IMPORT_C TUint16 MajorServiceClass() const;
414 IMPORT_C TUint8 MajorDeviceClass() const;
415 IMPORT_C TUint8 MinorDeviceClass() const;
416 IMPORT_C TUint32 DeviceClass() const;
418 IMPORT_C TBool operator==(const TBTDeviceClass& aDeviceClass) const;
419 IMPORT_C TBTDeviceClass& operator=(const TBTDeviceClass& aDeviceClass);
421 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
422 IMPORT_C void InternalizeL(RReadStream& aStream);
424 static const TUint32 KStreamVersion = 0x00000001;
426 TUint32 iDeviceClass;
428 // This data padding has been added to help prevent future binary compatibility breaks
429 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
434 /** Class to store the security override parameters for a particular remote device.
439 NONSHARABLE_CLASS(TBTDeviceSecurity)
442 /** Enumeration to provide select MITM protection required. */
445 EMitmUnspecified, /*!< No specific MITM protection requirements */
446 EMitmRequired /*!< Require the link is MITM protected */
450 IMPORT_C TBTDeviceSecurity();
451 IMPORT_C TBTDeviceSecurity(TUint8 aSecurity);
452 IMPORT_C TBTDeviceSecurity(TUint8 aSecurity, TUint aPasskeyMinLength);
453 IMPORT_C TBTDeviceSecurity(TBool aNoAuthenticate, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
454 IMPORT_C TBTDeviceSecurity(TMitmRequired aMitmRequirements, TBool aNoAuthorise, TBool aEncrypt, TBool aBanned);
456 IMPORT_C void SetNoAuthenticate(TBool aDecision);
457 IMPORT_C void SetMitmRequirements(TMitmRequired aDecision);
458 IMPORT_C void SetNoAuthorise(TBool aDecision);
459 IMPORT_C void SetEncrypt(TBool aDecision);
460 IMPORT_C void SetBanned(TBool aDecision);
462 IMPORT_C TBool NoAuthenticate() const;
463 IMPORT_C TMitmRequired MitmRequirements() const;
464 IMPORT_C TBool NoAuthorise() const;
465 IMPORT_C TBool Encrypt() const;
466 IMPORT_C TBool Banned() const;
467 IMPORT_C TUint PasskeyMinLength() const;
470 IMPORT_C TUint8 SecurityValue() const;
471 IMPORT_C void SetSecurityValue(TUint8 aDeviceSecurity);
472 IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
475 IMPORT_C TBool operator==(const TBTDeviceSecurity& aDeviceSecurity) const;
476 IMPORT_C TBool operator!=(const TBTDeviceSecurity& aDeviceSecurity) const;
478 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
479 IMPORT_C void InternalizeL(RReadStream& aStream);
482 /** Enumeration to assist in parsing of security settings. */
483 enum TBTDeviceSecuritySettings
485 ENoAuthenticate = 0x01, /*!< Don't authenticate the link @deprecated */
486 ENoAuthorise = 0x02, /*!< Don't authorise the connection */
487 EEncrypt = 0x04, /*!< Encrypt the link */
488 EBanned = 0x08, /*!< Don't connect to the device */
489 EMitmProtectionRequired = 0x10, /*!< Require the link is MITM protected */
493 static const TUint32 KStreamVersion = 0x00000001;
497 TUint iPasskeyMinLength;
499 // This data padding has been added to help prevent future binary compatibility breaks
500 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
505 /** Class to tie a service uid with a device security setting.
507 This allows us to have service-specific security settings for a device.
512 NONSHARABLE_CLASS(TBTServiceSecurityPerDevice)
515 IMPORT_C TBTServiceSecurityPerDevice();
516 IMPORT_C TBTServiceSecurityPerDevice(const TBTDevAddr& aDevice, const TBTDeviceSecurity& aSecuritySettings);
517 IMPORT_C TBTServiceSecurityPerDevice(const TBTServiceSecurityPerDevice&);
519 IMPORT_C void SetDeviceSecurity(const TBTDeviceSecurity& aSecuritySettings);
520 IMPORT_C void SetAddress(const TBTDevAddr& aAddress);
522 IMPORT_C const TBTDeviceSecurity& DeviceSecurity() const;
523 IMPORT_C const TBTDevAddr& DeviceAddress() const;
525 IMPORT_C void operator=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice);
526 IMPORT_C TBool operator==(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
527 IMPORT_C TBool operator!=(const TBTServiceSecurityPerDevice& aServiceSecurityPerDevice) const;
529 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
530 IMPORT_C void InternalizeL(RReadStream& aStream);
532 static const TUint32 KStreamVersion = 0x00000001;
534 TBTDevAddr iDeviceAddress; /*!< the address of the device for the overriding security **/
535 TBTDeviceSecurity iDeviceSecurity; /*!< the overriding security */
537 // This data padding has been added to help prevent future binary compatibility breaks
538 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
543 /** Stores parameters for a nameless device.
545 A class which stores useful parameters concerning a remote device
546 But *not* including names
551 NONSHARABLE_CLASS(TBTNamelessDevice)
553 friend class CBTDevice;
556 /** For Symbian use only
559 NONSHARABLE_CLASS(TBTBasebandParameters)
562 void ExternalizeL(RWriteStream& aStream) const;
563 void InternalizeL(RReadStream& aStream);
565 TUint8 iPageScanRepetitionMode; /*!< Page Scan repetition mode of remote device ( valid if > 0 ) */
566 TUint8 iPageScanPeriodMode; /*!< Page scan period mode of remote device */
567 TUint8 iPageScanMode; /*!< Page scan mode of remote device ( valid if > 0 ) */
568 TUint16 iClockOffset; /*!< clock off set of remote device ( valid if > 0 ) */
571 static const TUint32 KStreamVersion = 0x00000001;
575 IMPORT_C TBTNamelessDevice();
576 IMPORT_C const TBTDevAddr& Address() const;
577 IMPORT_C const TBTDeviceClass& DeviceClass() const;
578 IMPORT_C const TBTLinkKey& LinkKey() const;
579 IMPORT_C TBTLinkKeyType LinkKeyType() const;
580 IMPORT_C TUint8 PageScanRepMode() const;
581 IMPORT_C TUint8 PageScanMode() const;
582 IMPORT_C TUint8 PageScanPeriodMode() const;
583 IMPORT_C TUint16 ClockOffset() const;
584 IMPORT_C const TTime& Seen() const;
585 IMPORT_C const TTime& Used() const;
586 IMPORT_C const TBTDeviceSecurity& GlobalSecurity() const;
587 IMPORT_C void SetAddress(const TBTDevAddr& aBDAddr);
588 IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);
589 IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
590 IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
591 IMPORT_C void SetPageScanRepMode(TUint8 aPageScanRepMode);
592 IMPORT_C void SetPageScanPeriodMode(TUint8 aPageScanPeriodMode);
593 IMPORT_C void SetPageScanMode(TUint8 aPageScanMode);
594 IMPORT_C void SetClockOffset(TUint16 aClockOffSet);
595 IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting);
596 IMPORT_C void SetUsed(const TTime& aDateTime);
597 IMPORT_C void SetSeen(const TTime& aDateTime);
598 IMPORT_C TBool IsValidAddress() const;
599 IMPORT_C TBool IsValidDeviceClass() const;
600 IMPORT_C TBool IsValidLinkKey() const;
601 IMPORT_C TBool IsValidGlobalSecurity() const;
602 IMPORT_C TBool IsValidPageScanRepMode() const;
603 IMPORT_C TBool IsValidPageScanMode() const;
604 IMPORT_C TBool IsValidPageScanPeriodMode() const;
605 IMPORT_C TBool IsValidClockOffset() const;
606 IMPORT_C TBool IsValidUsed() const;
607 IMPORT_C TBool IsValidSeen() const;
608 IMPORT_C void DeleteLinkKey();
609 IMPORT_C void Update(const TBTNamelessDevice& aDevice);
610 IMPORT_C TBTNamelessDevice& operator=(const TBTNamelessDevice& aDevice);
611 IMPORT_C TBool operator==(const TBTNamelessDevice& aDevice) const;
612 IMPORT_C TBool operator!=(const TBTNamelessDevice& aDevice) const;
613 IMPORT_C TUint CompareTo(const TBTNamelessDevice& aDevice) const;
614 IMPORT_C TBool IsPaired() const;
615 IMPORT_C void SetPaired(TBool aPaired);
616 IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
617 IMPORT_C TBool IsValidPaired() const;
618 IMPORT_C const TBTPinCode& PassKey() const;
619 IMPORT_C void SetPassKey(const TBTPinCode& aPassKey);
620 IMPORT_C TBool IsValidPassKey() const;
621 IMPORT_C TUint PassKeyLength() const;
622 IMPORT_C TBool IsValidUiCookie() const;
623 IMPORT_C void SetUiCookie(TUint32 aUiCookie);
624 IMPORT_C TUint32 UiCookie() const;
626 /** Bitfield of TBTNamelessDevice attributes
627 This enum is to only be used by phone manufacturers, not by application developers.
633 EAddress = 0x000001, /*!< Device address */
634 EDeviceClass = 0x000002, /*!< Device class */
635 ELinkKey = 0x000004, /*!< Link key */
636 EGlobalSecurity = 0x000008, /*!< Global security settings */
637 EPageScanRepMode = 0x000010, /*!< Page scan repition mode */
638 EPageScanMode = 0x000020, /*!< Page scan mode */
639 EPageScanPeriodMode = 0x000040, /*!< Page scan period */
640 EClockOffset = 0x000080, /*!< Clock offset */
641 EUsed = 0x000100, /*!< Last used */
642 ESeen = 0x000200, /*!< Last seen */
643 EIsPaired = 0x000400, /*!< Is paired */
644 EPassKey = 0x000800, /*!< PassKey */
645 EUiCookie = 0x001000, /*!< User interface specific cookie */
647 EAllNamelessProperties = 0x00ffffff, /*!< All nameless properties set */
648 // Two highest nibbles used by CBTDevice
652 TUint32 iSetMask; /*!< Bit mask indicating the data members that have been set */
653 TBTDevAddr iBDAddr; /*!< The BT address of the remote device */
654 TBTDeviceClass iDeviceClass; /*!< The class(es) of the remote device */
655 TBTLinkKey iLinkKey; /*!< The link key */
656 TBTDeviceSecurity iGlobalSecurity;/*!< The overall security criteria for all services which this device may wish to use */
657 TBTBasebandParameters iBasebandParams;/*!< The baseband parameters */
658 TTime iUsed; /*!< when last connect from/to */
659 TTime iSeen; /*!< when last seen in inquiry */
660 TBool iPaired; /*!< Whether this device is paired */
661 TBTPinCode iPassKey; /*!< PassKey */
662 TBTLinkKeyType iLinkKeyType; /*!< Link Key Type */
663 TUint32 iUiCookie; /*!< The cookie attached to this device by the UI */
665 // This data padding has been added to help prevent future binary compatibility breaks.
666 // iPadding1 has been used for iLinkKeyType
667 // iPadding2 has been used for iUiCookie
673 /** Encapsulates all information that must be known about a device.
675 Stores useful information concerning a remote device, including names
680 NONSHARABLE_CLASS(CBTDevice) : public CBase
682 friend class TBTNamelessDevice;
685 IMPORT_C static CBTDevice* NewL(const TBTDevAddr& aBDAddr);
686 IMPORT_C static CBTDevice* NewLC(const TBTDevAddr& aBDAddr);
687 IMPORT_C static CBTDevice* NewL(const TBTNamelessDevice& aNamelessDevice);
688 IMPORT_C static CBTDevice* NewLC(const TBTNamelessDevice& aNamelessDevice);
689 IMPORT_C static CBTDevice* NewL();
690 IMPORT_C static CBTDevice* NewLC();
691 IMPORT_C ~CBTDevice();
692 IMPORT_C CBTDevice* CopyL() const;
693 IMPORT_C void UpdateL(const CBTDevice& aDevice);
694 IMPORT_C void AssignL(CBTDevice& aDevice);
695 IMPORT_C const TDesC8& DeviceName() const;
696 IMPORT_C const TDesC& FriendlyName() const;
697 IMPORT_C void SetDeviceNameL(const TDesC8& aName);
698 IMPORT_C void SetFriendlyNameL(const TDesC& aName);
699 IMPORT_C TBool IsValidDeviceName() const;
700 IMPORT_C TBool IsValidFriendlyName() const;
701 IMPORT_C TBool operator==(const CBTDevice& aDevice) const;
702 IMPORT_C TBool operator!=(const CBTDevice& aDevice) const;
703 IMPORT_C TUint CompareTo(const CBTDevice& aDevice) const;
704 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
705 IMPORT_C void InternalizeL(RReadStream& aStream);
706 IMPORT_C const TBTDevAddr& BDAddr() const;
707 IMPORT_C const TBTLinkKey& LinkKey() const;
708 IMPORT_C TBTLinkKeyType LinkKeyType() const;
709 IMPORT_C TBTDeviceClass DeviceClass() const;
710 IMPORT_C const TBTDeviceSecurity GlobalSecurity() const;
711 IMPORT_C void SetDeviceAddress(const TBTDevAddr& aBDAddr);
712 IMPORT_C void SetDeviceClass(TBTDeviceClass aDeviceClass);
713 IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey);
714 IMPORT_C void SetLinkKey(const TBTLinkKey& aLinkKey, TBTLinkKeyType aLinkKeyType);
715 IMPORT_C void SetGlobalSecurity(const TBTDeviceSecurity& aSetting);
716 IMPORT_C void DeleteLinkKey();
717 IMPORT_C TBool IsValidBDAddr() const;
718 IMPORT_C TBool IsValidDeviceClass() const;
719 IMPORT_C TBool IsValidLinkKey() const;
720 IMPORT_C TBool IsValidGlobalSecurity() const;
721 IMPORT_C const TTime& Seen() const;
722 IMPORT_C const TTime& Used() const;
723 IMPORT_C void SetUsed(const TTime& aDateTime);
724 IMPORT_C void SetSeen(const TTime& aDateTime);
725 IMPORT_C TBool IsValidUsed() const;
726 IMPORT_C TBool IsValidSeen() const;
727 IMPORT_C TBTNamelessDevice& AsNamelessDevice();
728 IMPORT_C const TBTNamelessDevice& AsNamelessDevice() const;
729 IMPORT_C TBool IsPaired() const;
730 IMPORT_C void SetPaired(TBool aPaired);
731 IMPORT_C void SetPaired(TBTLinkKeyType aLinkKeyType);
732 IMPORT_C TBool IsValidPaired() const;
733 IMPORT_C const TBTPinCode& PassKey() const;
734 IMPORT_C void SetPassKey(const TBTPinCode& aPassKey);
735 IMPORT_C TBool IsValidPassKey() const;
736 IMPORT_C TUint PassKeyLength() const;
737 IMPORT_C TBool IsValidUiCookie() const;
738 IMPORT_C void SetUiCookie(TUint32 aUiCookie);
739 IMPORT_C TUint32 UiCookie() const;
744 void ConstructL(const TBTDevAddr& aAddr);
745 void ConstructL(const TBTNamelessDevice& aNamelessDevice);
746 void CommonConstructL();
749 /** Describes the similarities between two devices. */
750 enum TBTDeviceNameSelector // not very encapsulated - we extend the enum of TBTNamelessDevice
753 EDeviceName = 0x40000000,
754 /** Friendly name. */
755 EFriendlyName = 0x80000000,
759 EAllNameProperties = 0xff000000,
760 /** Last enum. This is NOT a name property */
762 // All but two highest nibbles used by TBTNamelessDevice
765 static const TUint32 KStreamVersion = 0x00000001;
768 HBufC* iFriendlyName;
769 TBTNamelessDevice iDevice;
773 /**Number of bytes in an AFH Host Channel Classification.
775 Size and Length of the TBTAFHHostChannelClassification Descriptor
777 @see TBTAFHHostChannelClassification
781 const TUint8 KHCIAFHHostChannelClassificationSize=10;
784 /**Required number of unknown channels in an AFH Host Channel Classification.
786 That is least number of channels in the 79 channel set that must be left
787 NOT set to bad. In AFH host channel classification a channel may labelled
788 'bad' (implies do not use) or 'unknown' (implies that it is up to the
789 controller to decide if should be used). An attempt to create a
790 TBTAFHHostChannelClassification with more than KAFHMinUnknownChannels
791 set to 'bad' will result in a KErrUnderflow error being returned.
793 @see TBTAFHHostChannelClassification
797 const TUint8 KAFHMinUnknownChannels=20;
800 /**Number of channels in the Bluetooth channel set that is used with AFH
802 The Bluetooth channel set is the set of frequencies used in the Bluetooth
803 hopping sequence. AFH allows a connection to opt not to use some of the
804 frequencies in this set.
806 @see TBTAFHHostChannelClassification
810 const TUint8 KAFHNumChannels=79;
813 /**Descriptor class that should be used to help set up an
814 AFH host channel classification for the controller.
816 The bits in each byte of this descriptor are used
817 to tell the controller which channels the host
818 anticipates will become busy and so advisable for
819 Bluetooth to avoid. Such channels are referred to
820 as 'bad', and are represented by bits set to 0.
821 Channels that are not 'bad' are referred to as 'unknown' implying
822 simply that the host has no knowledge that they are, or
823 are about to become 'bad'. These are represented by bits set to 1.
824 Note: The Bluetooth specification demands that at least 20 channels
825 must be set to 'unknown'. Any attempt by the user of this class
826 to set too many 'bad' channels will result in the return of a
827 KErrNotSupported error, and the attempt having no effect.
833 NONSHARABLE_CLASS(TBTAFHHostChannelClassification) : public TBuf8<KHCIAFHHostChannelClassificationSize>
836 IMPORT_C TBTAFHHostChannelClassification();
837 IMPORT_C void Reset();
838 IMPORT_C TInt Validate() const;
839 IMPORT_C TInt SetChannelBad(const TUint8 aChannel);
840 IMPORT_C TInt SetChannelRangeBad(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest);
843 TInt DoSetChannelBad(const TUint8 aChannel);
844 TInt BitByteIndices(TUint8& aByteIndex, TUint8& aBitIndex, const TUint8 aChannel) const;
845 TUint8 NumUnknownsWithinRange(const TUint8 aChannelRangeLowest, const TUint8 aChannelRangeHighest) const;
847 // This data padding has been added to help prevent future binary compatibility breaks
848 // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
854 /** Class used to exchange the local settings with the Registry server.
856 Not a complete set of details of the local device
862 NONSHARABLE_CLASS(TBTLocalDevice)
865 IMPORT_C TBTLocalDevice();
866 IMPORT_C const TBTDevAddr& Address() const;
867 IMPORT_C TUint32 DeviceClass() const;
868 IMPORT_C const TDesC8& DeviceName() const;
869 IMPORT_C THCIScanEnable ScanEnable() const;
870 IMPORT_C TBool LimitedDiscoverable() const;
871 IMPORT_C TUint8 PowerSetting() const;
872 IMPORT_C TBool AFHChannelAssessmentMode() const;
873 IMPORT_C TBool AcceptPairedOnlyMode() const;
874 IMPORT_C void SetAddress(const TBTDevAddr& aAddr);
875 IMPORT_C void SetDeviceClass(TUint32 aCod);
876 IMPORT_C void SetDeviceName(const TDesC8& aName);
877 IMPORT_C void SetScanEnable(THCIScanEnable aEnable);
878 IMPORT_C void SetLimitedDiscoverable(TBool aOn);
879 IMPORT_C void SetPowerSetting(TUint8 aPowerSetting);
880 IMPORT_C void SetAFHChannelAssessmentMode(TBool aOn);
881 IMPORT_C void SetAcceptPairedOnlyMode(TBool aOn);
882 IMPORT_C TBool IsValidAddress() const;
883 IMPORT_C TBool IsValidDeviceClass() const;
884 IMPORT_C TBool IsValidDeviceName() const;
885 IMPORT_C TBool IsValidScanEnable() const;
886 IMPORT_C TBool IsValidLimitedDiscoverable() const;
887 IMPORT_C TBool IsValidPowerSetting() const;
888 IMPORT_C TBool IsValidAFHChannelAssessmentMode() const;
889 IMPORT_C TBool IsValidAcceptPairedOnlyMode() const;
896 EDeviceName = 0x0004,
897 EPowerSetting = 0x0008,
898 EScanEnable = 0x0010,
899 ELimitedDiscoverable = 0x0020,
900 EAFHChannelAssessmentMode = 0x0040,
901 EAcceptPairedOnlyMode = 0x0080,
902 }; //< Used for indicating if a setting has been set (i.e. not a default/random value) @see iBitMask
907 EAFHChannelAssessmentModeValue = 0x0001,
908 EAcceptPairedOnlyModeValue = 0x0002,
909 }; //< Used for settings requiring little space: allows new settings ot be introduced without increasing the size of this class @see iSimpleSettings
913 TUint iSetMask; //< Bit mask indicating the data members that have been set
916 TBTDeviceName8 iLocalName;
917 TUint8 iPowerSetting;
918 THCIScanEnable iScanEnable;
919 TBool iLimitedDiscoverable;
920 TUint32 iSimpleSettings; //< Only first two bits currently used - for AFH Channel Assessment Mode, and Accept Paired Only Mode