Avnet / WncControllerLibrary

Fork of WncControllerLibrary by Fred Kellerman

Revision:
2:30d78cda6779
Parent:
1:ac2de545b981
--- a/WncControllerK64F.cpp	Thu Sep 01 02:28:10 2016 +0000
+++ b/WncControllerK64F.cpp	Thu Sep 01 22:28:10 2016 +0000
@@ -38,6 +38,36 @@
     m_gpioPinList = *pPins;
 }
 
+bool WncControllerK64F::enterWncTerminalMode(bool echoOn)
+{
+    string * resp;
+    AtCmdErr_e r = sendWncCmd("AT", &resp, 500);
+    if (r == WNC_AT_CMD_TIMEOUT)
+        return (false);
+    
+    m_pDbgUart->puts("\r\nEntering WNC Terminal Mode - press <CTRL>-Q to exit!\r\n");
+    
+    while (1) {
+        if (m_pDbgUart->readable()) {
+            char c = m_pDbgUart->getc();
+            if (c == '\x11') {
+                m_pDbgUart->puts("\r\nExiting WNC Terminal Mode!\r\n");
+                // Cleanup in case user doesn't finish command:
+                sendWncCmd("AT", &resp, 300);
+                // Above AT may fail but should get WNC back in sync
+                return (sendWncCmd("AT", &resp, 500) == WNC_AT_CMD_OK);
+            }
+            if (echoOn == true) {
+                m_pDbgUart->putc(c);
+            }
+            m_pWncUart->putc(c);
+        }
+        if (m_pWncUart->readable())
+            m_pDbgUart->putc(m_pWncUart->getc());
+    }
+}
+
+
 int WncControllerK64F::putc(char c)
 {
     return (m_pWncUart->putc(c));