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 12:32:32 2016 +0000
Revision:
1:1de042ff6324
Parent:
0:bf04f62339a4
Child:
2:071bf3c7f2a2
Actually made it work... Sorry!

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 0:bf04f62339a4 35 char* GetIP();
Leigh_LbR 0:bf04f62339a4 36 int Connect();
Leigh_LbR 0:bf04f62339a4 37 void Disconnect();
Leigh_LbR 0:bf04f62339a4 38 Arrival_Board GetArrivals(const std::string& code_stn, const std::string& number);
Leigh_LbR 0:bf04f62339a4 39 Departure_Board GetDepartures(const std::string& code_stn, const std::string& number);
Leigh_LbR 0:bf04f62339a4 40 };
Leigh_LbR 0:bf04f62339a4 41
Leigh_LbR 0:bf04f62339a4 42 #endif