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 %ld 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 41 42 } 43 44 hci_id GetID(void) 45 { 46 return fHID; 47 } 48 49 virtual status_t IssueCommand(raw_command rc, size_t size) 50 { 51 return B_ERROR; 52 } 53 54 protected: 55 56 57 hci_id fHID; 58 int fFD; 59 60 private: 61 62 63 }; 64 65 #endif 66