Compare commits
4
Commits
v0.0.10
...
aba2fa9b80
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aba2fa9b80 | ||
|
|
7cf2f53793 | ||
|
|
892012bc1c | ||
|
|
dc4180320b |
@@ -1,32 +1,11 @@
|
||||
name: Build image
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
jobs:
|
||||
build-image:
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
runs-on: nix
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
# Required for installing nix
|
||||
- name: Install sudo
|
||||
run: apt-get update && apt-get install -y sudo
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
enable_kvm: false
|
||||
- name: Get image meta
|
||||
run: nix build .#image-meta -o image-meta
|
||||
- name: Version check
|
||||
run: |
|
||||
VERSION=$(cat image-meta/version)
|
||||
[ "$GITHUB_REF_NAME" = v"$VERSION" ]
|
||||
- name: Build image
|
||||
run: nix build .#image -o image.tar.gz
|
||||
- run: docker login -u paul -p "$PASSWORD" git.pbrinkmeier.de
|
||||
env:
|
||||
PASSWORD: "${{ secrets.REGISTRY_PASSWORD }}"
|
||||
- run: docker load < image.tar.gz
|
||||
- run: docker image push $(cat image-meta/name)
|
||||
- run: ls -lah
|
||||
- run: nix build .#image -o image.tar.gz
|
||||
|
||||
+8
-5
@@ -61,10 +61,10 @@ struct Timetable {
|
||||
|
||||
// Selectable timetables
|
||||
Timetable timetables[] = {
|
||||
{"Johanneskirche, Bstg. 1", "/departures?stop_id=de:08311:30104&platform=1"},
|
||||
{"Johanneskirche, Bstg. 2", "/departures?stop_id=de:08311:30104&platform=2"},
|
||||
{"Blumenthalstr., Bstg. A", "/departures?stop_id=de:08221:1225&platform=A"},
|
||||
{"Blumenthalstr., Bstg. B", "/departures?stop_id=de:08221:1225&platform=B"}
|
||||
{"Blumenthalstr. Bstg. A", "/departures?stop_id=de:08221:1225&platform=A"},
|
||||
{"Blumenthalstr. Bstg. B", "/departures?stop_id=de:08221:1225&platform=B"},
|
||||
{"Kapellenweg Bstg. A", "/departures?stop_id=de:08221:1135&platform=A"},
|
||||
{"Kapellenweg Bstg. B", "/departures?stop_id=de:08221:1135&platform=B"},
|
||||
};
|
||||
size_t selectedTimetable = 0;
|
||||
|
||||
@@ -233,7 +233,6 @@ void StateShowingDepartures::enter() {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
char symbol[3] = {0};
|
||||
char direction[16] = {0};
|
||||
|
||||
@@ -252,6 +251,10 @@ void StateShowingDepartures::enter() {
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
clearClock();
|
||||
display.setCursor(CLOCK_X, CLOCK_Y);
|
||||
display.printf("%5s", departures["serverTime"].as<const char *>());
|
||||
}
|
||||
|
||||
void StateShowingDepartures::tick() {
|
||||
|
||||
+143
@@ -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
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import "errors"
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "net/http"
|
||||
import "net/url"
|
||||
import "os"
|
||||
import "slices"
|
||||
import "strings"
|
||||
@@ -47,144 +46,6 @@ type DMDateTime struct {
|
||||
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) {
|
||||
req, err := c.BuildRequest(stopId)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user