A http client sample program.

Dependencies:   NyFileSystems libMiMic mbed-rtos mbed

Fork of TcpSocketClientSamlpe by Ryo Iizuka

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Tue Sep 15 09:28:25 2015 +0000
Parent:
27:c5900bcee344
Commit message:
update libMiMic

Changed in this revision

NyFileSystems.lib Show annotated file Show diff for this revision Revisions of this file
NySDFileSystem.lib Show diff for this revision Revisions of this file
libMiMic.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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r c5900bcee344 -r dd350a9a5221 NyFileSystems.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NyFileSystems.lib	Tue Sep 15 09:28:25 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/nyatla/code/NyFileSystems/#509d2ac0ba4f
diff -r c5900bcee344 -r dd350a9a5221 NySDFileSystem.lib
--- a/NySDFileSystem.lib	Wed Oct 23 04:53:25 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/nyatla/code/NySDFileSystem/#22ce3449b224
diff -r c5900bcee344 -r dd350a9a5221 libMiMic.lib
--- a/libMiMic.lib	Wed Oct 23 04:53:25 2013 +0000
+++ b/libMiMic.lib	Tue Sep 15 09:28:25 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/nyatla/code/libMiMic/#258e84040262
+http://mbed.org/users/nyatla/code/libMiMic/#e40058804062
diff -r c5900bcee344 -r dd350a9a5221 main.cpp
--- a/main.cpp	Wed Oct 23 04:53:25 2013 +0000
+++ b/main.cpp	Tue Sep 15 09:28:25 2015 +0000
@@ -13,18 +13,18 @@
 #include "fsdata.h"
 
 LocalFileSystem2 lf("local");
-NetConfig cfg; //create network configulation
-Net* net;
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 DigitalOut led4(LED4);
 
+    MiMicNetIf netif;
+    NetConfig cfg; //create network configulation  with onchip-setting.
 
 int main()
 {
-    net=new Net();//Net constructor must be created after started RTOS
+    Net net(netif);//Net constructor must be created after started RTOS
 
     // manual setting
     cfg.setIpAddr(192,168,128,39);
@@ -36,11 +36,12 @@
     // Create http client.
     // Socket must create between "net.start" with "new Net()"
     HttpClient http;
+led1=1;
     
     //Start network
-    net->start(cfg);
-
-    if(http.connect(IpAddr(192,168,128,195),80)){
+    net.start(cfg);
+led2=2;
+    if(http.connect(IpAddr(192,168,128,1),80)){
         if(http.sendMethod(HttpClient::HTTP_GET,"/mimic/")){            
             FILE *fp=fopen("/local/out.txt", "w");
             if(fp!=NULL){            
@@ -72,6 +73,21 @@
         }
         http.close();
     }
+    if(http.connect(IpAddr(192,168,128,254),80)){
+        if(http.sendMethod(HttpClient::HTTP_POST,"/mimic/")){
+            const char* DATA="{json}";
+            if(http.write(DATA,strlen(DATA))){
+                if(http.getStatus()==200){
+                    char buf[256];
+                    short len;
+                    if(http.read(buf,256,len)){
+                        printf("%.*s",len,buf);
+                    }
+                }
+            }
+        }
+        http.close();
+    }    
     for(int c=0;;c=(c+1)%2){
         led4=c;
         Thread::wait(500);
diff -r c5900bcee344 -r dd350a9a5221 mbed-rtos.lib
--- a/mbed-rtos.lib	Wed Oct 23 04:53:25 2013 +0000
+++ b/mbed-rtos.lib	Tue Sep 15 09:28:25 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782
+http://mbed.org/users/mbed_official/code/mbed-rtos/#21b438192b0f
diff -r c5900bcee344 -r dd350a9a5221 mbed.bld
--- a/mbed.bld	Wed Oct 23 04:53:25 2013 +0000
+++ b/mbed.bld	Tue Sep 15 09:28:25 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file