Senses an earthquake with MPU6050 and gets time, coordenates and other details of the event with an Adafruit GPS. All the info is sent to an HTTP server
Dependencies: MPU6050 mbed-http MBed_Adafruit-GPS-Library
Revision 4:27fd8efb5bab, committed 2017-02-23
- Comitter:
- Jan Jongboom
- Date:
- Thu Feb 23 12:36:59 2017 +0100
- Parent:
- 3:0f5859a9e3de
- Child:
- 5:42f713b19337
- Commit message:
- Increase MBEDTLS_MPI_MAX_SIZE so HTTPS calls to httpbin work as well
Changed in this revision
--- a/README.md Thu Feb 16 13:56:02 2017 +0100 +++ b/README.md Thu Feb 23 12:36:59 2017 +0100 @@ -5,10 +5,11 @@ It consists of two demo's, which you can select in ``source/select-demo.h``. * HTTP demo - * Does a GET request to [http://httpbin.org/status/418](http://httpbin.org/status/418). - * Does a POST request to [http://httpbin.org/post](http://httpbin.org/post). + * Does a GET request to http://httpbin.org/status/418. + * Does a POST request to http://httpbin.org/post. * HTTPS demo - * Does a GET request to [https://developer.mbed.org/media/uploads/mbed_official/hello.txt](https://developer.mbed.org/media/uploads/mbed_official/hello.txt). + * Does a GET request to https://developer.mbed.org/media/uploads/mbed_official/hello.txt. + * Does a POST request to https://httpbin.org/post. Response parsing is done through [nodejs/http-parser](https://github.com/nodejs/http-parser).
--- a/mbedtls_entropy_config.h Thu Feb 16 13:56:02 2017 +0100 +++ b/mbedtls_entropy_config.h Thu Feb 23 12:36:59 2017 +0100 @@ -39,13 +39,17 @@ #define MBEDTLS_SHA1_C #endif /* !MBEDTLS_SHA1_C */ +#if !defined(MBEDTLS_RSA_C) +#define MBEDTLS_RSA_C +#endif /* !MBEDTLS_RSA_C */ + /* * This value is sufficient for handling 2048 bit RSA keys. * * Set this value higher to enable handling larger keys, but be aware that this * will increase the stack usage. */ -#define MBEDTLS_MPI_MAX_SIZE 256 +#define MBEDTLS_MPI_MAX_SIZE 1024 #define MBEDTLS_MPI_WINDOW_SIZE 1
--- a/source/main-https.cpp Thu Feb 16 13:56:02 2017 +0100
+++ b/source/main-https.cpp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Z9c0p10a3CitlttNCbxWyuHv77+ldU9U0\n"
+ "WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD\n"
+ "VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0\n"
+ "Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU\n"
+ "cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx\n"
+ "IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN\n"
+ "AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH\n"
+ "YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5\n"
+ "6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC\n"
+ "Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX\n"
+ "c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a\n"
+ "mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=\n"
"-----END CERTIFICATE-----\n";
void dump_response(HttpResponse* res) {
@@ -53,18 +78,41 @@
return 1;
}
+ printf("\n----- HTTPS GET request -----\n");
+
// @todo: when I declare this on the stack we hard fault (run out of memory??)
- HttpsRequest* req = new HttpsRequest(network, SSL_CA_PEM, HTTP_GET, "https://developer.mbed.org/media/uploads/mbed_official/hello.txt");
- req->set_debug(true);
- HttpResponse* response = req->send();
- if (!response) {
- printf("HttpRequest failed (error code %d)\n", req->get_error());
+ HttpsRequest* get_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_GET, "https://developer.mbed.org/media/uploads/mbed_official/hello.txt");
+ get_req->set_debug(true);
+
+ HttpResponse* get_res = get_req->send();
+ if (!get_res) {
+ printf("HttpRequest failed (error code %d)\n", get_req->get_error());
return 1;
}
printf("\n----- HTTPS GET response -----\n");
- dump_response(response);
+ dump_response(get_res);
+
+ delete get_req;
+
+ // POST request to httpbin.org
+ printf("\n----- HTTPS POST request -----\n");
+
+ HttpsRequest* post_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, "https://httpbin.org/post");
+ post_req->set_debug(true);
+ post_req->set_header("Content-Type", "application/json");
- delete req;
+ const char body[] = "{\"hello\":\"world\"}";
+
+ HttpResponse* post_res = post_req->send(body, strlen(body));
+ if (!post_res) {
+ printf("HttpRequest failed (error code %d)\n", post_req->get_error());
+ return 1;
+ }
+
+ printf("\n----- HTTP POST response -----\n");
+ dump_response(post_res);
+
+ delete post_req;
Thread::wait(osWaitForever);
}
