Yasuhiko YAMAMOTO / Mbed 2 deprecated mbed_TANK_Kinect

Dependencies:   mbed myUSBHost AvailableMemory rfcomm myBlueUSB sdp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers btserial.h Source File

btserial.h

00001 #ifndef BTSERIAL_H
00002 #define BTSERIAL_H
00003 #include "mbed.h"
00004 #include "RFCOMM.h"
00005 
00006 class btserial {
00007     static const int bufsize = 127;
00008     int sock;
00009     unsigned char sendbuf[bufsize], recbuf[bufsize];
00010     int sendptr, recptrin, recptrout, free;
00011     static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData);
00012     void stash(const unsigned char *data, int len);
00013     bool open;
00014 public:
00015     btserial(char ba[6], char ch);//outgoing
00016     btserial(char ch);//incoming
00017     void baud(int);
00018     void format(int, Serial::Parity, int);
00019     int putc(int);
00020     int getc();
00021     int readable() {
00022         if (!open) return -1;
00023         return bufsize-free;
00024     }
00025     int writeable() {
00026         if (!open) return -1;
00027         return bufsize - sendptr;
00028     }
00029 };
00030 
00031 #endif