1/*
2 * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef _LOCAL_DEVICE_H
6#define _LOCAL_DEVICE_H
7
8#include <bluetooth/bluetooth.h>
9#include <bluetooth/DeviceClass.h>
10#include <bluetooth/BluetoothDevice.h>
11
12#include <bluetooth/HCI/btHCI.h>
13
14#include <Messenger.h>
15#include <Message.h>
16
17#include <String.h>
18
19
20namespace Bluetooth {
21
22class DiscoveryAgent;
23
24class LocalDevice : public BluetoothDevice {
25
26public:
27	/* Possible throwing */
28	static	LocalDevice*	GetLocalDevice();
29	static	uint32			GetLocalDeviceCount();
30
31	static	LocalDevice*	GetLocalDevice(const hci_id hid);
32	static	LocalDevice*	GetLocalDevice(const bdaddr_t bdaddr);
33
34			DiscoveryAgent*	GetDiscoveryAgent();
35			BString			GetFriendlyName();
36			status_t		SetFriendlyName(BString& name);
37			DeviceClass		GetDeviceClass();
38			status_t		SetDeviceClass(DeviceClass deviceClass);
39
40	/* Possible throwing */
41			status_t		SetDiscoverable(int mode);
42			status_t		SetAuthentication(bool authentication);
43
44			BString			GetProperty(const char* property);
45			status_t 		GetProperty(const char* property, uint32* value);
46
47			int				GetDiscoverable();
48			bdaddr_t		GetBluetoothAddress();
49	/*
50			ServiceRecord getRecord(Connection notifier);
51			void updateRecord(ServiceRecord srvRecord);
52	*/
53			hci_id	ID() const;
54private:
55			LocalDevice(hci_id hid);
56			virtual	~LocalDevice();
57
58			status_t		_ReadLocalVersion();
59			status_t		_ReadBufferSize();
60			status_t		_ReadLocalFeatures();
61			status_t		_ReadTimeouts();
62			status_t		_ReadLinkKeys();
63			status_t		Reset();
64
65	static	LocalDevice*	RequestLocalDeviceID(BMessage* request);
66
67			BMessenger*		fMessenger;
68			hci_id			fHid;
69
70	friend class DiscoveryAgent;
71	friend class RemoteDevice;
72	friend class PincodeWindow;
73
74};
75
76}
77
78
79#ifndef _BT_USE_EXPLICIT_NAMESPACE
80using Bluetooth::LocalDevice;
81#endif
82
83#endif // _LOCAL_DEVICE_H
84