Based on myBlueUSB and rosserial_mbed
Dependencies: mbed myUSBHost AvailableMemory myBlueUSB
MbedBT.h
- Committer:
- OTL
- Date:
- 2011-09-17
- Revision:
- 0:7684b95768c7
File content as of revision 0:7684b95768c7:
/* * 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_ */