Based on myBlueUSB and rosserial_mbed
Dependencies: mbed myUSBHost AvailableMemory myBlueUSB
Diff: MbedBT.h
- Revision:
- 0:7684b95768c7
diff -r 000000000000 -r 7684b95768c7 MbedBT.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MbedBT.h Sat Sep 17 14:21:35 2011 +0000 @@ -0,0 +1,67 @@ +/* + * MbedBT + * + * 2011/09/14 by OTL + */ + +#ifndef MBEDBT_H_ +#define MBEDBT_H_ + +#include"mbed.h" +#include "btserial.h" +#include "ftclasslibusbdevbt.h" + +extern int state; + +void test_tick() { + USBLoop(); + printf("tick\n"); + } + +class MbedBT { +public: + MbedBT(){ + timer_.start(); + } + void init() { + USBInit(); + + while(state != 1) { + USBLoop(); + } + + printf("Ready to open ports!!!!!!!!!!!!!\n"); + InitFtBtDeviceList(); + int n = GetNrOfFtBtDevices(); + printf("%d ft BT devices have been found\n", n); + if (n > 0) { + ftbtdev *d = GetFtUsbDeviceHandle(0); + if (d==0) printf("could not get device handle\n"); + int sock = OpenFtBtDevice(d); + } + bluetooth_ = new btserial(1); +// bluetooth_->baud(57600); + } + + int read() { + return bluetooth_->getc(); + } + void write(uint8_t* data, int length) { + bluetooth_->write(data, length); + } + + unsigned long time() { + return timer_.read_ms(); + } + ~MbedBT() { + delete bluetooth_; +// ticker_.dettach(); + } +protected: + btserial* bluetooth_; +// Ticker ticker_; + Timer timer_; +}; + + +#endif /* MBEDBT_H_ */ \ No newline at end of file