xref: /haiku/src/servers/bluetooth/LocalDeviceImpl.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
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 
32 	void HandleEvent(struct hci_event_header* event);
33 
34     /* Request handling */
35 	status_t GetAddress(bdaddr_t* bdaddr, BMessage* request);
36 	status_t GetFriendlyName(BString str, BMessage* request);
37 	status_t ProcessSimpleRequest(BMessage* request);
38 
39     /* Events handling */
40     void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request, int32 index);
41 	void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request, int32 index);
42 
43 	// Inquiry
44 	void InquiryResult(uint8* numberOfResponses, BMessage* request);
45 	void InquiryComplete(uint8* status, BMessage* request);
46 	void RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply* remotename, BMessage* request);
47 
48 	// Connection
49 	void ConnectionComplete(struct hci_ev_conn_complete* event, BMessage* request);
50 	void ConnectionRequest(struct hci_ev_conn_request* event, BMessage* request);
51 	void DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event, BMessage *request);
52 
53 	// Pairing
54 	void PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request);
55 	void RoleChange(struct hci_ev_role_change* event, BMessage* request, int32 index);
56 	void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request, int32 index);
57 	void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event, BMessage* request, int32 index);
58 };
59 
60 #endif
61