1 /* 2 * Copyright 2007-2008 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 _HCIDELEGATE_H_ 9 #define _HCIDELEGATE_H_ 10 11 #include <fcntl.h> 12 #include <unistd.h> 13 #include <stdio.h> 14 #include <Path.h> 15 16 #include <bluetooth/HCI/btHCI_transport.h> 17 18 19 typedef void* raw_command; 20 21 22 class HCIDelegate { 23 24 public: 25 HCIDelegate(BPath* path) 26 { 27 status_t status; 28 29 fFD = open (path->Path(), O_RDWR); 30 if (fFD > 0) { 31 // find out which ID was assigned 32 status = ioctl(fFD, GET_HCI_ID, &fHID, 0); 33 printf("%s: hid retrieved %lx status=%ld\n", __FUNCTION__, fHID, status); 34 } 35 else { 36 printf("%s: Device driver could not be opened %ld\n", __FUNCTION__, fHID); 37 fHID = B_ERROR; 38 } 39 40 //TODO create such queue 41 42 } 43 44 45 hci_id GetID(void) 46 { 47 return fHID; 48 } 49 50 virtual status_t IssueCommand(raw_command rc, size_t size)=0; // TODO means to be private 51 virtual status_t Launch()=0; 52 53 void FreeWindow(uint8 slots) { // TODO: hci control flow 54 55 } 56 57 status_t QueueCommand(raw_command rc, size_t size) 58 { 59 // TODO: this is suposed to queue the command in a queue so all are actually send to HW 60 return IssueCommand(rc, size); 61 } 62 63 64 protected: 65 66 67 hci_id fHID; 68 int fFD; 69 70 private: 71 72 73 }; 74 75 #endif 76