xref: /haiku/src/servers/bluetooth/LocalDeviceImpl.h (revision b671e9bbdbd10268a042b4f4cc4317ccd03d105e)
1 /*
2  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3  *
4  * All rights reserved. Distributed under the terms of the MIT License.
5  *
6  */
7 
8 #ifndef _LOCALDEVICE_IMPL_H_
9 #define _LOCALDEVICE_IMPL_H_
10 
11 #include <String.h>
12 
13 #include <bluetooth/bluetooth.h>
14 
15 #include "LocalDeviceHandler.h"
16 
17 #include "HCIDelegate.h"
18 #include "HCIControllerAccessor.h"
19 #include "HCITransportAccessor.h"
20 
21 class LocalDeviceImpl : public LocalDeviceHandler {
22 
23 private:
24 	LocalDeviceImpl(HCIDelegate* hd);
25 
26 public:
27 
28 	// Factory methods
29 	static LocalDeviceImpl* CreateControllerAccessor(BPath* path);
30 	static LocalDeviceImpl* CreateTransportAccessor(BPath* path);
31 	~LocalDeviceImpl();
32 	void Unregister();
33 
34 	void HandleEvent(struct hci_event_header* event);
35 
36 	// Request handling
37 	status_t GetAddress(bdaddr_t* bdaddr, BMessage* request);
38 	status_t GetFriendlyName(BString str, BMessage* request);
39 	status_t ProcessSimpleRequest(BMessage* request);
40 
41 	// Events handling
42 	void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, int32 index);
43 	void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, int32 index);
44 
45 	// Inquiry
46 	void InquiryResult(uint8* numberOfResponses, BMessage* request);
47 	void InquiryComplete(uint8* status, BMessage* request);
48 	void RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply* remotename, BMessage* request);
49 
50 	// Connection
51 	void ConnectionComplete(struct hci_ev_conn_complete* event, BMessage* request);
52 	void ConnectionRequest(struct hci_ev_conn_request* event, BMessage* request);
53 	void DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event, BMessage* request);
54 
55 	// Pairing
56 	void PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request);
57 	void RoleChange(struct hci_ev_role_change* event, BMessage* request, int32 index);
58 	void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request, int32 index);
59 	void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event, BMessage* request, int32 index);
60 	void MaxSlotChange(struct hci_ev_max_slot_change* event, BMessage* request, int32 index);
61 
62 	void HardwareError(struct hci_ev_hardware_error* event);
63 
64 };
65 
66 #endif
67