Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
7cf2f53793 | |||
892012bc1c | |||
dc4180320b |
@ -61,10 +61,10 @@ struct Timetable {
|
|||||||
|
|
||||||
// Selectable timetables
|
// Selectable timetables
|
||||||
Timetable timetables[] = {
|
Timetable timetables[] = {
|
||||||
{"Johanneskirche, Bstg. 1", "/departures?stop_id=de:08311:30104&platform=1"},
|
{"Blumenthalstr. Bstg. A", "/departures?stop_id=de:08221:1225&platform=A"},
|
||||||
{"Johanneskirche, Bstg. 2", "/departures?stop_id=de:08311:30104&platform=2"},
|
{"Blumenthalstr. Bstg. B", "/departures?stop_id=de:08221:1225&platform=B"},
|
||||||
{"Blumenthalstr., Bstg. A", "/departures?stop_id=de:08221:1225&platform=A"},
|
{"Kapellenweg Bstg. A", "/departures?stop_id=de:08221:1135&platform=A"},
|
||||||
{"Blumenthalstr., Bstg. B", "/departures?stop_id=de:08221:1225&platform=B"}
|
{"Kapellenweg Bstg. B", "/departures?stop_id=de:08221:1135&platform=B"},
|
||||||
};
|
};
|
||||||
size_t selectedTimetable = 0;
|
size_t selectedTimetable = 0;
|
||||||
|
|
||||||
@ -232,7 +232,6 @@ void StateShowingDepartures::enter() {
|
|||||||
if (line > 8) {
|
if (line > 8) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char symbol[3] = {0};
|
char symbol[3] = {0};
|
||||||
char direction[16] = {0};
|
char direction[16] = {0};
|
||||||
@ -252,6 +251,10 @@ void StateShowingDepartures::enter() {
|
|||||||
|
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearClock();
|
||||||
|
display.setCursor(CLOCK_X, CLOCK_Y);
|
||||||
|
display.printf("%5s", departures["serverTime"].as<const char *>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StateShowingDepartures::tick() {
|
void StateShowingDepartures::tick() {
|
||||||
|
143
efa_client.go
Normal file
143
efa_client.go
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
import "net/url"
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
type EFAClient interface {
|
||||||
|
GetName() string
|
||||||
|
BuildRequest(string) (*http.Request, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
var allEfaClients []EFAClient = []EFAClient{
|
||||||
|
BwegtEFAClient{},
|
||||||
|
VRNEFAClient{},
|
||||||
|
KVVEFAClient{},
|
||||||
|
VAGEFAClient{},
|
||||||
|
}
|
||||||
|
|
||||||
|
type VRNEFAClient struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c VRNEFAClient) GetName() string {
|
||||||
|
return "VRN"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c VRNEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||||
|
// Create request object
|
||||||
|
req, err := http.NewRequest("GET", "https://www.vrn.de/mngvrn/XML_DM_REQUEST", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure our request
|
||||||
|
query := url.Values{}
|
||||||
|
query.Set("coordOutputFormat", "EPSG:4326")
|
||||||
|
query.Set("depType", "stopEvents")
|
||||||
|
query.Set("includeCompleteStopSeq", "0")
|
||||||
|
query.Set("limit", "10")
|
||||||
|
query.Set("locationServerActive", "0")
|
||||||
|
query.Set("mode", "direct")
|
||||||
|
query.Set("name_dm", stopId)
|
||||||
|
query.Set("outputFormat", "json")
|
||||||
|
query.Set("type_dm", "stop")
|
||||||
|
query.Set("useOnlyStops", "1")
|
||||||
|
query.Set("useRealtime", "1")
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
return req, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type KVVEFAClient struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c KVVEFAClient) GetName() string {
|
||||||
|
return "KVV"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c KVVEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||||
|
form := url.Values{}
|
||||||
|
form.Set("action", "XSLT_DM_REQUEST")
|
||||||
|
form.Set("name_dm", stopId)
|
||||||
|
form.Set("type_dm", "stop")
|
||||||
|
form.Set("useRealtime", "1")
|
||||||
|
form.Set("limit", "10")
|
||||||
|
form.Set("mode", "direct")
|
||||||
|
form.Set("useRealtime", "1")
|
||||||
|
form.Set("outputFormat", "json")
|
||||||
|
body := strings.NewReader(form.Encode())
|
||||||
|
|
||||||
|
req, err := http.NewRequest("POST", "https://www.kvv.de/tunnelEfaDirect.php", body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("User-Agent", "coolio/1.0")
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
return req, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type BwegtEFAClient struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c BwegtEFAClient) GetName() string {
|
||||||
|
return "bwegt"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||||
|
// Create request object
|
||||||
|
req, err := http.NewRequest("GET", "https://www.bwegt.de/bwegt-efa/XML_DM_REQUEST", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure our request
|
||||||
|
query := url.Values{}
|
||||||
|
query.Set("coordOutputFormat", "EPSG:4326")
|
||||||
|
query.Set("depType", "stopEvents")
|
||||||
|
query.Set("includeCompleteStopSeq", "0")
|
||||||
|
query.Set("limit", "10")
|
||||||
|
query.Set("locationServerActive", "0")
|
||||||
|
query.Set("mode", "direct")
|
||||||
|
query.Set("name_dm", stopId)
|
||||||
|
query.Set("outputFormat", "json")
|
||||||
|
query.Set("type_dm", "stop")
|
||||||
|
query.Set("useOnlyStops", "1")
|
||||||
|
query.Set("useRealtime", "1")
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
return req, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type VAGEFAClient struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c VAGEFAClient) GetName() string {
|
||||||
|
return "VAG"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c VAGEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
||||||
|
// Create request object
|
||||||
|
req, err := http.NewRequest("GET", "https://efa.vagfr.de/vagfr3/XSLT_DM_REQUEST", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure our request
|
||||||
|
query := url.Values{}
|
||||||
|
query.Set("coordOutputFormat", "EPSG:4326")
|
||||||
|
query.Set("depType", "stopEvents")
|
||||||
|
query.Set("includeCompleteStopSeq", "0")
|
||||||
|
query.Set("limit", "10")
|
||||||
|
query.Set("locationServerActive", "0")
|
||||||
|
query.Set("mode", "direct")
|
||||||
|
query.Set("name_dm", stopId)
|
||||||
|
query.Set("outputFormat", "json")
|
||||||
|
query.Set("type_dm", "stop")
|
||||||
|
query.Set("useOnlyStops", "1")
|
||||||
|
query.Set("useRealtime", "1")
|
||||||
|
req.URL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
return req, nil
|
||||||
|
}
|
139
main.go
139
main.go
@ -6,7 +6,6 @@ import "errors"
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
import "log"
|
import "log"
|
||||||
import "net/http"
|
import "net/http"
|
||||||
import "net/url"
|
|
||||||
import "os"
|
import "os"
|
||||||
import "slices"
|
import "slices"
|
||||||
import "strings"
|
import "strings"
|
||||||
@ -47,144 +46,6 @@ type DMDateTime struct {
|
|||||||
Minute string `json:"minute"`
|
Minute string `json:"minute"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EFAClient interface {
|
|
||||||
GetName() string
|
|
||||||
BuildRequest(string) (*http.Request, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var allEfaClients []EFAClient = []EFAClient{
|
|
||||||
BwegtEFAClient{},
|
|
||||||
VRNEFAClient{},
|
|
||||||
KVVEFAClient{},
|
|
||||||
VAGEFAClient{},
|
|
||||||
}
|
|
||||||
|
|
||||||
type VRNEFAClient struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c VRNEFAClient) GetName() string {
|
|
||||||
return "VRN"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c VRNEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
|
||||||
// Create request object
|
|
||||||
req, err := http.NewRequest("GET", "https://www.vrn.de/mngvrn/XML_DM_REQUEST", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure our request
|
|
||||||
query := url.Values{}
|
|
||||||
query.Set("coordOutputFormat", "EPSG:4326")
|
|
||||||
query.Set("depType", "stopEvents")
|
|
||||||
query.Set("includeCompleteStopSeq", "0")
|
|
||||||
query.Set("limit", "10")
|
|
||||||
query.Set("locationServerActive", "0")
|
|
||||||
query.Set("mode", "direct")
|
|
||||||
query.Set("name_dm", stopId)
|
|
||||||
query.Set("outputFormat", "json")
|
|
||||||
query.Set("type_dm", "stop")
|
|
||||||
query.Set("useOnlyStops", "1")
|
|
||||||
query.Set("useRealtime", "1")
|
|
||||||
req.URL.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type KVVEFAClient struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c KVVEFAClient) GetName() string {
|
|
||||||
return "KVV"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c KVVEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
|
||||||
form := url.Values{}
|
|
||||||
form.Set("action", "XSLT_DM_REQUEST")
|
|
||||||
form.Set("name_dm", stopId)
|
|
||||||
form.Set("type_dm", "stop")
|
|
||||||
form.Set("useRealtime", "1")
|
|
||||||
form.Set("limit", "10")
|
|
||||||
form.Set("mode", "direct")
|
|
||||||
form.Set("useRealtime", "1")
|
|
||||||
form.Set("outputFormat", "json")
|
|
||||||
body := strings.NewReader(form.Encode())
|
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", "https://www.kvv.de/tunnelEfaDirect.php", body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("User-Agent", "coolio/1.0")
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type BwegtEFAClient struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c BwegtEFAClient) GetName() string {
|
|
||||||
return "bwegt"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
|
||||||
// Create request object
|
|
||||||
req, err := http.NewRequest("GET", "https://www.bwegt.de/bwegt-efa/XML_DM_REQUEST", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure our request
|
|
||||||
query := url.Values{}
|
|
||||||
query.Set("coordOutputFormat", "EPSG:4326")
|
|
||||||
query.Set("depType", "stopEvents")
|
|
||||||
query.Set("includeCompleteStopSeq", "0")
|
|
||||||
query.Set("limit", "10")
|
|
||||||
query.Set("locationServerActive", "0")
|
|
||||||
query.Set("mode", "direct")
|
|
||||||
query.Set("name_dm", stopId)
|
|
||||||
query.Set("outputFormat", "json")
|
|
||||||
query.Set("type_dm", "stop")
|
|
||||||
query.Set("useOnlyStops", "1")
|
|
||||||
query.Set("useRealtime", "1")
|
|
||||||
req.URL.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type VAGEFAClient struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c VAGEFAClient) GetName() string {
|
|
||||||
return "VAG"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c VAGEFAClient) BuildRequest(stopId string) (*http.Request, error) {
|
|
||||||
// Create request object
|
|
||||||
req, err := http.NewRequest("GET", "https://efa.vagfr.de/vagfr3/XSLT_DM_REQUEST", nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure our request
|
|
||||||
query := url.Values{}
|
|
||||||
query.Set("coordOutputFormat", "EPSG:4326")
|
|
||||||
query.Set("depType", "stopEvents")
|
|
||||||
query.Set("includeCompleteStopSeq", "0")
|
|
||||||
query.Set("limit", "10")
|
|
||||||
query.Set("locationServerActive", "0")
|
|
||||||
query.Set("mode", "direct")
|
|
||||||
query.Set("name_dm", stopId)
|
|
||||||
query.Set("outputFormat", "json")
|
|
||||||
query.Set("type_dm", "stop")
|
|
||||||
query.Set("useOnlyStops", "1")
|
|
||||||
query.Set("useRealtime", "1")
|
|
||||||
req.URL.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
return req, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
|
func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
|
||||||
req, err := c.BuildRequest(stopId)
|
req, err := c.BuildRequest(stopId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user