xref: /haiku/src/servers/bluetooth/LocalDeviceImpl.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
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 _LOCALDEVICE_IMPL_H_
6 #define _LOCALDEVICE_IMPL_H_
7 
8 #include <String.h>
9 
10 #include <bluetooth/bluetooth.h>
11 
12 #include "LocalDeviceHandler.h"
13 
14 #include "HCIDelegate.h"
15 #include "HCIControllerAccessor.h"
16 #include "HCITransportAccessor.h"
17 
18 class LocalDeviceImpl : public LocalDeviceHandler {
19 
20 private:
21 	LocalDeviceImpl(HCIDelegate* hd);
22 
23 public:
24 
25 	// Factory methods
26 	static LocalDeviceImpl* CreateControllerAccessor(BPath* path);
27 	static LocalDeviceImpl* CreateTransportAccessor(BPath* path);
28 	~LocalDeviceImpl();
29 	void Unregister();
30 
31 	void HandleEvent(struct hci_event_header* event);
32 
33 	// Request handling
34 	status_t ProcessSimpleRequest(BMessage* request);
35 
36 private:
37 	void HandleUnexpectedEvent(struct hci_event_header* event);
38 	void HandleExpectedRequest(struct hci_event_header* event,
39 		BMessage* request);
40 
41 	// Events handling
42 	void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request,
43 		int32 index);
44 	void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request,
45 		int32 index);
46 
47 	void NumberOfCompletedPackets(struct hci_ev_num_comp_pkts* event);
48 
49 	// Inquiry
50 	void InquiryResult(uint8* numberOfResponses, BMessage* request);
51 	void InquiryComplete(uint8* status, BMessage* request);
52 	void RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply*
53 		remotename, BMessage* request);
54 
55 	// Connection
56 	void ConnectionComplete(struct hci_ev_conn_complete* event, BMessage* request);
57 	void ConnectionRequest(struct hci_ev_conn_request* event, BMessage* request);
58 	void DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event,
59 		BMessage* request);
60 
61 	// Pairing
62 	void PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request);
63 	void RoleChange(struct hci_ev_role_change* event, BMessage* request);
64 	void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request);
65 	void ReturnLinkKeys(struct hci_ev_return_link_keys* returnedKeys);
66 
67 	void LinkKeyRequested(struct hci_ev_link_key_req* keyReqyested,
68 		BMessage* request);
69 
70 	void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event,
71 		BMessage* request);
72 	void MaxSlotChange(struct hci_ev_max_slot_change* event, BMessage* request);
73 
74 	void HardwareError(struct hci_ev_hardware_error* event);
75 
76 };
77 
78 #endif
79