Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt
network.cpp@37:8a0fc62a0512, 2020-11-29 (annotated)
- Committer:
 - vsoltan
 - Date:
 - Sun Nov 29 22:40:24 2020 +0000
 - Revision:
 - 37:8a0fc62a0512
 - Parent:
 - 19:58cc5465f647
 
finalizing code before writing report
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| vsoltan | 11:d0a105f6743f | 1 | #include "network.h" | 
| vsoltan | 11:d0a105f6743f | 2 | |
| vsoltan | 11:d0a105f6743f | 3 | void initEthernet(EthernetInterface *eth, UDPSocket *sock, Endpoint *nist) { | 
| vsoltan | 17:32ae1f106002 | 4 | int rc; | 
| vsoltan | 17:32ae1f106002 | 5 | rc = eth->init(); //Use DHCP | 
| vsoltan | 17:32ae1f106002 | 6 | if (rc < 0) { | 
| vsoltan | 19:58cc5465f647 | 7 | printf("\n\rFatal Error: failed to initialize ethernet via DHCP\n\r"); | 
| vsoltan | 17:32ae1f106002 | 8 | return; | 
| vsoltan | 17:32ae1f106002 | 9 | } | 
| vsoltan | 17:32ae1f106002 | 10 | rc = eth->connect(); | 
| vsoltan | 17:32ae1f106002 | 11 | if (rc < 0) { | 
| vsoltan | 19:58cc5465f647 | 12 | printf("\n\rFatal Error: failed to connect\n\r"); | 
| vsoltan | 17:32ae1f106002 | 13 | return; | 
| vsoltan | 17:32ae1f106002 | 14 | } | 
| vsoltan | 17:32ae1f106002 | 15 | rc = sock->init(); | 
| vsoltan | 17:32ae1f106002 | 16 | if (rc < 0) { | 
| vsoltan | 19:58cc5465f647 | 17 | printf("\n\rFatal Error: failed to initialize socket\n\r"); | 
| vsoltan | 17:32ae1f106002 | 18 | return; | 
| vsoltan | 17:32ae1f106002 | 19 | } | 
| vsoltan | 17:32ae1f106002 | 20 | rc = nist->set_address(AWS_IP, PORT); | 
| vsoltan | 17:32ae1f106002 | 21 | if (rc < 0) { | 
| vsoltan | 19:58cc5465f647 | 22 | printf("\n\rFatal Error: failed to set address\n\r"); | 
| vsoltan | 17:32ae1f106002 | 23 | return; | 
| vsoltan | 17:32ae1f106002 | 24 | } | 
| denizguler | 13:95d44f7855ca | 25 | sock->set_blocking(false, 0); | 
| vsoltan | 19:58cc5465f647 | 26 | printf("\n\rSuccess! Connected to %s, port: %i\n\r", AWS_IP, PORT); | 
| vsoltan | 11:d0a105f6743f | 27 | } | 
| vsoltan | 11:d0a105f6743f | 28 | |
| vsoltan | 11:d0a105f6743f | 29 | void cleanupEthernet(EthernetInterface *eth, UDPSocket *sock) { | 
| vsoltan | 11:d0a105f6743f | 30 | sock->close(); | 
| vsoltan | 11:d0a105f6743f | 31 | eth->disconnect(); | 
| vsoltan | 11:d0a105f6743f | 32 | } | 
