Skip to content

Commit f55b276

Browse files
committed
MCU8MASS-1828 Fix bug where appending to the transmit buffer would exit before the timeout
1 parent 21f83c1 commit f55b276

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/provision/provision.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static bool readUntilNewLine(char* output_buffer,
327327

328328
uint8_t input = SerialModule.read();
329329

330-
if (input == ASCII_SPACE) {
330+
if (input == ASCII_SPACE && index == 0) {
331331
continue;
332332
}
333333

@@ -561,8 +561,9 @@ static bool requestAndSaveToNonVolatileMemory(const char* message,
561561

562562
SequansController.writeBytes((uint8_t*)command, strlen(command), true);
563563

564-
SequansController.waitForByte('>', 1000);
565-
SequansController.writeBytes((uint8_t*)data, data_length, true);
564+
if (SequansController.waitForByte('>', 1000)) {
565+
SequansController.writeBytes((uint8_t*)data, data_length, true);
566+
}
566567

567568
if (SequansController.readResponse() != ResponseResult::OK) {
568569
SerialModule.println(
@@ -1394,6 +1395,7 @@ void provisionHttp() {
13941395
// --------------------------------------------------------------------
13951396

13961397
SerialModule.println();
1398+
13971399
SerialModule.print("--- Provisioning...");
13981400

13991401
char command[strlen(AT_HTTPS_SECURITY_PROFILE) + 64] = "";

src/sequans_controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,13 +587,13 @@ bool SequansControllerClass::appendDataToTransmitBuffer(const uint8_t data) {
587587
_delay_ms(1);
588588
}
589589

590-
if (!(VPORTC.IN & CTS_PIN_bm)) {
590+
if (!(VPORTC.IN & CTS_PIN_bm) && !timeout_timer.hasTimedOut()) {
591591
// Enable data register empty interrupt so that the data gets
592592
// pushed out. We do this in the loop as the CTS interrupt might
593593
// disable the interrupt logic, so we wait until that is not the
594594
// case and then start the transmit logic
595595
HWSERIALAT.CTRLA |= USART_DREIE_bm;
596-
} else {
596+
} else if (timeout_timer.hasTimedOut()) {
597597
// If we time out and the modem still can't accept the data, we
598598
// just return
599599
return false;

0 commit comments

Comments
 (0)