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 Dorantesclass LocalDeviceImpl : public LocalDeviceHandler {
1930f1d1f3SOliver Ruiz Dorantes
2030f1d1f3SOliver Ruiz Dorantesprivate:
212db900d8SOliver Ruiz Dorantes	LocalDeviceImpl(HCIDelegate* hd);
2230f1d1f3SOliver Ruiz Dorantes
2330f1d1f3SOliver Ruiz Dorantespublic:
2430f1d1f3SOliver Ruiz Dorantes
25ccf28e4dSOliver Ruiz Dorantes	// Factory methods
26ccf28e4dSOliver Ruiz Dorantes	static LocalDeviceImpl* CreateControllerAccessor(BPath* path);
27ccf28e4dSOliver 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);
32ccf28e4dSOliver Ruiz Dorantes
33ccf28e4dSOliver Ruiz Dorantes	// Request handling
3430f1d1f3SOliver Ruiz Dorantes	status_t ProcessSimpleRequest(BMessage* request);
3530f1d1f3SOliver Ruiz Dorantes
362db900d8SOliver Ruiz Dorantesprivate:
372db900d8SOliver Ruiz Dorantes	void HandleUnexpectedEvent(struct hci_event_header* event);
38040fb3eaSOliver Ruiz Dorantes	void HandleExpectedRequest(struct hci_event_header* event,
39040fb3eaSOliver Ruiz Dorantes		BMessage* request);
402db900d8SOliver Ruiz Dorantes
41ccf28e4dSOliver Ruiz Dorantes	// Events handling
42040fb3eaSOliver Ruiz Dorantes	void CommandComplete(struct hci_ev_cmd_complete* event, BMessage* request,
43040fb3eaSOliver Ruiz Dorantes		int32 index);
44040fb3eaSOliver Ruiz Dorantes	void CommandStatus(struct hci_ev_cmd_status* event, BMessage* request,
45040fb3eaSOliver Ruiz Dorantes		int32 index);
46040fb3eaSOliver Ruiz Dorantes
47040fb3eaSOliver Ruiz Dorantes	void NumberOfCompletedPackets(struct hci_ev_num_comp_pkts* event);
48deb0a3edSOliver Ruiz Dorantes
494b7428b5SOliver Ruiz Dorantes	// Inquiry
50ae736793SOliver Ruiz Dorantes	void InquiryResult(uint8* numberOfResponses, BMessage* request);
514b7428b5SOliver Ruiz Dorantes	void InquiryComplete(uint8* status, BMessage* request);
52040fb3eaSOliver Ruiz Dorantes	void RemoteNameRequestComplete(struct hci_ev_remote_name_request_complete_reply*
53040fb3eaSOliver Ruiz Dorantes		remotename, BMessage* request);
54deb0a3edSOliver Ruiz Dorantes
5514ea910dSOliver Ruiz Dorantes	// Connection
5614ea910dSOliver Ruiz Dorantes	void ConnectionComplete(struct hci_ev_conn_complete* event, BMessage* request);
57ccf28e4dSOliver Ruiz Dorantes	void ConnectionRequest(struct hci_ev_conn_request* event, BMessage* request);
58040fb3eaSOliver Ruiz Dorantes	void DisconnectionComplete(struct hci_ev_disconnection_complete_reply* event,
59040fb3eaSOliver Ruiz Dorantes		BMessage* request);
6041da6509SOliver Ruiz Dorantes
6141da6509SOliver Ruiz Dorantes	// Pairing
62ccf28e4dSOliver 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);
65040fb3eaSOliver Ruiz Dorantes	void ReturnLinkKeys(struct hci_ev_return_link_keys* returnedKeys);
66040fb3eaSOliver Ruiz Dorantes
67040fb3eaSOliver Ruiz Dorantes	void LinkKeyRequested(struct hci_ev_link_key_req* keyReqyested,
68040fb3eaSOliver Ruiz Dorantes		BMessage* request);
69040fb3eaSOliver Ruiz Dorantes
70040fb3eaSOliver Ruiz Dorantes	void PageScanRepetitionModeChange(struct hci_ev_page_scan_rep_mode_change* event,
71040fb3eaSOliver Ruiz Dorantes		BMessage* request);
722db900d8SOliver Ruiz Dorantes	void MaxSlotChange(struct hci_ev_max_slot_change* event, BMessage* request);
73deb0a3edSOliver Ruiz Dorantes
74deb0a3edSOliver Ruiz Dorantes	void HardwareError(struct hci_ev_hardware_error* event);
7552e3ce2cSOliver Ruiz Dorantes
7630f1d1f3SOliver Ruiz Dorantes};
7730f1d1f3SOliver Ruiz Dorantes
7830f1d1f3SOliver Ruiz Dorantes#endif
79