API for linking to the Huxley National Rail REST proxy for the retrieval of live National Rail data. Still needs work (sadly), but works well for the time being!
Dependencies: EthernetInterface
National Rail Huxley Integration Interface
This API provides a clear link between the National Rail Huxley Integration JSON interface (available at https://huxley.unop.uk/), and mbed devices, over an Ethernet connection. This project is still very much a work-in-progress, but hopefully I will be able to provide a comprehensive method of retrieving live National Rail departures data in a simple and effective way.
Revision 11:4532ff549fcf, committed 2016-05-24
- Comitter:
- Leigh_LbR
- Date:
- Tue May 24 15:17:38 2016 +0000
- Parent:
- 10:d178bc9eb95a
- Commit message:
- Fixed a small glitch with NR_Network.cpp
Changed in this revision
nr_network.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r d178bc9eb95a -r 4532ff549fcf nr_network.cpp --- a/nr_network.cpp Tue May 10 13:18:25 2016 +0000 +++ b/nr_network.cpp Tue May 24 15:17:38 2016 +0000 @@ -1,6 +1,7 @@ #include "departure_board.h" #include "arrival_board.h" #include "nr_network.h" +#include "mbed.h" #include <string> #include <vector> @@ -109,13 +110,23 @@ */ int NR_Network_Conn::Connect(const char* url) { - if(_address[0] == '\0' && _sub_mask[0] == '\0' && _gateway == '\0') { + Serial pc(USBTX, USBRX); + pc.baud(115200); + pc.printf("Initiating connection (2A)...\n"); + + if((_address[0] == '\0') || (_sub_mask[0] == '\0') || (_gateway == '\0')) { + pc.printf("IP Address is being set by DHCP.\n"); if(conn.init() < 0) return -1; } else { + pc.printf("IP Address is being set manually.\n"); if(conn.init(_address, _sub_mask, _gateway) < 0) return -1; } - conn.connect(); + pc.printf("Connecting (2B)...\n"); + + if(int err = conn.connect() < 0) return err; + + pc.printf("Creating TCPSocketConnection (2C)...\n"); socket = TCPSocketConnection();