Based on myBlueUSB and rosserial_mbed
Dependencies: mbed myUSBHost AvailableMemory myBlueUSB
Diff: btserial.h
- Revision:
- 0:7684b95768c7
diff -r 000000000000 -r 7684b95768c7 btserial.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/btserial.h Sat Sep 17 14:21:35 2011 +0000 @@ -0,0 +1,33 @@ +#ifndef BTSERIAL_H +#define BTSERIAL_H +#include "mbed.h" +#include "RFCOMM.h" + +class btserial { + static const int bufsize = 350; + int recbufsize, sndbufsize; + int sock; + unsigned char sendbuf[bufsize], recbuf[bufsize]; + int sendptr, recptrin, recptrout, free; + static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData); + void stash(const unsigned char *data, int len); + bool open; +public: + btserial(char ba[6], char ch);//outgoing + btserial(char ch);//incoming + void baud(int); + void format(int, Serial::Parity, int); + int putc(int); + int btserial::write(u8* data, int len); + int getc(); + int readable() { + if (!open) return -1; + return bufsize-free; + } + int writeable() { + if (!open) return -1; + return bufsize - sendptr; + } +}; + +#endif \ No newline at end of file