Based on myBlueUSB reference ver. http://mbed.org/users/networker/programs/myBlueUSB/lsm1ui
Dependencies: mbed myUSBHost AvailableMemory rfcomm myBlueUSB sdp
btserial.h@0:8d8481ed6d49, 2011-07-05 (annotated)
- Committer:
- kenbumono
- Date:
- Tue Jul 05 08:25:59 2011 +0000
- Revision:
- 0:8d8481ed6d49
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenbumono | 0:8d8481ed6d49 | 1 | #ifndef BTSERIAL_H |
kenbumono | 0:8d8481ed6d49 | 2 | #define BTSERIAL_H |
kenbumono | 0:8d8481ed6d49 | 3 | #include "mbed.h" |
kenbumono | 0:8d8481ed6d49 | 4 | #include "RFCOMM.h" |
kenbumono | 0:8d8481ed6d49 | 5 | |
kenbumono | 0:8d8481ed6d49 | 6 | class btserial { |
kenbumono | 0:8d8481ed6d49 | 7 | static const int bufsize = 127; |
kenbumono | 0:8d8481ed6d49 | 8 | int sock; |
kenbumono | 0:8d8481ed6d49 | 9 | unsigned char sendbuf[bufsize], recbuf[bufsize]; |
kenbumono | 0:8d8481ed6d49 | 10 | int sendptr, recptrin, recptrout, free; |
kenbumono | 0:8d8481ed6d49 | 11 | static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData); |
kenbumono | 0:8d8481ed6d49 | 12 | void stash(const unsigned char *data, int len); |
kenbumono | 0:8d8481ed6d49 | 13 | bool open; |
kenbumono | 0:8d8481ed6d49 | 14 | public: |
kenbumono | 0:8d8481ed6d49 | 15 | btserial(char ba[6], char ch);//outgoing |
kenbumono | 0:8d8481ed6d49 | 16 | btserial(char ch);//incoming |
kenbumono | 0:8d8481ed6d49 | 17 | void baud(int); |
kenbumono | 0:8d8481ed6d49 | 18 | void format(int, Serial::Parity, int); |
kenbumono | 0:8d8481ed6d49 | 19 | int putc(int); |
kenbumono | 0:8d8481ed6d49 | 20 | int getc(); |
kenbumono | 0:8d8481ed6d49 | 21 | int readable() { |
kenbumono | 0:8d8481ed6d49 | 22 | if (!open) return -1; |
kenbumono | 0:8d8481ed6d49 | 23 | return bufsize-free; |
kenbumono | 0:8d8481ed6d49 | 24 | } |
kenbumono | 0:8d8481ed6d49 | 25 | int writeable() { |
kenbumono | 0:8d8481ed6d49 | 26 | if (!open) return -1; |
kenbumono | 0:8d8481ed6d49 | 27 | return bufsize - sendptr; |
kenbumono | 0:8d8481ed6d49 | 28 | } |
kenbumono | 0:8d8481ed6d49 | 29 | }; |
kenbumono | 0:8d8481ed6d49 | 30 | |
kenbumono | 0:8d8481ed6d49 | 31 | #endif |