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
btserial.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 BTSERIAL_H |
nobukuma | 0:003889bc474f | 2 | #define BTSERIAL_H |
nobukuma | 0:003889bc474f | 3 | #include "mbed.h" |
nobukuma | 0:003889bc474f | 4 | #include "RFCOMM.h" |
nobukuma | 0:003889bc474f | 5 | |
nobukuma | 0:003889bc474f | 6 | class btserial { |
nobukuma | 0:003889bc474f | 7 | static const int bufsize = 350; |
nobukuma | 0:003889bc474f | 8 | int recbufsize, sndbufsize; |
nobukuma | 0:003889bc474f | 9 | int sock; |
nobukuma | 0:003889bc474f | 10 | unsigned char sendbuf[bufsize], recbuf[bufsize]; |
nobukuma | 0:003889bc474f | 11 | int sendptr, recptrin, recptrout, free; |
nobukuma | 0:003889bc474f | 12 | static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData); |
nobukuma | 0:003889bc474f | 13 | void stash(const unsigned char *data, int len); |
nobukuma | 0:003889bc474f | 14 | bool open; |
nobukuma | 0:003889bc474f | 15 | public: |
nobukuma | 0:003889bc474f | 16 | btserial(char ba[6], char ch);//outgoing |
nobukuma | 0:003889bc474f | 17 | btserial(char ch);//incoming |
nobukuma | 0:003889bc474f | 18 | void baud(int); |
nobukuma | 0:003889bc474f | 19 | void format(int, Serial::Parity, int); |
nobukuma | 0:003889bc474f | 20 | int putc(int); |
nobukuma | 0:003889bc474f | 21 | int getc(); |
nobukuma | 0:003889bc474f | 22 | int readable() { |
nobukuma | 0:003889bc474f | 23 | if (!open) return -1; |
nobukuma | 0:003889bc474f | 24 | return bufsize-free; |
nobukuma | 0:003889bc474f | 25 | } |
nobukuma | 0:003889bc474f | 26 | int writeable() { |
nobukuma | 0:003889bc474f | 27 | if (!open) return -1; |
nobukuma | 0:003889bc474f | 28 | return bufsize - sendptr; |
nobukuma | 0:003889bc474f | 29 | } |
nobukuma | 0:003889bc474f | 30 | }; |
nobukuma | 0:003889bc474f | 31 | |
nobukuma | 0:003889bc474f | 32 | #endif |