local fix version of myBlueUSB (http://mbed.org/users/networker/code/myBlueUSB/). - merge deleted files which are required to compile. - enable echo back of received data via RFCOMM.

Dependencies:   AvailableMemory FatFileSystem mbed myUSBHost

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HCITransportUSB.h Source File

HCITransportUSB.h

00001 #ifndef HCITRANSPORTUSB_H
00002 #define HCITRANSPORTUSB_H
00003 #define MAX_HCL_SIZE 260
00004 #define MAX_ACL_SIZE 400
00005 #include "USBHost.h"
00006 
00007 extern int bulk;
00008 
00009 class HCITransportUSB : public HCITransport {
00010     int _device;
00011     u8* _hciBuffer;
00012     u8* _aclBuffer;
00013 
00014 public:
00015     void Open(int device, u8* hciBuffer, u8* aclBuffer) {
00016         _device = device;
00017         _hciBuffer = hciBuffer;
00018         _aclBuffer = aclBuffer;
00019         USBInterruptTransfer(_device,0x81,_hciBuffer,MAX_HCL_SIZE,HciCallback,this);
00020         USBBulkTransfer(_device,0x82,_aclBuffer,MAX_ACL_SIZE,AclCallback,this);
00021     }
00022 
00023     static void HciCallback(int device, int endpoint, int status, u8* data, int len, void* userData) {
00024         HCI* t = ((HCITransportUSB*)userData)->_target; //printf("HCI: %d bytes avail\n", len);
00025         if (t){
00026         printfBytes("HCICallback:", data, len);
00027             t->HCIRecv(data,len);
00028             }
00029         USBInterruptTransfer(device,0x81,data,MAX_HCL_SIZE,HciCallback,userData);
00030     }
00031 
00032     static void AclCallback(int device, int endpoint, int status, u8* data, int len, void* userData) {
00033         HCI* t = ((HCITransportUSB*)userData)->_target; printf("ACL: %d bytes avail\n", len);
00034         if (t){
00035         printfBytes("ACLCallback:", data, len);
00036             t->ACLRecv(data,len);
00037             }
00038             printf("ACL Read pending..\n");
00039         USBBulkTransfer(device,0x82,data,MAX_ACL_SIZE,AclCallback,userData);
00040     }
00041 
00042     virtual void HCISend(const u8* data, int len) {
00043         printfBytes("HCISend:", data, len);
00044         USBControlTransfer(_device,REQUEST_TYPE_CLASS, 0, 0, 0,(u8*)data,len);
00045     }
00046 
00047     virtual int ACLSend(const u8* data, int len) { //printf("send %d bytes to usb\n", len);
00048         if (len > _acl_mtu) {
00049             printf("Max outgoing packet(%d) size exceeded, segmenting necessary, pktlen = %d\n", _acl_mtu, len);
00050             return 0;
00051         }
00052 #ifdef HOST_CONTR_FLOW
00053         if (data_credits == 0)
00054           printf("Waiting for ACL buffers...\n");
00055         while (data_credits < 1) {
00056             USBLoop();
00057         }
00058         data_credits--;
00059 #endif
00060         printfBytes("ACLSend:", data, len);
00061         return USBBulkTransfer(_device,0x02,(u8*)data,len);
00062     }
00063 };
00064 
00065 #endif