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
source/network-helper.h@30:4825e4f38844, 2018-10-29 (annotated)
- Committer:
- Jan Jongboom
- Date:
- Mon Oct 29 14:34:43 2018 +0800
- Branch:
- mbed-os-5.10
- Revision:
- 30:4825e4f38844
- Child:
- 31:66704f6f17c5
Update to Mbed OS 5.10, with default network interface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jan Jongboom |
30:4825e4f38844 | 1 | #ifndef _MBED_HTTP_EXAMPLE_H_ |
Jan Jongboom |
30:4825e4f38844 | 2 | #define _MBED_HTTP_EXAMPLE_H_ |
Jan Jongboom |
30:4825e4f38844 | 3 | |
Jan Jongboom |
30:4825e4f38844 | 4 | #include "mbed.h" |
Jan Jongboom |
30:4825e4f38844 | 5 | |
Jan Jongboom |
30:4825e4f38844 | 6 | /** |
Jan Jongboom |
30:4825e4f38844 | 7 | * Connect to the network using the default networking interface, |
Jan Jongboom |
30:4825e4f38844 | 8 | * you can also swap this out with a driver for a different networking interface |
Jan Jongboom |
30:4825e4f38844 | 9 | * if you use WiFi: see mbed_app.json for the credentials |
Jan Jongboom |
30:4825e4f38844 | 10 | */ |
Jan Jongboom |
30:4825e4f38844 | 11 | NetworkInterface *connect_to_default_network_interface() { |
Jan Jongboom |
30:4825e4f38844 | 12 | printf("[NWKH] Connecting to network...\n"); |
Jan Jongboom |
30:4825e4f38844 | 13 | |
Jan Jongboom |
30:4825e4f38844 | 14 | NetworkInterface* network = NetworkInterface::get_default_instance(); |
Jan Jongboom |
30:4825e4f38844 | 15 | |
Jan Jongboom |
30:4825e4f38844 | 16 | nsapi_error_t connect_status = network->connect(); |
Jan Jongboom |
30:4825e4f38844 | 17 | |
Jan Jongboom |
30:4825e4f38844 | 18 | if (connect_status != NSAPI_ERROR_OK) { |
Jan Jongboom |
30:4825e4f38844 | 19 | printf("[NWKH] Failed to connect to network (%d)\n", connect_status); |
Jan Jongboom |
30:4825e4f38844 | 20 | return NULL; |
Jan Jongboom |
30:4825e4f38844 | 21 | } |
Jan Jongboom |
30:4825e4f38844 | 22 | |
Jan Jongboom |
30:4825e4f38844 | 23 | printf("[NWKH] Connected to the network\n"); |
Jan Jongboom |
30:4825e4f38844 | 24 | printf("[NWKH] IP address: %s\n", network->get_ip_address()); |
Jan Jongboom |
30:4825e4f38844 | 25 | return network; |
Jan Jongboom |
30:4825e4f38844 | 26 | } |
Jan Jongboom |
30:4825e4f38844 | 27 | |
Jan Jongboom |
30:4825e4f38844 | 28 | #endif // _MBED_HTTP_EXAMPLE_H_ |