Based on myBlueUSB and rosserial_mbed

Dependencies:   mbed myUSBHost AvailableMemory myBlueUSB

Committer:
OTL
Date:
Sat Sep 17 14:24:13 2011 +0000
Revision:
1:18139954944b
Parent:
0:7684b95768c7
remove m3pi and main

Who changed what in which revision?

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