Firmware  0.4.1
Loading...
Searching...
No Matches
HTTP

The HTTP module contains the implementation of the web server. Depending on the operating mode (access point or station), either a server for the captive portal or one for the REST APIs is created. Which server is ultimately started depends on whether a network SSID is stored in the settings. If no settings are available yet, the access point server is started, otherwise the station server is started.

Access Point

The access point server provides the captive portal for initial network configuration. Two endpoints are created for this purpose:

  • /save/
    • POST
  • /*
    • GET

/*

The wildcard GET endpoint redirects all requests to the captive portal. The string containing the complete HTML code is generated at runtime using std::format_to_n. In addition to a number of (pre)settings, it also contains a list of available WiFi networks.

/save/

The POST endpoint receives the settings of the captive portal when saving in the form of query parameters. The settings are stored in the NVS namespace settings. Afterwards the board reboots.

Station

The server for station mode provides a whole range of different endpoints that can be used in normal operation.

  • /dcc/
    • GET
    • POST
  • /dcc/locos/
    • DELETE
    • GET
    • PUT
  • /dcc/turnouts/
    • DELETE
    • GET
    • PUT
  • /settings/
    • GET
    • POST
  • /sys/
    • GET
  • /*
    • GET

WebSockets?

Endpoints

The Endpoints class allows you to set up subscriptions to different endpoints. For such a subscription, the request type and endpoint name must be specified. Furthermore, a distinction is made between synchronous (HTTP) and asynchronous (WebSocket) connections.

Both subscription types are stored in a std::map with a custom key comparator.

Previous Next
Interfaces mDNS