This library controls the WNC. There is a derived class for usage from the K64F board.

Fork of WncControllerLibrary by Fred Kellerman

Files at this revision

API Documentation at this revision

Comitter:
fkellermavnet
Date:
Thu Sep 01 22:28:10 2016 +0000
Parent:
1:ac2de545b981
Child:
3:b7b3d2c554e5
Commit message:
Added a new method to K64F library to allow one to type in the debug serial port and send and receive commands to the WNC.

Changed in this revision

WncController.h Show annotated file Show diff for this revision Revisions of this file
WncControllerK64F.cpp Show annotated file Show diff for this revision Revisions of this file
WncControllerK64F.h Show annotated file Show diff for this revision Revisions of this file
--- a/WncController.h	Thu Sep 01 02:28:10 2016 +0000
+++ b/WncController.h	Thu Sep 01 22:28:10 2016 +0000
@@ -330,14 +330,14 @@
     virtual int  getTimerTicksB_mS(void) = 0;
         
     bool waitForPowerOnModemToRespond(uint8_t powerUpTimeoutSecs);    
-
+    AtCmdErr_e sendWncCmd(const char * const s, string ** r, int ms_timeout);
+    
 private:
 
     bool softwareInitMdm(void);
     bool checkCellLink(void);
     AtCmdErr_e mdmSendAtCmdRsp(const char * cmd, int timeout_ms, string * rsp, bool crLf = true);
     size_t mdmGetline(string * buff, int timeout_ms);
-    AtCmdErr_e sendWncCmd(const char * const s, string ** r, int ms_timeout);
     bool at_at_wnc(void);
     bool at_init_wnc(bool hardReset = false);
     bool at_sockopen_wnc(const char * const ip, uint16_t port, uint16_t numSock, bool tcp, uint16_t timeOutSec);
--- 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));
--- a/WncControllerK64F.h	Thu Sep 01 02:28:10 2016 +0000
+++ b/WncControllerK64F.h	Thu Sep 01 22:28:10 2016 +0000
@@ -71,6 +71,22 @@
      */
     WncControllerK64F(struct WncGpioPinListK64F * pPins, MODSERIAL * wnc_uart, MODSERIAL * debug_uart = NULL);
     
+    /**
+     *  \brief Activates a mode where the user can send text to and from the K64F
+     *  debug Serial port directly to the WNC.
+     *
+     *  \param [in] echoOn - set to true to enable terminal echo
+     *
+     *  \return true - if terminal mode was successfully entered and exited.
+     *
+     *  \details Activates a mode where the user can send text to and from the K64F
+     *  debug Serial port directly to the WNC.  The mode is entered via this
+     *  call.  The mode is exited when the user types CTRL-Q.  While in this
+     *  mode all text to and from the WNC is consumed by the debug Serial port.
+     *  No other methods in the class will receive any of the WNC output.
+     */
+    bool enterWncTerminalMode(bool echoOn);
+    
 private:
 
     // Disallow copy