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
ftclasslibusbdevbt.h@2:9f25a7fa1a54, 2013-12-08 (annotated)
- Committer:
- nobukuma
- Date:
- Sun Dec 08 21:52:09 2013 +0000
- Revision:
- 2:9f25a7fa1a54
- Parent:
- 0:003889bc474f
???BT??????????????????; ?????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nobukuma | 0:003889bc474f | 1 | #ifndef FTCLASSLIBUSBDEVBT_H |
nobukuma | 0:003889bc474f | 2 | #define FTCLASSLIBUSBDEVBT_H |
nobukuma | 0:003889bc474f | 3 | |
nobukuma | 0:003889bc474f | 4 | |
nobukuma | 0:003889bc474f | 5 | class ftbtdev {//small object for ft BT enumeration |
nobukuma | 0:003889bc474f | 6 | inquiry_info info; |
nobukuma | 0:003889bc474f | 7 | public: |
nobukuma | 0:003889bc474f | 8 | ftbtdev(inquiry_info* ii) { |
nobukuma | 0:003889bc474f | 9 | info = *ii; |
nobukuma | 0:003889bc474f | 10 | } |
nobukuma | 0:003889bc474f | 11 | BD_ADDR* BtAddr() { |
nobukuma | 0:003889bc474f | 12 | return &info.bdaddr; |
nobukuma | 0:003889bc474f | 13 | } |
nobukuma | 0:003889bc474f | 14 | }; |
nobukuma | 0:003889bc474f | 15 | |
nobukuma | 0:003889bc474f | 16 | class ftdev {//this should in the future encapsulate the real TXC |
nobukuma | 0:003889bc474f | 17 | int sock; |
nobukuma | 0:003889bc474f | 18 | int parseState; |
nobukuma | 0:003889bc474f | 19 | unsigned short X1_crc, X1_len, X1_pos; |
nobukuma | 0:003889bc474f | 20 | unsigned char *X1_pkt; |
nobukuma | 0:003889bc474f | 21 | unsigned short chksum(); |
nobukuma | 0:003889bc474f | 22 | void parse(const unsigned char *, unsigned); |
nobukuma | 0:003889bc474f | 23 | public: |
nobukuma | 0:003889bc474f | 24 | ftdev(): sock(0) { parseState = 0;} |
nobukuma | 0:003889bc474f | 25 | int Open(BD_ADDR *bt_addr, int chan=1, SocketCallback cb=&ftdev::recv) { |
nobukuma | 0:003889bc474f | 26 | L2CAPAddr s; |
nobukuma | 0:003889bc474f | 27 | s.bdaddr = *bt_addr; |
nobukuma | 0:003889bc474f | 28 | s.psm = chan;//abuse the psm for the channelID |
nobukuma | 0:003889bc474f | 29 | sock = Socket_Open(SOCKET_RFCOM, &s.hdr, cb, this);//Open the serial connection via RFCOMM |
nobukuma | 0:003889bc474f | 30 | if (sock<=0) |
nobukuma | 0:003889bc474f | 31 | printf("Opening of RFCOMM socket for ftdevice failed (%d)\n", sock); |
nobukuma | 0:003889bc474f | 32 | return sock; |
nobukuma | 0:003889bc474f | 33 | } |
nobukuma | 0:003889bc474f | 34 | static void recv(int socket, SocketState state, const u8* data, int len, void* userData) { |
nobukuma | 0:003889bc474f | 35 | if (userData) ((ftdev*)userData)->receive(socket, state, data, len); |
nobukuma | 0:003889bc474f | 36 | } |
nobukuma | 0:003889bc474f | 37 | void receive(int socket, SocketState state, const u8* data, int len);// {printf("ftdev::receive was called: socket %d, state=%d, length=%d\n", socket, state, len);} |
nobukuma | 0:003889bc474f | 38 | }; |
nobukuma | 0:003889bc474f | 39 | |
nobukuma | 0:003889bc474f | 40 | extern ftdev _ftdev; |
nobukuma | 0:003889bc474f | 41 | |
nobukuma | 0:003889bc474f | 42 | unsigned InitFtBtDeviceList(); |
nobukuma | 0:003889bc474f | 43 | int GetNrOfFtBtDevices(); |
nobukuma | 0:003889bc474f | 44 | ftbtdev* GetFtUsbDeviceHandle(unsigned Num); |
nobukuma | 0:003889bc474f | 45 | unsigned OpenFtBtDevice(ftbtdev* d); |
nobukuma | 0:003889bc474f | 46 | |
nobukuma | 0:003889bc474f | 47 | #endif |