Pulse Oximeter (NONIN) communicates with mbed via Bluetooth dongle and sends Heart Rate and Oxygen Saturation via GPRS module

Dependencies:   C12832 GPS GSM mbed

Fork of myBlueUSB_localfix by Nobuaki Aoki

Committer:
samialshorman
Date:
Tue Apr 14 21:48:07 2015 +0000
Revision:
3:55a622e3dbb5
Parent:
0:003889bc474f
Nonin (Pulse Oximeter) connected to mbed lpc 1768 by Bluetooth dongle and sends SMS including Heart Rate and Oxygen saturation by GPRS module

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nobukuma 0:003889bc474f 1 #ifndef FTCLASSLIBUSBDEVBT_H
nobukuma 0:003889bc474f 2 #define FTCLASSLIBUSBDEVBT_H
nobukuma 0:003889bc474f 3
nobukuma 0:003889bc474f 4
nobukuma 0:003889bc474f 5 class ftbtdev {//small object for ft BT enumeration
nobukuma 0:003889bc474f 6 inquiry_info info;
nobukuma 0:003889bc474f 7 public:
nobukuma 0:003889bc474f 8 ftbtdev(inquiry_info* ii) {
nobukuma 0:003889bc474f 9 info = *ii;
nobukuma 0:003889bc474f 10 }
nobukuma 0:003889bc474f 11 BD_ADDR* BtAddr() {
nobukuma 0:003889bc474f 12 return &info.bdaddr;
nobukuma 0:003889bc474f 13 }
nobukuma 0:003889bc474f 14 };
nobukuma 0:003889bc474f 15
nobukuma 0:003889bc474f 16 class ftdev {//this should in the future encapsulate the real TXC
nobukuma 0:003889bc474f 17 int sock;
nobukuma 0:003889bc474f 18 int parseState;
nobukuma 0:003889bc474f 19 unsigned short X1_crc, X1_len, X1_pos;
nobukuma 0:003889bc474f 20 unsigned char *X1_pkt;
nobukuma 0:003889bc474f 21 unsigned short chksum();
nobukuma 0:003889bc474f 22 void parse(const unsigned char *, unsigned);
nobukuma 0:003889bc474f 23 public:
nobukuma 0:003889bc474f 24 ftdev(): sock(0) { parseState = 0;}
nobukuma 0:003889bc474f 25 int Open(BD_ADDR *bt_addr, int chan=1, SocketCallback cb=&ftdev::recv) {
nobukuma 0:003889bc474f 26 L2CAPAddr s;
nobukuma 0:003889bc474f 27 s.bdaddr = *bt_addr;
nobukuma 0:003889bc474f 28 s.psm = chan;//abuse the psm for the channelID
nobukuma 0:003889bc474f 29 sock = Socket_Open(SOCKET_RFCOM, &s.hdr, cb, this);//Open the serial connection via RFCOMM
nobukuma 0:003889bc474f 30 if (sock<=0)
nobukuma 0:003889bc474f 31 printf("Opening of RFCOMM socket for ftdevice failed (%d)\n", sock);
nobukuma 0:003889bc474f 32 return sock;
nobukuma 0:003889bc474f 33 }
nobukuma 0:003889bc474f 34 static void recv(int socket, SocketState state, const u8* data, int len, void* userData) {
nobukuma 0:003889bc474f 35 if (userData) ((ftdev*)userData)->receive(socket, state, data, len);
nobukuma 0:003889bc474f 36 }
nobukuma 0:003889bc474f 37 void receive(int socket, SocketState state, const u8* data, int len);// {printf("ftdev::receive was called: socket %d, state=%d, length=%d\n", socket, state, len);}
nobukuma 0:003889bc474f 38 };
nobukuma 0:003889bc474f 39
nobukuma 0:003889bc474f 40 extern ftdev _ftdev;
nobukuma 0:003889bc474f 41
nobukuma 0:003889bc474f 42 unsigned InitFtBtDeviceList();
nobukuma 0:003889bc474f 43 int GetNrOfFtBtDevices();
nobukuma 0:003889bc474f 44 ftbtdev* GetFtUsbDeviceHandle(unsigned Num);
nobukuma 0:003889bc474f 45 unsigned OpenFtBtDevice(ftbtdev* d);
nobukuma 0:003889bc474f 46
nobukuma 0:003889bc474f 47 #endif