Yonariel Hernandez
/
Proyecto-Final_copy_petey
kio
README.md@2:4745484bc533, 2021-08-05 (annotated)
- Committer:
- yonaetworks
- Date:
- Thu Aug 05 01:28:42 2021 +0000
- Revision:
- 2:4745484bc533
- Parent:
- 0:29132844de96
funciona URL post/get desde MBEDOS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yonaetworks | 0:29132844de96 | 1 | # HTTP/HTTPS example for Mbed OS 5 |
yonaetworks | 0:29132844de96 | 2 | |
yonaetworks | 0:29132844de96 | 3 | This application demonstrates how to make HTTP and HTTPS requests and parse the response from Mbed OS 5. |
yonaetworks | 0:29132844de96 | 4 | |
yonaetworks | 0:29132844de96 | 5 | It consists of six demo's, which you can select in ``source/select-demo.h``. |
yonaetworks | 0:29132844de96 | 6 | |
yonaetworks | 0:29132844de96 | 7 | * HTTP demo: |
yonaetworks | 0:29132844de96 | 8 | * Does a GET request to http://httpbin.org/status/418. |
yonaetworks | 0:29132844de96 | 9 | * Does a POST request to http://httpbin.org/post. |
yonaetworks | 0:29132844de96 | 10 | * HTTPS demo: |
yonaetworks | 0:29132844de96 | 11 | * Does a GET request to https://os.mbed.com/media/uploads/mbed_official/hello.txt. |
yonaetworks | 0:29132844de96 | 12 | * Does a POST request to https://httpbin.org/post. |
yonaetworks | 0:29132844de96 | 13 | * HTTP demo with socket re-use. |
yonaetworks | 0:29132844de96 | 14 | * HTTPS demo with socket re-use. |
yonaetworks | 0:29132844de96 | 15 | * HTTP demo over IPv6. |
yonaetworks | 0:29132844de96 | 16 | * HTTPS demo with chunked requests. |
yonaetworks | 0:29132844de96 | 17 | |
yonaetworks | 0:29132844de96 | 18 | Response parsing is done through [nodejs/http-parser](https://github.com/nodejs/http-parser). |
yonaetworks | 0:29132844de96 | 19 | |
yonaetworks | 0:29132844de96 | 20 | **Note:** HTTPS requests do not work on targets with less than 128K of RAM due to the size of the TLS handshake. For more background see [mbed-http](https://developer.mbed.org/teams/sandbox/code/mbed-http). |
yonaetworks | 0:29132844de96 | 21 | |
yonaetworks | 0:29132844de96 | 22 | ## To build |
yonaetworks | 0:29132844de96 | 23 | |
yonaetworks | 0:29132844de96 | 24 | 1. If you're using WiFi, specify the credentials in `mbed_app.json`. |
yonaetworks | 0:29132844de96 | 25 | 1. Build the project in the online compiler or using Mbed CLI. |
yonaetworks | 0:29132844de96 | 26 | 1. Flash the project to your development board. |
yonaetworks | 0:29132844de96 | 27 | 1. Attach a serial monitor to your board to see the debug messages. |
yonaetworks | 0:29132844de96 | 28 | |
yonaetworks | 0:29132844de96 | 29 | ## Defining the network interface |
yonaetworks | 0:29132844de96 | 30 | |
yonaetworks | 0:29132844de96 | 31 | This application uses the on-board network interface for your board. If you use an external network interface (f.e. a WiFi module) you need to add the driver to this project. Then, open `network-helper.h` and specify which network driver to use. |
yonaetworks | 0:29132844de96 | 32 | |
yonaetworks | 0:29132844de96 | 33 | More information is in the Mbed OS documentation under [IP Networking](https://os.mbed.com/docs/latest/reference/ip-networking.html). |
yonaetworks | 0:29132844de96 | 34 | |
yonaetworks | 0:29132844de96 | 35 | ## Entropy (or lack thereof) |
yonaetworks | 0:29132844de96 | 36 | |
yonaetworks | 0:29132844de96 | 37 | On all platforms that do not have the `TRNG` feature, the application is compiled without TLS entropy sources. This means that your code is inherently unsafe and should not be deployed to any production systems. To enable entropy, remove the `MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES` and `MBEDTLS_TEST_NULL_ENTROPY` macros from mbed_app.json. |
yonaetworks | 0:29132844de96 | 38 | |
yonaetworks | 0:29132844de96 | 39 | ## Flash size |
yonaetworks | 0:29132844de96 | 40 | |
yonaetworks | 0:29132844de96 | 41 | Default flash size for HTTPS is very large, as the application is loading the default Mbed TLS configuration. To use a more optimized version, you can disable unused cypher suites and other Mbed TLS features with a custom configuration file. Create a new configuration file, then add in `mbed_app.json`: |
yonaetworks | 0:29132844de96 | 42 | |
yonaetworks | 0:29132844de96 | 43 | ``` |
yonaetworks | 0:29132844de96 | 44 | "MBEDTLS_CONFIG_FILE=\"mbedtls_config.h\"" |
yonaetworks | 0:29132844de96 | 45 | ``` |
yonaetworks | 0:29132844de96 | 46 | |
yonaetworks | 0:29132844de96 | 47 | to the `macros` array. |
yonaetworks | 0:29132844de96 | 48 | |
yonaetworks | 0:29132844de96 | 49 | ## Running tests |
yonaetworks | 0:29132844de96 | 50 | |
yonaetworks | 0:29132844de96 | 51 | You can run the integration tests from this project via Mbed CLI. |
yonaetworks | 0:29132844de96 | 52 | |
yonaetworks | 0:29132844de96 | 53 | 1. In `select-demo.h` set the `DEMO` macro to `DEMO_TESTS`. |
yonaetworks | 0:29132844de96 | 54 | 1. Set your WiFi credentials in `mbed_app.json`. |
yonaetworks | 0:29132844de96 | 55 | 1. Then run the tests via: |
yonaetworks | 0:29132844de96 | 56 | |
yonaetworks | 0:29132844de96 | 57 | ``` |
yonaetworks | 0:29132844de96 | 58 | $ mbed test -v -n mbed-http-tests-tests-* |
yonaetworks | 0:29132844de96 | 59 | ``` |
yonaetworks | 0:29132844de96 | 60 | |
yonaetworks | 0:29132844de96 | 61 | ## Tested on |
yonaetworks | 0:29132844de96 | 62 | |
yonaetworks | 0:29132844de96 | 63 | * K64F with Ethernet. |
yonaetworks | 0:29132844de96 | 64 | * NUCLEO_F411RE with ESP8266. |
yonaetworks | 0:29132844de96 | 65 | * ODIN-W2 with WiFi. |
yonaetworks | 0:29132844de96 | 66 | * K64F with Atmel 6LoWPAN shield. |
yonaetworks | 0:29132844de96 | 67 | * DISCO-L475VG-IOT01A with WiFi (requires the [wifi-ism43362](https://github.com/ARMmbed/wifi-ism43362/) driver). |
yonaetworks | 0:29132844de96 | 68 | * [Mbed Simulator](https://github.com/janjongboom/mbed-simulator). |