XBee API operation library for mbed for miniprojects

Dependencies:   SmartLabXBeeCore

Fork of SmartLabXBeeAPI2 by CHENGQI YANG

Revision:
0:415f4b1b988e
Child:
2:723cccd7659a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialData.cpp	Thu Oct 22 12:32:36 2015 +0000
@@ -0,0 +1,44 @@
+#include "SerialData.h"
+
+SerialData::SerialData(PinName tx, PinName rx)
+{
+    serialPort = new Serial(tx, rx);
+    serialPort->baud(9600);
+}
+
+SerialData::SerialData(PinName tx, PinName rx, int baudRate)
+{
+    serialPort = new Serial(tx, rx);
+    serialPort->baud(baudRate);
+}
+
+SerialData::~SerialData()
+{
+    if (serialPort != NULL)
+        delete serialPort;
+}
+
+int SerialData::readByte()
+{
+    if (serialPort->readable())
+        return serialPort->getc();
+    else return -1;
+}
+
+void SerialData::writeByte(char data)
+{
+    serialPort->putc(data);
+}
+
+bool SerialData::isOpen()
+{
+    if (serialPort->readable())
+        return true;
+    else return false;
+}
+
+void SerialData::open()
+{}
+
+void SerialData::close()
+{}
\ No newline at end of file