1291e1143SOliver Ruiz Dorantes/*
2291e1143SOliver Ruiz Dorantes * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3e5da0ec5SOliver Ruiz Dorantes * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
4291e1143SOliver Ruiz Dorantes * All rights reserved. Distributed under the terms of the MIT License.
5291e1143SOliver Ruiz Dorantes */
6291e1143SOliver Ruiz Dorantes#ifndef _HCIDELEGATE_H_
7291e1143SOliver Ruiz Dorantes#define _HCIDELEGATE_H_
8291e1143SOliver Ruiz Dorantes
9291e1143SOliver Ruiz Dorantes#include <fcntl.h>
10291e1143SOliver Ruiz Dorantes#include <unistd.h>
11291e1143SOliver Ruiz Dorantes#include <stdio.h>
12291e1143SOliver Ruiz Dorantes#include <Path.h>
13291e1143SOliver Ruiz Dorantes
14291e1143SOliver Ruiz Dorantes#include <bluetooth/HCI/btHCI_transport.h>
15291e1143SOliver Ruiz Dorantes
16291e1143SOliver Ruiz Dorantestypedef void* raw_command;
17291e1143SOliver Ruiz Dorantes
18291e1143SOliver Ruiz Dorantes
19291e1143SOliver Ruiz Dorantesclass HCIDelegate {
20291e1143SOliver Ruiz Dorantes
21291e1143SOliver Ruiz Dorantes	public:
22291e1143SOliver Ruiz Dorantes		HCIDelegate(BPath* path)
23291e1143SOliver Ruiz Dorantes		{
24e5da0ec5SOliver Ruiz Dorantes			//TODO create such queue
25ccf28e4dSOliver Ruiz Dorantes			fIdentifier = -1;
26291e1143SOliver Ruiz Dorantes		}
27e5da0ec5SOliver Ruiz Dorantes
28ccf28e4dSOliver Ruiz Dorantes
29ccf28e4dSOliver Ruiz Dorantes		hci_id Id(void) const
30291e1143SOliver Ruiz Dorantes		{
31ccf28e4dSOliver Ruiz Dorantes			return fIdentifier;
32291e1143SOliver Ruiz Dorantes		}
3348cca06aSOliver Ruiz Dorantes
34e5da0ec5SOliver Ruiz Dorantes
35e5da0ec5SOliver Ruiz Dorantes		virtual ~HCIDelegate()
36e5da0ec5SOliver Ruiz Dorantes 		{
37ccf28e4dSOliver Ruiz Dorantes
38e5da0ec5SOliver Ruiz Dorantes		}
39e5da0ec5SOliver Ruiz Dorantes
40e5da0ec5SOliver Ruiz Dorantes		virtual status_t IssueCommand(raw_command rc, size_t size)=0;
41e5da0ec5SOliver Ruiz Dorantes			// TODO means to be private use QueueCommand
4248cca06aSOliver Ruiz Dorantes		virtual status_t Launch()=0;
4348cca06aSOliver Ruiz Dorantes
443205e523SOliver Ruiz Dorantes
45e5da0ec5SOliver Ruiz Dorantes		void FreeWindow(uint8 slots)
46e5da0ec5SOliver Ruiz Dorantes		{
47e5da0ec5SOliver Ruiz Dorantes			// TODO: hci control flow
483205e523SOliver Ruiz Dorantes		}
493205e523SOliver Ruiz Dorantes
50e5da0ec5SOliver Ruiz Dorantes
513205e523SOliver Ruiz Dorantes		status_t QueueCommand(raw_command rc, size_t size)
523205e523SOliver Ruiz Dorantes		{
53e5da0ec5SOliver Ruiz Dorantes			// TODO: this is suposed to queue the command in a queue so all
54ccf28e4dSOliver Ruiz Dorantes			// are actually send to HW to implement HCI FlowControl requeriments
553205e523SOliver Ruiz Dorantes			return IssueCommand(rc, size);
563205e523SOliver Ruiz Dorantes		}
573205e523SOliver Ruiz Dorantes
58291e1143SOliver Ruiz Dorantes	protected:
59291e1143SOliver Ruiz Dorantes
60ccf28e4dSOliver Ruiz Dorantes		hci_id fIdentifier;
61e5da0ec5SOliver Ruiz Dorantes
62291e1143SOliver Ruiz Dorantes	private:
63291e1143SOliver Ruiz Dorantes
64291e1143SOliver Ruiz Dorantes};
65291e1143SOliver Ruiz Dorantes
66291e1143SOliver Ruiz Dorantes#endif
67