Programm erwartet auf der seriellen Schnittstelle eine Eingabe, die es an den IntrospectionEP des Servers schickt und bei erfolgreicher Überprüfung (Status=200) das Schloss öffnet.
Dependencies: EthernetInterface HTTPClient mbed-dev mbed-rtos wolfSSL MODSERIAL
Diff: main.cpp
- Revision:
- 4:00b8d595aa33
- Parent:
- 3:e91a03086c72
- Child:
- 5:a837161f959a
--- a/main.cpp Thu Jun 23 20:58:07 2016 +0000 +++ b/main.cpp Thu Jun 23 21:07:49 2016 +0000 @@ -14,9 +14,8 @@ int main() { setbuf(stdout, NULL); - eth.init(); //Use DHCP + eth.init(); eth.connect(); - http.dumpResHeader(true); R=!R;G=!G;B=!B; wait(1); @@ -24,7 +23,6 @@ // Wait for Token on Serial and read to str // Light Blue B=!B; - printf("Erwarte Eingabe: "); while(1){ if(serial.readable()){ serial.scanf("%s",&str); @@ -33,34 +31,26 @@ } // Token Read, light Yellow R=!R;G=!G;B=!B; - printf(str); + //printf(str); // Send token to Server - // POST date, more examples on https://developer.mbed.org/users/donatien/code/HTTPClient_HelloWorld/file/270e2d0bb85a/main.cpp - printf("\nTrying to post data...\n"); HTTPMap map; HTTPText inText(str2, 32000); map.put("client_id", "a1b2c3"); map.put("client_secret", "drickyoughurt"); - map.put("token_type_hint", "pop_token"); //Sptäer durch pop ersetzen!! + map.put("token_type_hint", "pop_token"); map.put("token", str); - //int ret = http.post("http://requestb.in/14qajp81", map, &inText); int ret = http.post("https://kongsugar.de/introspection", map, &inText); if (!ret) { - printf("Page fetched successfully - read %d characters\n", strlen(str2)); - printf("Result: %s\n", str2); // Unlock, Light Green 5s R=!R;wait(5);G=!G; } else { - printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); // Light Red 5s G=!G;wait(5);R=!R; } } - - eth.disconnect(); }