cd-wifi-client

A client for the WiFi portal of Czech Railways trains.

Usage no npm install needed!

<script type="module">
  import cdWifiClient from 'https://cdn.skypack.dev/cd-wifi-client';
</script>

README

cd-wifi-client

A client for the onboard WiFi portal of České dráhy (Czech Railways) trains.

npm version ISC-licensed chat with me on Gitter support me on Patreon

Installation

npm install cd-wifi-client

Usage

Acknowledging the captive portal

const {acknowledgeCaptivePortal} = require('cd-wifi-client')

const acknowledgeLegalTerms = (msg) => {
    console.log(msg)
    return Promise.resolve() // we always accept
}

acknowledgeCaptivePortal(acknowledgeLegalTerms)
.then(successMsg => console.info(successMsg))
.catch(console.error)

Getting the current position

const {fetchTrainStatus} = require('cd-wifi-client')

console.log(await fetchTrainStatus())
{
    latitude: 50.252175,
    longitude: 14.30227,
    altitude: 185.5,
    speed: 85,
    delay: null,
}

Getting the WiFi data limit & connectivity

const {
    fetchWifiStatus,
    fetchWifiConnectivity,
} = require('cd-wifi-client')

console.log(await fetchWifiStatus())
console.log(await fetchWifiConnectivity())
// WiFi status
{
    authenticated: true,
    id: null,
    clientIpAddress: '10.0.0.105',
    clientMacAddress: null,
    dataUsage: {used: 0, limit: -1, speedLimit: false, region: 'CZ'},
}
// WiFi connectivity
{
    version: '1.9',
    online: '1',
    bundleid: '84105699258',
    bundleip: '10.3.2.1',
    links: [
        {
            index: '1',
            device_type: 'ethernet',
            device_state: 'down',
            link_state: 'disconnected',
            ethernet_info: {ip: '0.0.0.0', netmask: '0.0.0.0', mode: 'dhcp'},
        },
        {
            index: '102',
            device_type: 'modem',
            device_subtype: 'sierra-7710',
            device_state: 'up',
            link_state: 'available',
            rssi: '-75',
            technology: 'lte',
            operator_id: '23002',
            apninfo: 'cd-internet,-1,-1',
            umts_info: {net_status: '1', lac: 'FFFE', cellid: '03F3FF01'},
        },
        // …
    ]
}

Related

Contributing

If you have a question or need support using cd-wifi-client, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.