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.

/media/uploads/Leigh_LbR/nre_powered_logo.jpg

Committer:
Leigh_LbR
Date:
Thu Apr 21 15:02:20 2016 +0000
Revision:
4:7e8a23454d85
Parent:
2:071bf3c7f2a2
Child:
8:6e063a3827c0
Finished documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Leigh_LbR 0:bf04f62339a4 1 #ifndef NR_NETWORK_H
Leigh_LbR 0:bf04f62339a4 2 #define NR_NETWORK_H
Leigh_LbR 0:bf04f62339a4 3
Leigh_LbR 0:bf04f62339a4 4 #include "arrival_board.h"
Leigh_LbR 0:bf04f62339a4 5 #include "departure_board.h"
Leigh_LbR 1:1de042ff6324 6 #include "EthernetInterface.h"
Leigh_LbR 0:bf04f62339a4 7 #include <string>
Leigh_LbR 0:bf04f62339a4 8
Leigh_LbR 1:1de042ff6324 9 /** NR_Network_Conn
Leigh_LbR 1:1de042ff6324 10 * Used for establishing a connection to the Huxley NR SOAP proxy and to generate departure/arrivals data
Leigh_LbR 1:1de042ff6324 11 */
Leigh_LbR 0:bf04f62339a4 12 class NR_Network_Conn
Leigh_LbR 0:bf04f62339a4 13 {
Leigh_LbR 0:bf04f62339a4 14 private:
Leigh_LbR 0:bf04f62339a4 15 void init(const char* address, const char* mask, const char* gateway);
Leigh_LbR 0:bf04f62339a4 16 EthernetInterface conn;
Leigh_LbR 0:bf04f62339a4 17 TCPSocketConnection socket;
Leigh_LbR 0:bf04f62339a4 18 char _address[17];
Leigh_LbR 0:bf04f62339a4 19 char _sub_mask[17];
Leigh_LbR 0:bf04f62339a4 20 char _gateway[17];
Leigh_LbR 0:bf04f62339a4 21
Leigh_LbR 0:bf04f62339a4 22 public:
Leigh_LbR 1:1de042ff6324 23 /** Make a connection. The empty constructor creates a connection using DHCP.
Leigh_LbR 1:1de042ff6324 24 */
Leigh_LbR 0:bf04f62339a4 25 NR_Network_Conn();
Leigh_LbR 1:1de042ff6324 26 /** Make a connection. This constructor creates a connection with the specified IP address, subnet and gateway
Leigh_LbR 1:1de042ff6324 27 * @param address the IP address of this device (in the format "192.168.1.101"
Leigh_LbR 1:1de042ff6324 28 * @param mask the subnet mask of this device (in the format "255.255.255.0"
Leigh_LbR 1:1de042ff6324 29 * @param gateway the gatway of this device (in the format "192.168.1.1"
Leigh_LbR 1:1de042ff6324 30 */
Leigh_LbR 0:bf04f62339a4 31 NR_Network_Conn(const char* address, const char* mask, const char* gateway);
Leigh_LbR 1:1de042ff6324 32 /** Get the socket (an object of type TCPSocketConnection)
Leigh_LbR 1:1de042ff6324 33 */
Leigh_LbR 0:bf04f62339a4 34 TCPSocketConnection GetSocket();
Leigh_LbR 2:071bf3c7f2a2 35 /** Get the IP address of the current connection
Leigh_LbR 2:071bf3c7f2a2 36 */
Leigh_LbR 0:bf04f62339a4 37 char* GetIP();
Leigh_LbR 2:071bf3c7f2a2 38 /** Establish a connection to the API
Leigh_LbR 2:071bf3c7f2a2 39 */
Leigh_LbR 0:bf04f62339a4 40 int Connect();
Leigh_LbR 2:071bf3c7f2a2 41 /** Disconnect from the API
Leigh_LbR 2:071bf3c7f2a2 42 */
Leigh_LbR 0:bf04f62339a4 43 void Disconnect();
Leigh_LbR 4:7e8a23454d85 44 /** Request a list of arrivals from the API and format them into an Arrival_Board object.
Leigh_LbR 4:7e8a23454d85 45 * @param code_stn the station code to get arrivals from
Leigh_LbR 4:7e8a23454d85 46 * @param number the number of arrivals to retrieve
Leigh_LbR 4:7e8a23454d85 47 * @return an Arrival_Board object containing all the arrivals to this station
Leigh_LbR 4:7e8a23454d85 48 */
Leigh_LbR 0:bf04f62339a4 49 Arrival_Board GetArrivals(const std::string& code_stn, const std::string& number);
Leigh_LbR 4:7e8a23454d85 50 /** Request a list of departures from the API and format them into a Departure_Board object.
Leigh_LbR 4:7e8a23454d85 51 * @param code_stn the station code to get departures from
Leigh_LbR 4:7e8a23454d85 52 * @param number the number of departures to retrieve
Leigh_LbR 4:7e8a23454d85 53 * @return a Departure_Board object containing all the departures from this station
Leigh_LbR 4:7e8a23454d85 54 */
Leigh_LbR 0:bf04f62339a4 55 Departure_Board GetDepartures(const std::string& code_stn, const std::string& number);
Leigh_LbR 0:bf04f62339a4 56 };
Leigh_LbR 0:bf04f62339a4 57
Leigh_LbR 0:bf04f62339a4 58 #endif