xref: /haiku/src/servers/bluetooth/LocalDeviceImpl.h (revision 040fb3eaaca3d80c40a301d6ba8c2b1efb9a6190)
130f1d1f3SOliver Ruiz Dorantes /*
230f1d1f3SOliver Ruiz Dorantes  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
330f1d1f3SOliver Ruiz Dorantes  * All rights reserved. Distributed under the terms of the MIT License.
430f1d1f3SOliver Ruiz Dorantes  */
530f1d1f3SOliver Ruiz Dorantes #ifndef _LOCALDEVICE_IMPL_H_
630f1d1f3SOliver Ruiz Dorantes #define _LOCALDEVICE_IMPL_H_
730f1d1f3SOliver Ruiz Dorantes 
830f1d1f3SOliver Ruiz Dorantes #include <String.h>
930f1d1f3SOliver Ruiz Dorantes 
1030f1d1f3SOliver Ruiz Dorantes #include <bluetooth/bluetooth.h>
1130f1d1f3SOliver Ruiz Dorantes 
1230f1d1f3SOliver Ruiz Dorantes #include "LocalDeviceHandler.h"
1330f1d1f3SOliver Ruiz Dorantes 
1430f1d1f3SOliver Ruiz Dorantes #include "HCIDelegate.h"
1530f1d1f3SOliver Ruiz Dorantes #include "HCIControllerAccessor.h"
1630f1d1f3SOliver Ruiz Dorantes #include "HCITransportAccessor.h"
1730f1d1f3SOliver Ruiz Dorantes 
1830f1d1f3SOliver Ruiz Dorantes class LocalDeviceImpl : public LocalDeviceHandler {
1930f1d1f3SOliver Ruiz Dorantes 
2030f1d1f3SOliver Ruiz Dorantes private:
2130f1d1f3SOliver Ruiz Dorantes 	LocalDeviceImpl(HCIDelegate* hd);
2230f1d1f3SOliver Ruiz Dorantes 
2330f1d1f3SOliver Ruiz Dorantes public:
2430f1d1f3SOliver Ruiz Dorantes 
2530f1d1f3SOliver Ruiz Dorantes 	// Factory methods
2630f1d1f3SOliver Ruiz Dorantes 	static LocalDeviceImpl* CreateControllerAccessor(BPath* path);
2730f1d1f3SOliver Ruiz Dorantes 	static LocalDeviceImpl* CreateTransportAccessor(BPath* path);
28ccf28e4dSOliver Ruiz Dorantes 	~LocalDeviceImpl();
29ccf28e4dSOliver Ruiz Dorantes 	void Unregister();
3030f1d1f3SOliver Ruiz Dorantes 
3130f1d1f3SOliver Ruiz Dorantes 	void HandleEvent(struct hci_event_header* event);
3230f1d1f3SOliver Ruiz Dorantes 
33ccf28e4dSOliver Ruiz Dorantes 	// Request handling
3430f1d1f3SOliver Ruiz Dorantes 	status_t ProcessSimpleRequest(BMessage* request);
3530f1d1f3SOliver Ruiz Dorantes 
362db900d8SOliver Ruiz Dorantes private:
372db900d8SOliver Ruiz Dorantes 	void HandleUnexpectedEvent(struct hci_event_header* event);
38*040fb3eaSOliver Ruiz Dorantes 	void HandleExpectedRequest(struct hci_event_header* event,
39*040fb3eaSOliver Ruiz Dorantes 		BMessage* request);
402db900d8SOliver Ruiz Dorantes 
41ccf28e4dSOliver Ruiz Dorantes 	// Events handling
42*040fb3eaSOliver Ruiz Dorantes 	void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request,
43*040fb3eaSOliver Ruiz Dorantes 		int32 index);
44*040fb3eaSOliver Ruiz Dorantes 	void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request,
45*040fb3eaSOliver Ruiz Dorantes 		int32 index);
46*040fb3eaSOliver Ruiz Dorantes 
47*040fb3eaSOliver Ruiz Dorantes 	void NumberOfCompletedPackets(struct hci_ev_num_comp_pkts* event);
4830f1d1f3SOliver Ruiz Dorantes 
494b7428b5SOliver Ruiz Dorantes 	// Inquiry
50ae736793SOliver Ruiz Dorantes 	void InquiryResult(uint8* numberOfResponses, BMessage* request);
514b7428b5SOliver Ruiz Dorantes 	void InquiryComplete(uint8* status, BMessage* request);
52*040fb3eaSOliver Ruiz Dorantes 	void RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply*
53*040fb3eaSOliver Ruiz Dorantes 		remotename, BMessage* request);
5414ea910dSOliver Ruiz Dorantes 
5514ea910dSOliver Ruiz Dorantes 	// Connection
5614ea910dSOliver Ruiz Dorantes 	void ConnectionComplete(struct hci_ev_conn_complete* event, BMessage* request);
5741da6509SOliver Ruiz Dorantes 	void ConnectionRequest(struct hci_ev_conn_request* event, BMessage* request);
58*040fb3eaSOliver Ruiz Dorantes 	void DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event,
59*040fb3eaSOliver Ruiz Dorantes 		BMessage* request);
6041da6509SOliver Ruiz Dorantes 
6141da6509SOliver Ruiz Dorantes 	// Pairing
6214ea910dSOliver Ruiz Dorantes 	void PinCodeRequest(struct hci_ev_pin_code_req* event, BMessage* request);
632db900d8SOliver Ruiz Dorantes 	void RoleChange(struct hci_ev_role_change* event, BMessage* request);
642db900d8SOliver Ruiz Dorantes 	void LinkKeyNotify(struct hci_ev_link_key_notify* event, BMessage* request);
65*040fb3eaSOliver Ruiz Dorantes 	void ReturnLinkKeys(struct hci_ev_return_link_keys* returnedKeys);
66*040fb3eaSOliver Ruiz Dorantes 
67*040fb3eaSOliver Ruiz Dorantes 	void LinkKeyRequested(struct hci_ev_link_key_req* keyReqyested,
68*040fb3eaSOliver Ruiz Dorantes 		BMessage* request);
69*040fb3eaSOliver Ruiz Dorantes 
70*040fb3eaSOliver Ruiz Dorantes 	void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event,
71*040fb3eaSOliver Ruiz Dorantes 		BMessage* request);
722db900d8SOliver Ruiz Dorantes 	void MaxSlotChange(struct hci_ev_max_slot_change* event, BMessage* request);
73ddac4074SOliver Ruiz Dorantes 
74ddac4074SOliver Ruiz Dorantes 	void HardwareError(struct hci_ev_hardware_error* event);
7552e3ce2cSOliver Ruiz Dorantes 
7630f1d1f3SOliver Ruiz Dorantes };
7730f1d1f3SOliver Ruiz Dorantes 
7830f1d1f3SOliver Ruiz Dorantes #endif
79