shinichi satoh / Mbed 2 deprecated http_access

Dependencies:   CyaSSL EthernetInterface mbed-rtos mbed

Fork of SimpleTCPClient by wolf SSL

Files at this revision

API Documentation at this revision

Comitter:
wolfSSL
Date:
Mon Dec 08 05:10:41 2014 +0000
Parent:
1:ac91b4f8d818
Child:
3:7f54a8739701
Commit message:
Cleaned for the workshop

Changed in this revision

CyaSSL.lib Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.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
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CyaSSL.lib	Mon Dec 08 05:10:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/wolfSSL/code/CyaSSL/#64d4f7cb83d5
--- a/EthernetInterface.lib	Wed Oct 08 05:04:36 2014 +0000
+++ b/EthernetInterface.lib	Mon Dec 08 05:10:41 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#e6b79f0ccd95
+http://mbed.org/users/mbed_official/code/EthernetInterface/#30d93e43335d
--- a/main.cpp	Wed Oct 08 05:04:36 2014 +0000
+++ b/main.cpp	Mon Dec 08 05:10:41 2014 +0000
@@ -3,9 +3,9 @@
 
 /*** SSL #include <cyassl/ssl.h> ***/
 
-const int PORT = 80 /*** SSL 443 end SSL ***/ ;
+#define PORT 80 /*** SSL 443 ***/ 
 
-#define err_sys(m) { puts(m) ; }
+#define err_sys(m) puts(m)
 
 TCPSocketConnection socket;
 
@@ -33,21 +33,32 @@
     } else  printf("SocketSend:%d/%d\n", n, sz);
     return n ;
 }
-end SSL ***/
+***/
 
 EthernetInterface eth;
 
-void net_main(void const *av)
+main()
 {
     char server_ip[20] ;
+
+    eth.init(); //Use DHCP
+    printf("===== Simple TCP Client ========\n") ;
+    /*** SSL
+    printf("===== Simple SSL Client ========\n") ;
+    ***/
+    
+    while(1) {
+        if(eth.connect()== 0)break ;
+        wait(0.1);
+    }
+    printf("Client IP: %s\n", eth.getIPAddress());
+
     /*** SSL
     CYASSL_CTX*     ctx     = 0;
     CYASSL*         ssl     = 0;
 
     CYASSL_METHOD* method = CyaTLSv1_2_client_method();
-    end SSL ***/
-
-
+    ***/
 
     /* Initialize CyaSSL Context */
     /*** SSL
@@ -61,9 +72,14 @@
 
     socket.set_blocking(false, 300) ;
     printf("Server IP: ") ;
-    scanf("%s", server_ip) ; 
-    puts(server_ip) ;
-
+    for(int i=0; i<sizeof(server_ip); i++) {
+        if((server_ip[i] = getchar()) == '\r') {
+            server_ip[i] = '\0' ;
+            putchar('\n') ;
+            break ;
+        } else putchar(server_ip[i]) ;
+    }
+    
     while (socket.connect(server_ip, PORT) < 0) {
         printf("Unable to connect to (%s) on port (%d)\n", server_ip, PORT);
         wait(1);
@@ -86,7 +102,9 @@
     char msg[] = "GET / HTTP/1.0\r\nConnection: Close\r\n\r\n" ;
     // const char msg[] = "Hello World\r\n" ;
 
-    if (/*** SSL   CyaSSL_write(ssl, end SSL***/
+    if (
+        /*** SSL   
+        CyaSSL_write(ssl, msg, sizeof(msg)-1) != (sizeof(msg)-1)) ***/
         socket.send(msg, sizeof(msg)-1) != (sizeof(msg)-1))
         err_sys("CyaSSL_write failed");
 
@@ -94,12 +112,10 @@
     int n ;
     puts("Server Response:\n") ;
     do {
-        n = /*** SSL  CyaSSL_read(ssl, end SSL ***/
+        n = /*** SSL  CyaSSL_read(ssl, buf, sizeof(buf)-1); ***/
             socket.receive(buf, sizeof(buf)-1);
         if (n >= 0) {
-
             buf[n] = 0;
-            //printf("%d,", n) ;
             printf("%s", buf);
         } else
             err_sys("CyaSSL_read failed");
@@ -110,22 +126,3 @@
     /*** SSL    CyaSSL_CTX_free(ctx) ; ***/
     eth.disconnect();
 }
-
-
-main()
-{
-
-    printf("===== Simple TCP Client ========\n") ;
-    /* CyaSSL_Debugging_ON() ; */
-
-    eth.init(); //Use DHCP
-    eth.connect();
-    printf("Client IP: %s\n", eth.getIPAddress());
-
-#define STACK_SIZE 12000
-    Thread t(net_main, NULL, osPriorityNormal, STACK_SIZE);
-
-    while (true) {
-        Thread::wait(1000);
-    }
-}
\ No newline at end of file
--- a/mbed-rtos.lib	Wed Oct 08 05:04:36 2014 +0000
+++ b/mbed-rtos.lib	Mon Dec 08 05:10:41 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#478a48c29e88
+http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
--- a/mbed-src.lib	Wed Oct 08 05:04:36 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#20b371a9491b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 08 05:10:41 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file