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@38:0813e461b835, 2019-08-01 (annotated)
- Committer:
- Alvaro13
- Date:
- Thu Aug 01 05:05:55 2019 +0000
- Revision:
- 38:0813e461b835
- Parent:
- 35:4b847971db1b
program reseted
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 |
35:4b847971db1b | 5 | #include "NetworkInterface.h" |
Jan Jongboom |
30:4825e4f38844 | 6 | |
Jan Jongboom |
30:4825e4f38844 | 7 | /** |
Jan Jongboom |
30:4825e4f38844 | 8 | * Connect to the network using the default networking interface, |
Jan Jongboom |
30:4825e4f38844 | 9 | * you can also swap this out with a driver for a different networking interface |
Jan Jongboom |
30:4825e4f38844 | 10 | * if you use WiFi: see mbed_app.json for the credentials |
Jan Jongboom |
30:4825e4f38844 | 11 | */ |
Jan Jongboom |
30:4825e4f38844 | 12 | NetworkInterface *connect_to_default_network_interface() { |
Jan Jongboom |
30:4825e4f38844 | 13 | printf("[NWKH] Connecting to network...\n"); |
Jan Jongboom |
30:4825e4f38844 | 14 | |
Jan Jongboom |
30:4825e4f38844 | 15 | NetworkInterface* network = NetworkInterface::get_default_instance(); |
Jan Jongboom |
35:4b847971db1b | 16 | |
Jan Jongboom |
35:4b847971db1b | 17 | if (!network) { |
Jan Jongboom |
35:4b847971db1b | 18 | printf("[NWKH] No network interface found, select an interface in 'network-helper.h'\n"); |
Jan Jongboom |
35:4b847971db1b | 19 | return NULL; |
Jan Jongboom |
35:4b847971db1b | 20 | } |
Jan Jongboom |
30:4825e4f38844 | 21 | |
Jan Jongboom |
30:4825e4f38844 | 22 | nsapi_error_t connect_status = network->connect(); |
Jan Jongboom |
30:4825e4f38844 | 23 | |
Jan Jongboom |
30:4825e4f38844 | 24 | if (connect_status != NSAPI_ERROR_OK) { |
Jan Jongboom |
30:4825e4f38844 | 25 | printf("[NWKH] Failed to connect to network (%d)\n", connect_status); |
Jan Jongboom |
30:4825e4f38844 | 26 | return NULL; |
Jan Jongboom |
30:4825e4f38844 | 27 | } |
Jan Jongboom |
30:4825e4f38844 | 28 | |
Jan Jongboom |
30:4825e4f38844 | 29 | printf("[NWKH] Connected to the network\n"); |
Jan Jongboom |
30:4825e4f38844 | 30 | printf("[NWKH] IP address: %s\n", network->get_ip_address()); |
Jan Jongboom |
30:4825e4f38844 | 31 | return network; |
Jan Jongboom |
30:4825e4f38844 | 32 | } |
Jan Jongboom |
30:4825e4f38844 | 33 | |
Jan Jongboom |
30:4825e4f38844 | 34 | #endif // _MBED_HTTP_EXAMPLE_H_ |