Sami Alshorman / Mbed 2 deprecated BluetoothNONIN

Dependencies:   C12832 GPS GSM mbed

Fork of myBlueUSB_localfix by Nobuaki Aoki

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 = 4;
00008     int recbufsize, sndbufsize;
00009     int sock;
00010     unsigned char sendbuf[bufsize], recbuf[bufsize];
00011     int sendptr, recptrin, recptrout, free;
00012     static void cb(int socket, SocketState state, const unsigned char *data, int len, void* userData);
00013     void stash(const unsigned char *data, int len);
00014     bool open;
00015 public:
00016     btserial(char ba[6], char ch);//outgoing
00017     btserial(char ch);//incoming
00018     void baud(int);
00019     void format(int, Serial::Parity, int);
00020     int putc(int);
00021     int getc();
00022     int readable() {
00023         if (!open) return -1;
00024         return bufsize-free;
00025     }
00026     int writeable() {
00027         if (!open) return -1;
00028         return bufsize - sendptr;
00029     }
00030 };
00031 
00032 #endif