Skip to content

Commit e1380db

Browse files
committed
Documentation
1 parent dbdd5bd commit e1380db

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

DBAPI.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ DBAPI::DBAPI() {
1313

1414
}
1515

16-
16+
/**
17+
* Get stations matching the name or close to an address
18+
* @param name Name of the station to get
19+
* @param address Address to request nearest stations from - currently not implemented, leave as NULL
20+
* @param num Maxmium of stations to request
21+
* @return DBstation* array, possibly NULL if no results were found
22+
*/
1723
DBstation* DBAPI::getStation(
1824
const char* name,
1925
const char* address,
@@ -100,6 +106,11 @@ DBstation* DBAPI::getStation(
100106
return stations;
101107
}
102108

109+
/**
110+
* Get stations by coordinates
111+
* Legacy function, not implemented again
112+
* @return NULL currently
113+
*/
103114
DBstation* DBAPI::getStationByCoord(
104115
uint32_t latitude,
105116
uint32_t longitude,
@@ -109,6 +120,17 @@ DBstation* DBAPI::getStationByCoord(
109120
return NULL;
110121
}
111122

123+
/**
124+
* Requests departures/arrivals from/at given stationID.
125+
* @param type abfahrt or ankunft
126+
* @param stationId ID of stations, can be acquired by getStation(...)->stationId
127+
* @param target target of service, currently not used, leave as NULL
128+
* @param time specify request date/time, leave at 0 if you want to query with current time
129+
* @param maxCount maxiumum of services to request (may be lower if maxDuration is reached before maxCount)
130+
* @param maxDuration maximum of hours to request (each hour will possibly generate a new http request)
131+
* @param productFilter any combination of DBprod values for service types to request
132+
* @return DBdeparr array, possibly NULL if no service is available with the requested parameters or an error occured
133+
*/
112134
DBdeparr* DBAPI::getStationBoard(
113135
const char type[8],
114136
const char* stationId,
@@ -308,6 +330,11 @@ DBdeparr* DBAPI::getStationBoard(
308330
return deparr;
309331
}
310332

333+
/**
334+
* Helper to parse string to time_t
335+
* @param t Time string in time with potential TZ formatted like 0123-56-89T12:45:67+90:23
336+
* @return time_t timestamp
337+
*/
311338
time_t DBAPI::parseTime(const char* t) {
312339
tmElements_t time;
313340
// 0123-56-89T12:45:67+90:23
@@ -321,6 +348,10 @@ time_t DBAPI::parseTime(const char* t) {
321348
return makeTime(time);
322349
}
323350

351+
/**
352+
* Wrapper for querying departures
353+
* @see getStationBoard
354+
*/
324355
DBdeparr* DBAPI::getDepartures(
325356
const char* stationId,
326357
const char* target,
@@ -332,6 +363,10 @@ DBdeparr* DBAPI::getDepartures(
332363
return getStationBoard("abfahrt", stationId, target, time, maxCount, maxDuration, productFilter);
333364
}
334365

366+
/**
367+
* Wrapper for querying arrivals
368+
* @see getStationBoard
369+
*/
335370
DBdeparr* DBAPI::getArrivals(
336371
const char* stationId,
337372
const char* target,
@@ -343,14 +378,25 @@ DBdeparr* DBAPI::getArrivals(
343378
return getStationBoard("ankunft", stationId, target, time, maxCount, maxDuration, productFilter);
344379
}
345380

381+
/**
382+
* Replace special characters for AdafruitGFX charset
383+
* @param gfx If true, will replace for AdafruitGFX, otherwise like ä -> ae
384+
*/
346385
void DBAPI::setAGFXOutput(bool gfx) {
347386
repum = gfx ? REP_AGFX : REP_UML;
348387
}
349388

389+
/**
390+
* Replace special characters for displays
391+
* @param uml `REP_AGFX` for AdafruitGFX, `REP_UML` for simple ä -> ae and REP_NONE for raw output
392+
*/
350393
void DBAPI::setUmlaut(enum DBumlaut uml) {
351394
repum = uml;
352395
}
353396

397+
/**
398+
* Translate numeric values into strings for 2025+ API version
399+
*/
354400
const char* DBAPI::services[] = {
355401
"HOCHGESCHWINDIGKEITSZUEGE",
356402
"INTERCITYUNDEUROCITYZUEGE",

0 commit comments

Comments
 (0)