Get basic debug info from the WNC M14A21.

Dependencies:   JSON M2XStreamClient-JMF WNCInterface mbed-rtos mbed

Fork of WNCInterface_HTTP_example by Avnet

Files at this revision

API Documentation at this revision

Comitter:
rfinn
Date:
Sat Nov 19 16:44:33 2016 +0000
Parent:
5:2656c2764b62
Commit message:
initial

Changed in this revision

WNCInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2656c2764b62 -r 5467db9f2674 WNCInterface.lib
--- a/WNCInterface.lib	Thu Nov 17 18:37:59 2016 +0000
+++ b/WNCInterface.lib	Sat Nov 19 16:44:33 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Avnet/code/WNCInterface/#fded23f50479
+https://developer.mbed.org/teams/Avnet/code/WNCInterface/#6bc40ac8b054
diff -r 2656c2764b62 -r 5467db9f2674 main.cpp
--- a/main.cpp	Thu Nov 17 18:37:59 2016 +0000
+++ b/main.cpp	Sat Nov 19 16:44:33 2016 +0000
@@ -25,30 +25,29 @@
 #include "mbed.h"
 #include "WNCInterface.h"
 
-#include "Socket/Socket.h"
-#include "Socket/TCPSocketConnection.h"
-#include "Socket/UDPSocket.h"
-
 #define DEBUG
 #define MBED_PLATFORM
 #include "HTTPClient.h"
 
+#define DELAY_INTERVAL 10000
+
 #define CRLF    "\n\r"
 
 #define ntohl(n)    ((n & 0xff) << 24) |\
                     ((n & 0xff00) << 8) |\
                     ((n & 0xff0000UL) >> 8) |\
                     ((n & 0xff000000UL) >> 24)
-    
+
 int main() {
     int ret;
     WNCInterface wnc;
     MODSERIAL pc(USBTX,USBRX,256,256);
     
     pc.baud(115200);
-    pc.printf("STARTING WNCInterface & Socket Test" CRLF);
+    pc.printf("STARTING WNCInterface Info" CRLF);
     
-    ret = wnc.init();                     
+    wnc.doDebug(3); 
+    ret = wnc.init();
     pc.printf("WNC Module %s initialized (%02X)." CRLF, ret?"IS":"IS NOT", ret);
     if( !ret ) {
         printf(" - - - - - - - ALL DONE - - - - - - - " CRLF);
@@ -57,148 +56,10 @@
         
     ret = wnc.connect();                 
     printf("IP Address: %s " CRLF CRLF, wnc.getIPAddress());
-//
-//demonstrate a TCP connection
-//
-    TCPSocketConnection tsock;
-    printf("\n\n\n\n------------------------------------" CRLF "starting TCP Socket Test..." CRLF);
 
-    tsock.connect("mbed.org", 80);
-    printf("Connected!" CRLF );
-    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
-    ret=tsock.send_all(http_cmd, sizeof(http_cmd)-1);
-    printf("TCP Socket sent %d bytes.\r\n",ret);    
-    char buffer[1500];
-
-    tsock.set_blocking (false, 1000);    
-    while (ret>0) {
-        ret = tsock.receive(buffer, sizeof(buffer)-1);
-        buffer[ret] = '\0';
-        if( ret > 0 )
-            printf("Received %d chars from server:" CRLF "<----->" CRLF "%s" CRLF 
-                   "<----->" CRLF, ret, buffer);
-    }
-    tsock.close();      
-
-//
-//demonstrate a UDP connection
-//
-    printf("\n\n\n\n-------------------------------------" CRLF);
-    printf(        "starting UDP Socket Test..." CRLF);
-
-//#define UDP_URL "utcnist.colorado.edu"
-//#define UDP_PORT 37
-#define UDP_URL "pool.ntp.org"
-#define UDP_PORT 123
-
-    UDPSocket usock;
-    usock.init();
-    Endpoint nist;
-
-    nist.set_address(UDP_URL, UDP_PORT);
-    printf("Endpoing set to '%s'/%s/%d, try sending data." CRLF,
-        UDP_URL, nist.get_address(), nist.get_port());
-    
-//    char out_buffer[] = "plop"; // Does not matter
-
-  char out_buffer[48];
-    out_buffer[0] = 0xE3;         // LI, Version, Mode
-    out_buffer[1] = 0;            // Stratum, or type of clock
-    out_buffer[2] = 6;            // Polling Interval
-    out_buffer[3] = 0xEC;         // Peer Clock Precision
-    // 8 bytes of zero for Root Delay & Root Dispersion
-    out_buffer[12]  = 49;
-    out_buffer[13]  = 0x4E;
-    out_buffer[14]  = 49;
-    out_buffer[15]  = 52;
-
-    ret = usock.sendTo(nist, out_buffer, sizeof(out_buffer));
-    printf("sent buffer to UDP IP/Port (ret=%d)" CRLF "Now try receiving." CRLF,ret);
-
-
-    usock.set_blocking (false, 1000);    
-    char in_buffer[50];
-    int n = usock.receiveFrom(nist, in_buffer, sizeof(in_buffer));
-    
-    printf("Received %d bytes via UDP IP address %s on port %d." CRLF, 
-            n, nist.get_address(), nist.get_port());
     
-    usock.close();
-
-//
-//demonstrate HTTPClient operations
-//
-    HTTPClient http;
-    char str[512];
-
-    printf("\n\n\n\n-------------------------------------" CRLF);
-    printf(        "starting HTTPClient Socket Test..." CRLF);
-
-    //GET data
-    printf(">>>>Fetch a page..." CRLF);
-
-    ret = http.get("http://developer.mbed.org/media/uploads/mbed_official/hello.txt", str, strlen(str));
-    if (!ret)
-    {
-      printf("Page fetched successfully - read %d characters" CRLF, strlen(str));
-      printf("<----->" CRLF "Result: %s" CRLF "<----->" CRLF, str); 
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d" CRLF, ret, http.getHTTPResponseCode());
-    }
-
-    //POST data
-    HTTPMap map;
-    HTTPText inText(str, 512);
-    map.put("Hello", "World");
-    map.put("test", "1234");
-
-    printf(CRLF CRLF ">>>>Post data..." CRLF);
-    ret = http.post("http://httpbin.org/post", map, &inText);
-    if (!ret)
-    {
-      printf("Executed POST successfully - read %d characters" CRLF, strlen(str));
-      printf("<----->" CRLF );
-      printf("Result: %s" CRLF "<----->" CRLF, str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d" CRLF, ret, http.getHTTPResponseCode());
-    }
-    
-    //PUT data
-    strcpy(str, "This is a PUT test!");
-    HTTPText outText(str);
-    printf(CRLF CRLF ">>>>Put data..." CRLF);
-    ret = http.put("http://httpbin.org/put", outText, &inText);
-    if (!ret)
-    {
-      printf("Executed PUT successfully - read %d characters" CRLF, strlen(str));
-      printf("<----->" CRLF );
-      printf("Result: %s" CRLF "<----->" CRLF, str); 
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d" CRLF, ret, http.getHTTPResponseCode());
-    }
-    
-    //DELETE data
-    printf(CRLF CRLF ">>>>Delete data..." CRLF);
-    ret = http.del("http://httpbin.org/delete", &inText);
-    if (!ret)
-    {
-      printf("Executed DELETE successfully - read %d characters" CRLF, strlen(str));
-      printf("<----->" CRLF );
-      printf("Result: %s" CRLF "<----->" CRLF, str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d" CRLF, ret, http.getHTTPResponseCode());
-    }
 
     wnc.disconnect();
     printf(" - - - - - - - ALL DONE - - - - - - - " CRLF);
-    while(1) {}
 }