Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CommandTerminal.cpp
- Revision:
- 6:e27eaad36a0c
- Parent:
- 4:666017851052
- Child:
- 9:ff62b20f7000
--- a/CommandTerminal/CommandTerminal.cpp Tue Aug 18 16:31:53 2015 +0000
+++ b/CommandTerminal/CommandTerminal.cpp Fri Jan 29 14:01:05 2016 -0600
@@ -207,7 +207,7 @@
else
max_send_size = mDot::MaxLengths_868[_dot->getTxDataRate()];
- DEBUG_PRINTF("Awake\r\n");
+ logDebug("Awake\r\n");
wakeup(_sleep_standby);
char ch;
@@ -226,7 +226,7 @@
if (escape_buffer.length() == 3 && escape_buffer.find(escape_sequence) == 0) {
_mode = mDot::COMMAND_MODE;
- DEBUG_PRINTF("Exit serial mode\r\n");
+ logDebug("Exit serial mode\r\n");
escape_timer.stop();
escape_buffer.clear();
write(done);
@@ -235,10 +235,16 @@
}
if (_serial_up) {
- osDelay(_dot->getWakeDelay());
+ serial_read_timer.start();
+ uint32_t timeout = _dot->getWakeDelay();
- serial_read_timer.start();
- uint16_t timeout = _dot->getWakeTimeout();
+ // wait for timeout or start of serial data
+ while (!readable() && serial_read_timer.read_ms() < timeout) {
+ osDelay(10);
+ }
+
+ serial_read_timer.reset();
+ timeout = _dot->getWakeTimeout();
while (_serial_up && serial_read_timer.read_ms() < timeout) {
while (readable() && serial_buffer.size() < max_send_size) {
serial_buffer.push_back(read());
@@ -252,19 +258,19 @@
_xbee_on_sleep = GPIO_PIN_RESET;
if (!_dot->getIsTransmitting()) {
std::vector<uint8_t> recv_buffer;
- DEBUG_PRINTF("Received serial data, sending out radio.\r\n");
+ logDebug("Received serial data, sending out radio.\r\n");
if (_dot->send(serial_buffer) != mDot::MDOT_OK)
- DEBUG_PRINTF("Send failed.\r\n");
+ logDebug("Send failed.\r\n");
if (_dot->recv(recv_buffer))
_serial.writef("%s\r\n", formatPacketData(recv_buffer, _dot->getRxOutput()).c_str());
} else {
- DEBUG_PRINTF("Radio is busy, cannot send.\r\n");
+ logDebug("Radio is busy, cannot send.\r\n");
}
serial_buffer.clear();
} else {
- DEBUG_PRINTF("No data received from serial to send.\r\n");
+ logDebug("No data received from serial to send.\r\n");
}
_serial_up = false;
}
@@ -321,7 +327,7 @@
if (_dot->getFrequencyBand() == mDot::FB_915) {
uint8_t band = ((_dot->getFrequencySubBand()) % 8) + 1;
- DEBUG_PRINTF("Join retries exhausted, switching to sub band %u\r\n", band);
+ logDebug("Join retries exhausted, switching to sub band %u\r\n", band);
_dot->setFrequencySubBand(band);
}
@@ -546,7 +552,7 @@
_dot->setVerbose(true);
write(done);
} else if (args[0] == "AT+SD") {
- DEBUG_PRINTF("Enter Serial Mode\r\n");
+ logDebug("Enter Serial Mode\r\n");
_mode = mDot::SERIAL_MODE;
} else if (args[0] == "AT+SLEEP") {
if (args.size() > 1 && (args[1] != "?")) {
