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".
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. 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 /** Defines the granularity of the arrays used in CBTDevice.
89 const TInt KSecurityGranularity=1;
91 /** Cleanup utility for CBTDeviceArrays.
93 Creates a TCleanupItem that calls ResetAndDestroy and then deletes the array.
98 class BTDeviceArrayCleanupStack
102 IMPORT_C static void PushL(CBTDeviceArray* aBTDeviceArray);
104 static void ResetAndDestroy(TAny* aBTDeviceArray);
107 /** Enum used to describe the Bluetooth major service classes.
109 See the bluetooth specification for more details.
114 enum TBTMajorServiceClass
115 { //23 13 <- bit number
116 /** Limited discoverable mode **/
117 EMajorServiceLimitedDiscoverableMode = 0x01, //00000000001
119 EMajorServicePositioning = 0x08, //00000001000
121 EMajorServiceNetworking = 0x10, //00000010000
123 EMajorServiceRendering = 0x20, //00000100000
125 EMajorServiceCapturing = 0x40, //00001000000
126 /** Object transfer **/
127 EMajorServiceObjectTransfer = 0x80, //00010000000
129 EMajorServiceAudio = 0x100, //00100000000
131 EMajorServiceTelephony = 0x200, //01000000000
133 EMajorServiceInformation = 0x400, //10000000000
135 * Old name kept for SC.
137 * @see EMajorServiceAudio
139 EMajorServiceAudioService = 0x100 //00100000000
142 /** Enum used to describe the Bluetooth major device classes.
144 See the bluetooth specification for more details.
149 enum TBTMajorDeviceClass
150 { //12 8 <- bit number
151 /** Miscellaneous device **/
152 EMajorDeviceMisc = 0x0, //00000
153 /** Computer device **/
154 EMajorDeviceComputer = 0x1, //00001
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
168 EMajorDeviceToy = 0x8, //01000
169 /** Unclassified device **/
170 EMajorDeviceUnclassified = 0x1F, //11111
172 * Old name kept for SC.
174 * @see EMajorDeviceAV
176 EMajorDeviceAudioDevice = 0x4, //00100
178 * Old name kept for SC.
180 * @see EMajorDeviceUnclassified
182 EMajorDeviceDeviceUnclassified = 0x1F //11111
185 /** Enum used to describe the Bluetooth minor device classes relating to the "Computer" major device class.
187 See the bluetooth specification for more details.
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
210 /** Enum used to describe the Bluetooth minor device classes relating to the "phone" major device class.
212 See the bluetooth specification for more details.
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
233 /** Enum used to describe the Bluetooth minor device classes relating to the "LAN" major device class.
235 See the bluetooth specification for more details.
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
259 /** Enum used to describe the Bluetooth minor device classes relating to the "AV" major device class.
261 See the bluetooth specification for more details.
266 enum TBTMinorDeviceClassAV
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
304 /** Enum used to describe the Bluetooth minor device classes relating to the "Peripheral" major device class.
306 See the bluetooth specification for more details.
310 enum TBTMinorDeviceClassPeripheral
312 /** Keyboard peripheral device.
314 Note that the keyboard bit can be independently
315 or'd with all other bits.
317 EMinorDevicePeripheralKeyboard = 0x10, //010000
318 /** Pointer peripheral device.
320 Note that the pointer bit can be independently
321 or'd with all other bits.
323 EMinorDevicePeripheralPointer = 0x20, //100000
325 // All other bits are mutually exclusive
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
343 /** Enum used to describe the Bluetooth minor device classes relating to the "Imaging" major device class.
345 See the bluetooth specification for more details.
350 enum TBTMinorDeviceClassImaging
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
362 /** Enum used to describe the Bluetooth minor device classes relating to the "Wearable" major device class.
364 See the bluetooth specification for more details.
369 enum TBTMinorDeviceClassWearable
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
383 /** Enum used to describe the Bluetooth minor device classes relating to the "Toy" major device class.
385 See the bluetooth specification for more details.
390 enum TBTMinorDeviceClassToy
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
405 /** Minor Device class headset.
408 @see TBTMinorDeviceClassAV
410 enum TBTMinorDeviceClassHeadset
412 EHeadsetUnclassified = 0x0, //000000
413 EHeadsetProfile = 0x1, //000001
416 /** Encapsulation of device class definitions.
418 Contains a single TInt as member data and methods to extract the major, minor and service
419 class information from that TInt.
423 NONSHARABLE_CLASS(TBTDeviceClass)
426 IMPORT_C TBTDeviceClass();
427 IMPORT_C TBTDeviceClass(TUint32 aDeviceClass);
428 IMPORT_C TBTDeviceClass(TUint16 aMajorServiceClass, TUint8 aMajorDeviceClass,
429 TUint8 aMinorDeviceClass);
431 IMPORT_C TUint16 MajorServiceClass() const;
432 IMPORT_C TUint8 MajorDeviceClass() const;
433 IMPORT_C TUint8 MinorDeviceClass() const;
434 IMPORT_C TUint32 DeviceClass() const;
436 IMPORT_C TBool operator==(const TBTDeviceClass& aDeviceClass) const;
437 IMPORT_C TBTDeviceClass& operator=(const TBTDeviceClass& aDeviceClass);
439 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
440 IMPORT_C void InternalizeL(RReadStream& aStream);
442 static const TUint32 KStreamVersion = 0x00000001;
444 TUint32 iDeviceClass;
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
452 /** Class to store the security override parameters for a particular remote device.
457 NONSHARABLE_CLASS(TBTDeviceSecurity)
460 /** Enumeration to provide select MITM protection required. */
463 EMitmUnspecified, /*!< No specific MITM protection requirements */
464 EMitmRequired /*!< Require the link is MITM protected */
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);
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);
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;
488 IMPORT_C TUint8 SecurityValue() const;
489 IMPORT_C void SetSecurityValue(TUint8 aDeviceSecurity);
490 IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);
493 IMPORT_C TBool operator==(const TBTDeviceSecurity& aDeviceSecurity) const;
494 IMPORT_C TBool operator!=(const TBTDeviceSecurity& aDeviceSecurity) const;
496 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
497 IMPORT_C void InternalizeL(RReadStream& aStream);
500 /** Enumeration to assist in parsing of security settings. */
501 enum TBTDeviceSecuritySettings
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 */
511 static const TUint32 KStreamVersion = 0x00000001;
515 TUint iPasskeyMinLength;
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
523 /** Class to tie a service uid with a device security setting.
525 This allows us to have service-specific security settings for a device.
530 NONSHARABLE_CLASS(TBTServiceSecurityPerDevice)
533 IMPORT_C TBTServiceSecurityPerDevice();
534 IMPORT_C TBTServiceSecurityPerDevice(const TBTDevAddr& aDevice, const TBTDeviceSecurity& aSecuritySettings);
535 IMPORT_C TBTServiceSecurityPerDevice(const TBTServiceSecurityPerDevice&);
537 IMPORT_C void SetDeviceSecurity(const TBTDeviceSecurity& aSecuritySettings);
538 IMPORT_C void SetAddress(const TBTDevAddr& aAddress);
540 IMPORT_C const TBTDeviceSecurity& DeviceSecurity() const;
541 IMPORT_C const TBTDevAddr& DeviceAddress() const;
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;
547 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
548 IMPORT_C void InternalizeL(RReadStream& aStream);
550 static const TUint32 KStreamVersion = 0x00000001;
552 TBTDevAddr iDeviceAddress; /*!< the address of the device for the overriding security **/
553 TBTDeviceSecurity iDeviceSecurity; /*!< the overriding security */
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
561 /** For Symbian use only
564 NONSHARABLE_CLASS(TBTBasebandParameters)
567 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
568 IMPORT_C void InternalizeL(RReadStream& aStream);
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 ) */
576 static const TUint32 KStreamVersion = 0x00000001;
581 /** Stores parameters for a nameless device.
583 A class which stores useful parameters concerning a remote device
584 But *not* including names
589 NONSHARABLE_CLASS(TBTNamelessDevice)
591 friend class CBTDevice;
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;
645 /** Bitfield of TBTNamelessDevice attributes
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 */
665 EAllNamelessProperties = 0x00ffffff, /*!< All nameless properties set */
666 // Two highest nibbles used by CBTDevice
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 */
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
691 /** Encapsulates all information that must be known about a device.
693 Stores useful information concerning a remote device, including names
698 NONSHARABLE_CLASS(CBTDevice) : public CBase
700 friend class TBTNamelessDevice;
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;
762 void ConstructL(const TBTDevAddr& aAddr);
763 void ConstructL(const TBTNamelessDevice& aNamelessDevice);
764 void CommonConstructL();
767 /** Describes the similarities between two devices. */
768 enum TBTDeviceNameSelector // not very encapsulated - we extend the enum of TBTNamelessDevice
771 EDeviceName = 0x40000000,
772 /** Friendly name. */
773 EFriendlyName = 0x80000000,
777 EAllNameProperties = 0xff000000,
778 /** Last enum. This is NOT a name property */
780 // All but two highest nibbles used by TBTNamelessDevice
783 static const TUint32 KStreamVersion = 0x00000001;
786 HBufC* iFriendlyName;
787 TBTNamelessDevice iDevice;
791 /**Number of bytes in an AFH Host Channel Classification.
793 Size and Length of the TBTAFHHostChannelClassification Descriptor
795 @see TBTAFHHostChannelClassification
799 const TUint8 KHCIAFHHostChannelClassificationSize=10;
802 /**Required number of unknown channels in an AFH Host Channel Classification.
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.
811 @see TBTAFHHostChannelClassification
815 const TUint8 KAFHMinUnknownChannels=20;
818 /**Number of channels in the Bluetooth channel set that is used with AFH
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.
824 @see TBTAFHHostChannelClassification
828 const TUint8 KAFHNumChannels=79;
831 /**Descriptor class that should be used to help set up an
832 AFH host channel classification for the controller.
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.
851 NONSHARABLE_CLASS(TBTAFHHostChannelClassification) : public TBuf8<KHCIAFHHostChannelClassificationSize>
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);
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;
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
872 /** Class used to exchange the local settings with the Registry server.
874 Not a complete set of details of the local device
880 NONSHARABLE_CLASS(TBTLocalDevice)
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;
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
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
931 TUint iSetMask; ///< Bit mask indicating the data members that have been set
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