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-rtos mbed HTTPClient VodafoneUSBModem
Tests/Test08.cpp@46:d2c22206031a, 2012-09-19 (annotated)
- Committer:
- ashleymills
- Date:
- Wed Sep 19 09:52:46 2012 +0000
- Revision:
- 46:d2c22206031a
- Parent:
- 45:f68fea0831d7
- Child:
- 47:85c30274cc9b
Updated to latest version of bleeding edge dongle library.; Added code for DNS test.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 45:f68fea0831d7 | 1 | #include "Test08.h" |
ashleymills | 45:f68fea0831d7 | 2 | |
ashleymills | 45:f68fea0831d7 | 3 | Test08::Test08(VodafoneUSBModem *m) : VodafoneTestCase(m) { |
ashleymills | 45:f68fea0831d7 | 4 | _description = gTest08Description; |
ashleymills | 45:f68fea0831d7 | 5 | _testCaseNumber = 8; |
ashleymills | 45:f68fea0831d7 | 6 | } |
ashleymills | 45:f68fea0831d7 | 7 | |
ashleymills | 45:f68fea0831d7 | 8 | void Test08::setupTest() {} |
ashleymills | 45:f68fea0831d7 | 9 | |
ashleymills | 45:f68fea0831d7 | 10 | bool Test08::executeTest() { |
ashleymills | 45:f68fea0831d7 | 11 | bool outcome = true; |
ashleymills | 45:f68fea0831d7 | 12 | LOG("Description: %s",gTest08Description); |
ashleymills | 45:f68fea0831d7 | 13 | LOG("Connecting to internet"); |
ashleymills | 45:f68fea0831d7 | 14 | if(_modem->connect("internet","web","web")==0) { |
ashleymills | 45:f68fea0831d7 | 15 | LOG("Connected to internet"); |
ashleymills | 45:f68fea0831d7 | 16 | } else { |
ashleymills | 45:f68fea0831d7 | 17 | LOG("Failed to connect to internet"); |
ashleymills | 45:f68fea0831d7 | 18 | outcome = false; |
ashleymills | 45:f68fea0831d7 | 19 | } |
ashleymills | 46:d2c22206031a | 20 | struct hostent *server; |
ashleymills | 46:d2c22206031a | 21 | do { |
ashleymills | 46:d2c22206031a | 22 | while(1) { |
ashleymills | 46:d2c22206031a | 23 | LOG("Getting host address"); |
ashleymills | 46:d2c22206031a | 24 | server = ::gethostbyname("m2mthings.com"); |
ashleymills | 46:d2c22206031a | 25 | if(server==NULL) { |
ashleymills | 46:d2c22206031a | 26 | LOG("Failure getting host address!"); |
ashleymills | 46:d2c22206031a | 27 | outcome = false; |
ashleymills | 46:d2c22206031a | 28 | //break; |
ashleymills | 46:d2c22206031a | 29 | } else { |
ashleymills | 46:d2c22206031a | 30 | LOG("got host address, length %d",server->h_length); |
ashleymills | 46:d2c22206031a | 31 | break; |
ashleymills | 46:d2c22206031a | 32 | } |
ashleymills | 46:d2c22206031a | 33 | } |
ashleymills | 46:d2c22206031a | 34 | |
ashleymills | 46:d2c22206031a | 35 | if(server->h_length==4) { |
ashleymills | 46:d2c22206031a | 36 | LOG("DNS lookup returned %d.%d.%d.%d", |
ashleymills | 46:d2c22206031a | 37 | server->h_addr[0], |
ashleymills | 46:d2c22206031a | 38 | server->h_addr[1], |
ashleymills | 46:d2c22206031a | 39 | server->h_addr[2], |
ashleymills | 46:d2c22206031a | 40 | server->h_addr[3] |
ashleymills | 46:d2c22206031a | 41 | ); |
ashleymills | 46:d2c22206031a | 42 | } else { |
ashleymills | 46:d2c22206031a | 43 | LOG("Only IPv4 addresses are supported."); |
ashleymills | 46:d2c22206031a | 44 | outcome = false; |
ashleymills | 46:d2c22206031a | 45 | break; |
ashleymills | 46:d2c22206031a | 46 | } |
ashleymills | 46:d2c22206031a | 47 | } while(0); |
ashleymills | 45:f68fea0831d7 | 48 | |
ashleymills | 45:f68fea0831d7 | 49 | _modem->disconnect(); |
ashleymills | 45:f68fea0831d7 | 50 | return outcome; |
ashleymills | 45:f68fea0831d7 | 51 | } |
ashleymills | 45:f68fea0831d7 | 52 | |
ashleymills | 45:f68fea0831d7 | 53 | void Test08::endTest() { } |