![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
class library to access fischertechnik interfaces via USB
Dependencies: FatFileSystem mbed myBlueUSB neigbourhood rfcomm sdp
btserial.h@1:4676e8b9b357, 2013-03-11 (annotated)
- Committer:
- networker
- Date:
- Mon Mar 11 08:04:37 2013 +0000
- Revision:
- 1:4676e8b9b357
first publication of this experimental class, just for sharing wip
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
networker | 1:4676e8b9b357 | 1 | #ifndef BTSERIAL_H |
networker | 1:4676e8b9b357 | 2 | #define BTSERIAL_H |
networker | 1:4676e8b9b357 | 3 | #include "mbed.h" |
networker | 1:4676e8b9b357 | 4 | #include "RFCOMM.h" |
networker | 1:4676e8b9b357 | 5 | |
networker | 1:4676e8b9b357 | 6 | class btserial { |
networker | 1:4676e8b9b357 | 7 | static const int bufsize = 350; |
networker | 1:4676e8b9b357 | 8 | int recbufsize, sndbufsize; |
networker | 1:4676e8b9b357 | 9 | int sock; |
networker | 1:4676e8b9b357 | 10 | unsigned char sendbuf[bufsize], recbuf[bufsize]; |
networker | 1:4676e8b9b357 | 11 | int sendptr, recptrin, recptrout, free; |
networker | 1:4676e8b9b357 | 12 | static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData); |
networker | 1:4676e8b9b357 | 13 | virtual void stash(const unsigned char *data, int len); |
networker | 1:4676e8b9b357 | 14 | bool open; |
networker | 1:4676e8b9b357 | 15 | public: |
networker | 1:4676e8b9b357 | 16 | btserial(char ba[6], char ch);//outgoing |
networker | 1:4676e8b9b357 | 17 | btserial(char ch);//incoming |
networker | 1:4676e8b9b357 | 18 | void baud(int); |
networker | 1:4676e8b9b357 | 19 | void format(int, Serial::Parity, int); |
networker | 1:4676e8b9b357 | 20 | int putc(int); |
networker | 1:4676e8b9b357 | 21 | int getc(); |
networker | 1:4676e8b9b357 | 22 | int readable() { |
networker | 1:4676e8b9b357 | 23 | if (!open) return -1; |
networker | 1:4676e8b9b357 | 24 | return bufsize-free; |
networker | 1:4676e8b9b357 | 25 | } |
networker | 1:4676e8b9b357 | 26 | int writeable() { |
networker | 1:4676e8b9b357 | 27 | if (!open) return -1; |
networker | 1:4676e8b9b357 | 28 | return bufsize - sendptr; |
networker | 1:4676e8b9b357 | 29 | } |
networker | 1:4676e8b9b357 | 30 | }; |
networker | 1:4676e8b9b357 | 31 | |
networker | 1:4676e8b9b357 | 32 | #endif |