An example project for the Heltec Turtle LoRa board (STM32L4 and SX1276 chips). The projects is only supported for the Nucleo-L432KC board platform in the mbed online and offline compiler environment. Visit www.radioshuttle.de (choose Turtle board) for instructions. Note that most source files and libraries are open source, however some files especially the RadioShuttle core protocol is copyrighted work. Check header for details.

Dependencies:   mbed BufferedSerial SX1276GenericLib OLED_SSD1306 HELIOS_Si7021 NVProperty RadioShuttle-STM32L4 USBDeviceHT

Revision:
14:d9340be18c3d
Parent:
5:c6a960febe80
Child:
16:c12c85fdfa60
--- a/utils.cpp	Thu Jan 24 16:10:28 2019 +0100
+++ b/utils.cpp	Fri Jan 25 17:16:41 2019 +0100
@@ -141,10 +141,62 @@
     }
 }
 
+char *ConsoleReadline(char *buf, int buflen, bool echo)
+{
+	int count = 0;
+	memset(buf, 0, buflen);
+	
+	if (usb ) {
+		usb->flush();
+		while(usb->readable())
+			usb->getc(); // flush old chars
+		
+		while(true) {
+			if (usb->readable()) {
+				int c = usb->getc();
+				if (c == 0 || c == -1  || c == '\r' || c == '\n' ||	c == 3 || c == 4)
+					break;
+				if (echo) {
+					rprintf("%c", c);
+					usb->flush();
+				}
+				
+				buf[count] = c;
+				if (count++ >= buflen-2)
+					break;
+				// dprintf("Got char: '%c'(%d)", c, c);
+			}
+		}
+	}
+	if (ser) {
+		while(ser->readable())
+			ser->getc(); // flush old chars
+		
+		while(true) {
+			if (ser->readable()) {
+				int c = ser->getc();
+				if (c == 0 || c == -1  || c == '\r' || c == '\n' ||	c == 3 || c == 4)
+					break;
+				if (echo)
+					rprintf("%c", c);
+				buf[count] = c;
+				if (count++ >= buflen-2)
+					break;
+				// dprintf("Got char: '%c'(%d)", c, c);
+			}
+		}
+	}
+	if (echo)
+		rprintf("\r\n");
+	if (count)
+		return buf;
+	return NULL;
+}
+
 
 void dump(const char *title, const void *data, int len, bool dwords)
 {
-    dprintf("dump(\"%s\", 0x%x, %d bytes)", title, data, len);
+    dprintf("dump(\"%s\", 0x%x, %d bytes)", title, (unsigned int)data, len);
 
     int i, j, cnt;
     unsigned char *u;