Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/KevinCruz-cell/Redes-de-comunicaciones-/llms.txt

Use this file to discover all available pages before exploring further.

These endpoints are served under the /api/router prefix and communicate with the router over an SSH connection established at login. All endpoints require an active session (see Authentication). Responses are JSON unless noted otherwise.

GET /api/router/wifi-info

Returns current WiFi configuration and status read from the router via iwinfo and UCI.

Response

status
string
"success" on success, "error" on failure.
info
string
Raw output of iwinfo wlan0 info (or iw dev wlan0 info as fallback). Contains signal level, channel, bitrate and mode details.
ssid
string
SSID of the primary wireless interface (wireless.@wifi-iface[0]). Returns "Desconocido" if not set.
encryption
string
Encryption mode of the primary wireless interface (e.g., "psk2", "none"). Returns "none" if not set.
interfaces_count
integer
Number of wifi-iface sections configured in UCI.
{
  "status": "success",
  "info": "wlan0     ESSID: \"MyNetwork\"\n          Access Point: EC:75:0C:C2:FC:14\n          ...",
  "ssid": "MyNetwork",
  "encryption": "psk2",
  "interfaces_count": 2
}

POST /api/router/restart-wifi

Restarts the wireless subsystem by running wifi down && sleep 3 && wifi up on the router. The WiFi LED will turn off briefly and come back on.

Response

status
string
"success" or "error".
message
string
Human-readable result message.
{
  "status": "success",
  "message": "Wi-Fi reiniciado con éxito. El LED debería apagarse y encenderse de nuevo."
}
Clients connected to the WiFi network will be briefly disconnected during the restart sequence. The restart takes approximately 3–5 seconds.

GET /api/router/scan

Scans for nearby WiFi networks using iw dev wlan0 scan. Falls back to iwinfo wlan0 scan if the primary scan returns no results.

Response

Returns a JSON array. Each element represents a detected network.
ssid
string
Network name. "Oculto" if the SSID is hidden.
bssid
string
MAC address of the access point in uppercase colon-separated format.
channel
string
WiFi channel number.
signal
string
Signal strength in dBm (e.g., "-65").
encryption
string
Encryption type detected. "WPA2 PSK" when RSN/WPA IE is present, "Abierta" otherwise.
[
  {
    "ssid": "OfficeNetwork",
    "bssid": "EC:75:0C:C2:FC:14",
    "channel": "6",
    "signal": "-55",
    "encryption": "WPA2 PSK"
  },
  {
    "ssid": "Oculto",
    "bssid": "AA:BB:CC:DD:EE:FF",
    "channel": "11",
    "signal": "-70",
    "encryption": "Abierta"
  }
]

GET /api/router/devices

Returns the raw contents of /tmp/dhcp.leases from the router, which lists all active DHCP leases.

Response

leases
string
Raw text content of the DHCP leases file. Each line contains: expiry timestamp, MAC address, IP address, hostname, and client ID, space-separated.
{
  "leases": "1716000000 aa:bb:cc:dd:ee:ff 192.168.10.50 my-laptop *\n1716000100 11:22:33:44:55:66 192.168.10.51 phone *\n"
}

POST /api/router/switch

Executes a swconfig command on the router’s switch0 device. Used for reading switch configuration such as VLAN tables and port info.

Request

cmd
string
required
The swconfig command to execute. Must begin with swconfig dev switch0 — any other prefix is rejected with HTTP 403.

Response

output
string
Raw output returned by the command.
curl -X POST http://your-app.local/api/router/switch \
  -H "Content-Type: application/json" \
  -d '{"cmd": "swconfig dev switch0 show"}'
{
  "output": "Global attributes:\n\tlink: port:0 link:up speed:1000baseT full-duplex ...\n"
}
Commands not prefixed with swconfig dev switch0 are rejected with a 403 response. This restriction prevents arbitrary command execution.

POST /api/router/apply-uci

Applies one or more UCI commands on the router in sequence, then commits the wireless configuration. If any command references wifi or hostapd, the endpoint also runs wifi down; sleep 2; wifi up to apply changes live.

Request

commands
string[]
required
Array of UCI command strings to execute. Empty strings are ignored. The commit (uci commit wireless) is added automatically if not included in the list.

Response

status
string
"success" or "error".
message
string
"OK" on success, or an error message.
output
string
Combined output from all executed commands.
curl -X POST http://your-app.local/api/router/apply-uci \
  -H "Content-Type: application/json" \
  -d '{
    "commands": [
      "uci set wireless.@wifi-iface[0].ssid=NewSSID",
      "uci set wireless.@wifi-iface[0].encryption=psk2",
      "uci set wireless.@wifi-iface[0].key=mysecretkey"
    ]
  }'
{
  "status": "success",
  "message": "OK",
  "output": ""
}

POST /api/router/save-switch

Rebuilds the switch_vlan UCI sections for switch0 based on a VLAN port matrix, commits the network configuration, and restarts the network subsystem.

Request

vlans
object[]
required
Array of VLAN configuration objects. Each object describes one VLAN and the role of each port within it.

Response

status
string
"success" or "error".
message
string
Description of the result.
curl -X POST http://your-app.local/api/router/save-switch \
  -H "Content-Type: application/json" \
  -d '{
    "vlans": [
      {
        "id": 1,
        "modes": { "0": "t", "1": "u", "2": "u", "3": "u", "4": "u", "5": "off", "6": "off" }
      },
      {
        "id": 2,
        "modes": { "0": "t", "1": "off", "2": "off", "3": "u", "4": "u", "5": "off", "6": "off" }
      }
    ]
  }'
{
  "status": "success",
  "message": "Configuración de puertos y VLANs sincronizada en el hardware."
}
This endpoint deletes all existing switch_vlan UCI sections before writing new ones. Send the complete desired VLAN matrix each time — partial updates are not supported.

GET /api/router/port-status

Returns the link status, speed, and duplex mode for each of the seven ports (0–6) on switch0.

Response

status
string
"success" or "error".
ports
object[]
Array of port status objects, one per port.
{
  "status": "success",
  "ports": [
    { "id": 0, "link": true, "speed": "1000baseT", "full_duplex": true, "raw": "port:0 link:up speed:1000baseT full-duplex" },
    { "id": 1, "link": true, "speed": "100baseT", "full_duplex": false, "raw": "port:1 link:up speed:100baseT" },
    { "id": 2, "link": false, "speed": "", "full_duplex": false, "raw": "port:2 link:down" }
  ]
}

POST /api/router/set-port-state

Enables or disables a specific switch port using the swconfig disable attribute.

Request

port
integer
required
Port number to control. Must be one of: 0, 1, 2, 3, 4, 5, 6.
state
string
required
Desired port state. "up" to enable the port, "down" to disable it.

Response

status
string
"success" or "error".
port
integer
The port number that was modified.
state
string
The state that was applied ("up" or "down").
message
string
Human-readable confirmation message.
Raw output of the link verification command run after the state change.
curl -X POST http://your-app.local/api/router/set-port-state \
  -H "Content-Type: application/json" \
  -d '{"port": 3, "state": "down"}'
{
  "status": "success",
  "port": 3,
  "state": "down",
  "message": "Puerto desactivado",
  "link": "port:3 link:down"
}
Disabling the port connected to your management workstation will drop your SSH/HTTP session. Always ensure you have an alternative path back to the router before disabling a port.

Build docs developers (and LLMs) love