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.
Diff: nr_network.cpp
- Revision:
- 11:4532ff549fcf
- Parent:
- 8:6e063a3827c0
--- 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();