1 /* 2 * Copyright 2007 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 _BTHCI_TRANSPORT_H_ 9 #define _BTHCI_TRANSPORT_H_ 10 11 #include <bluetooth/HCI/btHCI.h> 12 13 #include <net_buffer.h> 14 #include <Drivers.h> 15 16 typedef enum { ANCILLYANT = (1<<0), 17 RUNNING = (1<<1), 18 LEAVING = (1<<2), 19 SENDING = (1<<3), 20 PROCESSING = (1<<4) 21 } bt_transport_status_t; 22 23 typedef uint8 bt_stat_t; 24 typedef struct bt_hci_statistics { 25 26 bt_stat_t acceptedTX; 27 bt_stat_t rejectedTX; 28 bt_stat_t successfulTX; 29 bt_stat_t errorTX; 30 31 bt_stat_t acceptedRX; 32 bt_stat_t rejectedRX; 33 bt_stat_t successfulRX; 34 bt_stat_t errorRX; 35 36 bt_stat_t commandTX; 37 bt_stat_t eventRX; 38 bt_stat_t aclTX; 39 bt_stat_t aclRX; 40 bt_stat_t scoTX; 41 bt_stat_t scoRX; 42 bt_stat_t escoTX; 43 bt_stat_t escoRX; 44 45 bt_stat_t bytesRX; 46 bt_stat_t bytesTX; 47 48 49 } bt_hci_statistics; 50 51 /* TODO: Possible Hooks which drivers will have to provide */ 52 typedef struct bt_hci_transport { 53 54 status_t (*SendCommand)(hci_id hci_dev, net_buffer* snbuf); 55 status_t (*SendPacket)(hci_id hci_dev, net_buffer* nbuf ); 56 status_t (*SendSCO)(hci_id hci_dev, net_buffer* nbuf ); 57 status_t (*DeliverStatistics)(bt_hci_statistics* statistics); 58 59 transport_type kind; 60 char name[B_OS_NAME_LENGTH]; 61 62 } bt_hci_transport; 63 64 typedef struct bt_hci_device { 65 66 transport_type kind; 67 char realName[B_OS_NAME_LENGTH]; 68 69 } bt_hci_device; 70 71 72 /* Here the transport driver have some flags that */ 73 /* can be used to inform the upper layer about some */ 74 /* special behaouvior to perform */ 75 76 #define BT_IGNORE_THIS_DEVICE (1<<0) 77 #define BT_SCO_NOT_WORKING (1<<1) 78 #define BT_WILL_NEED_A_RESET (1<<2) 79 #define BT_DIGIANSWER (1<<4) 80 81 /* Mandatory IOCTLS to be */ 82 83 #define BT_IOCTLS_OFFSET 3000 84 85 enum { 86 ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET , 87 BT_UP, 88 GET_STATICS, 89 GET_NOTIFICATION_PORT, 90 GET_HCI_ID 91 }; 92 93 #define PACK_PORTCODE(type,hid,data) ((type&0xFF)<<24|(hid&0xFF)<<16|(data&0xFFFF)) 94 #define GET_PORTCODE_TYPE(code) ((code&0xFF000000)>>24) 95 #define GET_PORTCODE_HID(code) ((code&0x00FF0000)>>16) 96 #define GET_PORTCODE_DATA(code) ((code&0x0000FFFF)) 97 98 /* Port drivers can use to send information (1 for all for 99 at moment refer to ioctl GET_NOTIFICATION_PORT)*/ 100 #define BT_USERLAND_PORT_NAME "BT kernel-user Land" 101 102 #endif 103