### TPLinkMR200Client usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/mr-variants.md Shows how to instantiate TPLinkMR200Client, authorize, get LTE status, and logout. Requires a router at the given URL and password. ```python from tplinkrouterc6u import TPLinkMR200Client, Connection router = TPLinkMR200Client('http://192.168.1.1', 'password') router.authorize() print(router.get_lte_status().isp_name) router.logout() ``` -------------------------------- ### Usage example: get_client with default parameters Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/provider.md Basic usage of get_client with host and password, then authorize, get firmware, and logout. ```python from tplinkrouterc6u import TplinkRouterProvider router = TplinkRouterProvider.get_client('http://192.168.0.1', 'password') router.authorize() print(router.get_firmware()) router.logout() ``` -------------------------------- ### Install repository in editable mode with pip Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/README.md Run from the repository root or with the path to the repo to install the package in editable mode for local development. ```bash pip install -e path/to/repo ``` -------------------------------- ### Usage example for TplinkDecoE4RRouter Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/deco.md Shows how to instantiate the router, authorize, fetch firmware info, and log out. ```python from tplinkrouterc6u import TplinkDecoE4RRouter router = TplinkDecoE4RRouter('http://192.168.1.1', 'password') router.authorize() print(router.get_firmware()) router.logout() ``` -------------------------------- ### TPLinkSG108EClient usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Shows how to instantiate the client, authorize, retrieve port status, get LED status, and logout. Requires the tplinkrouterc6u library and a valid router URL and password. ```python from tplinkrouterc6u import TPLinkSG108EClient router = TPLinkSG108EClient('http://192.168.1.1', 'password') router.authorize() for port in router.get_port_status(): print(port.port, port.link_up, port.negotiated_speed, port.tx_good_packets) print(router.led_status()) router.logout() ``` -------------------------------- ### TplinkWDRRouter usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/wdr.md Example of creating a router instance and retrieving firmware and client information. Requires the tplinkrouterc6u library. ```python from tplinkrouterc6u import TplinkWDRRouter router = TplinkWDRRouter('http://192.168.1.1', 'password') print(router.get_firmware()) router.update('all') print(router.get_clients()) ``` -------------------------------- ### Usage example: importing and calling helper functions Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/helper.md Shows how to import and use get_ip, get_ipv6, get_mac, and get_value with sample inputs and expected outputs. ```python from tplinkrouterc6u.common.helper import get_ip, get_ipv6, get_mac, get_value ip = get_ip('192.168.1.1') # IPv4Address('192.168.1.1') ip6 = get_ipv6('not-an-ip') # IPv6Address('::') mac = get_mac('AA-BB-CC-DD-EE-FF') # EUI48('AA:BB:CC:DD:EE:FF') payload = {'wan': {'ip_info': {'mac': '00:11:22:33:44:55'}}} mac_str = get_value(payload, ['wan', 'ip_info', 'mac'], '') # '00:11:22:33:44:55' missing = get_value(payload, ['wan', 'nope'], None) # None ``` -------------------------------- ### Usage pattern from README Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c6u.md Example of using the TplinkRouter class to authorize, get status, and enable guest WiFi. ```python from tplinkrouterc6u import TplinkRouter with TplinkRouter('192.168.0.1', 'password') as router: router.authorize() status = router.get_status() if not status.guest_2g_enable: router.set_wifi(Connection.GUEST_2G, True) ``` -------------------------------- ### Import and use TplinkRouterProvider with various client classes Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/README.md Shows how to import the library and use the provider to get a client for your router. The provider picks a matching client automatically. You can also instantiate a client class directly, optionally passing a username and logger. Some routers require a web encrypted password instead of the normal password. Always call authorize() before actions and logout() after, or use 'with router:' to handle it automatically. ```python from tplinkrouterc6u import ( TplinkRouterProvider, TplinkRouterV1_11, TplinkRouterSG, # For routers like Archer BE3600, Archer BE230 TplinkRouterAX72, TplinkRouter, TplinkC1200Router, TplinkC5400XRouter, TPLinkMRClient, # Class for MR series routers which supports old firmwares with AES cipher CBC mode TPLinkMRClientGCM, # Class for MR series routers which supports AES cipher GCM mode TPLinkMR200Client, TPLinkMR6400v7Client, TPLinkMR600Client, # Class for MR series that replaced the RSA key exchange with ECIES over NIST P-224 TPLinkVRClient, TPLinkVR400v2Client, TplinkVR1200vRouter, TPLinkEXClient, # Class for EX series routers which supports old firmwares with AES cipher CBC mode TPLinkEXClientGCM, # Class for EX series routers which supports AES cipher GCM mode TPLinkEXClientGCMOAEP, # EX GCM + RSA-OAEP signatures (e.g. EX920) TPLinkRClient, # For routers like TL-R470GP-AC TPLinkXDRClient, TPLinkDecoClient, TplinkDecoE4RRouter, TPLinkEAP115Client, TPLinkCPE210Client, TPLinkSG108EClient, TplinkC80Router, TplinkWDRRouter, TPLinkC50Client, TPLinkWR841NClient, TplinkRE330Router, TplinkRE813XERouter, TplinkRe700XRouter, # alias of TplinkRE813XERouter TplinkC3200Router, Connection ) from logging import Logger import traceback # Prefer the provider: it picks a matching client for your router router = TplinkRouterProvider.get_client('http://192.168.0.1', 'password') logger = Logger('test') # You may use a client class directly, e.g.: # router = TplinkRouter('http://192.168.0.1', 'password') # You may also pass username if it is different and a logger to log errors as # router = TplinkRouter('http://192.168.0.1', 'password', 'admin2', logger=logger) # C5400X / RE813XE / RE700X / similar: use web encrypted password (see Web Encrypted Password below) # router = TplinkC5400XRouter('http://192.168.0.1', 'WebEncryptedPassword', logger=logger) # router = TplinkRE813XERouter('http://192.168.0.1', 'WebEncryptedPassword', logger=logger) try: # Or: with router: # authorize on enter, logout on exit router.authorize() # Get firmware info - returns Firmware firmware = router.get_firmware() # Get status info - returns Status status = router.get_status() if not status.guest_2g_enable: # check if guest 2.4G wifi is disable router.set_wifi(Connection.GUEST_2G, True) # turn on guest 2.4G wifi # Get IPv6 status (not implemented on every client → NotImplementedError) try: ipv6_status = router.get_ipv6_status() print(ipv6_status.wan_ipv6_addr, ipv6_status.wan_ipv6_gateway) except NotImplementedError: pass # Get EasyMesh nodes (empty list when the router runs no mesh) try: for node in router.get_mesh_nodes(): print(f"{node.name:24} {node.model:16} {node.macaddr} {node.ipaddr:16s} " f"{node.role:16} clients={node.client_num}") except NotImplementedError: pass # Optional methods (not on every client) try: reservations = router.get_ipv4_reservations() reservations.sort(key=lambda a: a.ipaddr) for res in reservations: print(f"{res.macaddr} {res.ipaddr:16s} {res.hostname:36} {'Permanent':12}") except (AttributeError, NotImplementedError): pass try: leases = router.get_ipv4_dhcp_leases() leases.sort(key=lambda a: a.ipaddr) for lease in leases: print(f"{lease.macaddr} {lease.ipaddr:16s} {lease.hostname:36} {lease.lease_time:12}") except (AttributeError, NotImplementedError): pass router.logout() # always logout; TP-Link Web Interface only supports up to 1 user logged in except Exception as e: logger.error(traceback.format_exc()) ``` -------------------------------- ### Usage example: get_clients Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/provider.md Retrieves the client classes and prints the class for 'TplinkRouter'. ```python clients = TplinkRouterProvider.get_clients() print(clients['TplinkRouter']) # tplinkrouterc6u.client.c6u.TplinkRouter ``` -------------------------------- ### Usage example for TPLinkCPE210Client and TPLinkEAP115Client Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/cpe-eap.md Shows how to instantiate and use both clients: authorize, fetch firmware/status, and logout. Note that EAP115 does not support reboot or WiFi configuration. ```python from tplinkrouterc6u import TPLinkCPE210Client, TPLinkEAP115Client cpe = TPLinkCPE210Client('http://192.168.1.2', 'password') cpe.authorize() print(cpe.get_firmware().firmware_version) cpe.logout() eap = TPLinkEAP115Client('http://192.168.1.3', 'password') eap.authorize() print(len(eap.get_status().devices)) eap.logout() ``` -------------------------------- ### TPLinkMRClient usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/mr.md Example of using the production MR client to authorize, get status, disable 5G Wi-Fi, and logout. Requires a router at the given host with the provided password. ```python from tplinkrouterc6u import TPLinkMRClient, Connection router = TPLinkMRClient('http://192.168.1.1', 'password', username='admin') router.authorize() status = router.get_status() print(status.wifi_2g_enable, status.clients_total) router.set_wifi(Connection.HOST_5G, False) router.logout() ``` -------------------------------- ### Using TPLinkEXClientGCMOAEP to get LTE serving cells Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/ex.md Example usage of TPLinkEXClientGCMOAEP: create client, authorize, iterate over LTE serving cells, print band and RSRP, then logout. ```python from tplinkrouterc6u import TPLinkEXClientGCMOAEP router = TPLinkEXClientGCMOAEP('http://192.168.1.1', 'password', username='user') router.authorize() for cell in router.get_lte_serving_cells(): print(cell.band, cell.rsrp) router.logout() ``` -------------------------------- ### Usage example for TPLinkC50Client and TPLinkWR841NClient Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c50-wr841.md Shows how to instantiate both clients, authorize, fetch status or firmware, and logout. The C50 client uses PKCS#1 v1.5 signatures; the WR841N client uses raw RSA. ```python from tplinkrouterc6u import TPLinkC50Client, TPLinkWR841NClient router = TPLinkC50Client('http://192.168.1.1', 'password') router.authorize() status = router.get_status() print(status.wifi_2g_enable) router.logout() w = TPLinkWR841NClient('http://192.168.1.1', 'password') w.authorize() print(w.get_firmware()) w.logout() ``` -------------------------------- ### TplinkRouterV1_11 usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c6u.md Example of using TplinkRouterV1_11 to authorize, fetch firmware, and logout. The authorize() method performs RSA-only authentication (no AES wrapper) and raises ClientException on login failure. The example disables SSL verification and catches ClientException to print an authentication error. ```python from tplinkrouterc6u import TplinkRouterV1_11 from tplinkrouterc6u.common.exception import ClientException router = TplinkRouterV1_11('http://192.168.0.1', 'password', verify_ssl=False) try: router.authorize() print(router.get_firmware()) router.logout() except ClientException as e: print('auth failed:', e) ``` -------------------------------- ### TplinkRouterSG usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/luci-gateway-devices.md Shows how to instantiate TplinkRouterSG, authorize, fetch IPv6 status, and logout. Requires a valid host and password. ```python from tplinkrouterc6u import TplinkRouterSG router = TplinkRouterSG('http://192.168.0.1', 'password') router.authorize() print(router.get_ipv6_status().wan_ipv6_addr) router.logout() ``` -------------------------------- ### Usage example for TplinkC80Router and TplinkRE330Router Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/code-protocol.md Demonstrates the primary workflow for both router classes: instantiate, authorize, perform a status query, toggle a setting, and logout. Requires the tplinkrouterc6u package and valid router credentials. ```python from tplinkrouterc6u import TplinkC80Router, TplinkRE330Router, Connection c80 = TplinkC80Router('http://192.168.1.1', 'password') c80.authorize() print(c80.get_ipv6_status().wan_ipv6_addr) c80.set_wifi(Connection.HOST_5G, False) c80.logout() re330 = TplinkRE330Router('http://192.168.1.1', 'password') re330.authorize() print(re330.get_led_status()) re330.set_led_status(False) re330.logout() ``` -------------------------------- ### TPLinkSG108EClient.authorize() Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Authenticates with the switch by GETting the root page and POSTing login credentials to /logon.cgi. Raises AuthorizeError on failure. ```APIDOC ## TPLinkSG108EClient.authorize() ### Description Authenticates with the switch by GETting the root page and POSTing login credentials to /logon.cgi. Raises AuthorizeError on failure. ### Method POST ### Endpoint `/logon.cgi` ### Signature ```python def authorize() -> None: ``` ### Parameters None ### Request Body - **username** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. - **cpassword** (string) - Required - Confirmation password (empty string). - **logon** (string) - Required - The login action ("Login"). ### Request Example ```json { "username": "admin", "password": "secret", "cpassword": "", "logon": "Login" } ``` ### Response #### Success Response (200) No response body. #### Error Responses - **AuthorizeError** - Raised when connection fails or login fails. ``` -------------------------------- ### TPLinkSG108EClient._get_vars() Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Internal helper to GET a page and parse script variables. Raises ClientError on non-200 response. ```APIDOC ## TPLinkSG108EClient._get_vars() ### Description Internal helper to GET a page and parse script variables. Raises ClientError on non-200 response. ### Method GET ### Signature ```python def _get_vars(path: str, params: dict | None = None) -> dict: ``` ### Parameters - **path** (str) - Required - The path to GET. - **params** (dict | None) - Optional - Query parameters to include. ### Returns - **dict** - Dictionary of parsed script variables (excluding 'tip' key). ### Error Responses - **ClientError** - Raised when response status is not 200. ``` -------------------------------- ### TplinkRE813XERouter usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/luci-gateway-devices.md Example of authorizing, fetching Wi-Fi status, and disabling a host band. Uses the Connection enum for band selection. ```python from tplinkrouterc6u import TplinkRE813XERouter from tplinkrouterc6u.common.package_enum import Connection router = TplinkRE813XERouter('http://192.168.0.1', 'password') router.authorize() wifi = router.get_wifi(Connection.HOST_5G) print(wifi.enable, wifi.ssid, wifi.channel) router.set_wifi(Connection.HOST_5G, enable=False) router.logout() ``` -------------------------------- ### TPLinkSG108EClient.set_led() Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Sets the LED state by GETting /led_on_set.cgi with the desired state. ```APIDOC ## TPLinkSG108EClient.set_led() ### Description Sets the LED state by GETting /led_on_set.cgi with the desired state. ### Method GET ### Endpoint `/led_on_set.cgi` ### Signature ```python def set_led(enable: bool) -> bool: ``` ### Parameters - **enable** (bool) - Required - True to turn LED on, False to turn off. ### Query Parameters - **rd_led** (integer) - Required - 1 if enable is True, 0 otherwise. - **led_cfg** (string) - Required - The apply action ("Apply"). ### Request Example ``` GET /led_on_set.cgi?rd_led=1&led_cfg=Apply ``` ### Returns - **bool** - The new LED state. ``` -------------------------------- ### TPLinkRClient usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/xdr.md Shows how to instantiate TPLinkRClient, authorize, disable the guest 5G Wi-Fi, and logout. Requires a router like the TL-R470GP-AC and a valid password. ```python from tplinkrouterc6u import TPLinkRClient, Connection router = TPLinkRClient('http://192.168.1.1', 'password') router.authorize() router.set_wifi(Connection.GUEST_5G, False) router.logout() ``` -------------------------------- ### Usage example: get_client with error handling Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/provider.md Usage with custom username, logger, verify_ssl=False, and timeout=10, catching ClientException. The exception message hints at using the web-encrypted password for C5400X-class routers. ```python from tplinkrouterc6u import TplinkRouterProvider from tplinkrouterc6u.common.exception import ClientException from logging import Logger logger = Logger('app') try: router = TplinkRouterProvider.get_client('192.168.0.1', 'wrong-password', username='user', logger=logger, verify_ssl=False, timeout=10) router.authorize() except ClientException as e: # Message hints at using the web-encrypted password for C5400X-class routers. print('Login failed:', e) ``` -------------------------------- ### EncryptionWrapper usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/encryption.md Demonstrates basic usage of the EncryptionWrapper class: encrypting a string, decrypting it, and generating a signature. The get_signature call requires an MD5 hash and ECC public key values (nn, ee) that are not defined in the snippet. ```python from tplinkrouterc6u.common.encryption import EncryptionWrapper w = EncryptionWrapper() ct = w.aes_encrypt('operation=read') plain = w.aes_decrypt(ct) sign = w.get_signature(1234, True, md5_hash, nn, ee) ``` -------------------------------- ### _backup_get(path: str) -> bytes Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/backup-mixin.md Abstract hook for the authenticated GET request. The base implementation raises NotImplementedError. Subclasses must implement this method with their own authentication mechanism. The only current implementation is TplinkVR1200vRouter._backup_get, which sends the TokenID header and raises ClientException on non-200 responses. ```APIDOC ## _backup_get(path: str) -> bytes ### Description Performs the authenticated GET request to download the backup. ### Method _backup_get(path) ### Parameters - **path** (str) - Required - The backup path to request. ### Return - **bytes** - The raw backup data. ### Exceptions - **NotImplementedError** - Raised by the base class; subclasses must override. - **ClientException** - Raised on non-200 responses (e.g., 'Backup failed, status code: …'). ### Notes Subclasses must implement this method using their client's HTTP transport (token headers, stok, session, etc.). ``` -------------------------------- ### TPLinkXDRClient usage example Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/xdr.md Example usage: authorize, connect PPPoE, get status, disconnect, logout. ```python from tplinkrouterc6u import TPLinkXDRClient router = TPLinkXDRClient('http://192.168.1.1', 'password') router.authorize() router.pppoe_connect() status = router.get_status() router.pppoe_disconnect() router.logout() ``` -------------------------------- ### TplinkRouter initialization with all options Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/configuration.md Shows how to create a TplinkRouter instance with all available configuration options. The host is prefixed with http:// automatically, username defaults to 'admin' but should be 'user' for EX-series devices, verify_ssl=False disables TLS warnings, and timeout is in seconds per request. After construction, call authorize() to authenticate. ```python from logging import Logger from tplinkrouterc6u import TplinkRouter logger = Logger('app') router = TplinkRouter( host='192.168.0.1', # http:// is added automatically password='secret', username='admin', # 'user' for EX-series logger=logger, verify_ssl=False, # disable TLS warnings timeout=15, # seconds per request ) router.authorize() ``` -------------------------------- ### Using TplinkVR1200vRouter to backup configuration Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/ex.md Shows how to instantiate the router, authorize, and download the configuration backup. The backup is written to 'backup.bin'. ```python from tplinkrouterc6u import TplinkVR1200vRouter router = TplinkVR1200vRouter('http://192.168.1.1', 'password') router.authorize() backup = router.backup_config() # bytes of the router settings backup with open('backup.bin', 'wb') as f: f.write(backup) router.logout() ``` -------------------------------- ### Constructor signature Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/ex.md Initializes the EX client. Default username is 'user' (EX-series UIs reject 'admin'), and the RSA key URL is set to 'cgi/getGDPRParm'. ```python def __init__(self, host: str, password: str, username: str = 'user', logger: Logger = None, verify_ssl: bool = True, timeout: int = 30) -> None: ``` -------------------------------- ### _build_backup_path(firmware: Firmware) -> str Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/backup-mixin.md Builds the backup download path from firmware information. It matches the hardware version and firmware version against internal regexes to construct the path. Raises ClientException if the path cannot be built. ```APIDOC ## _build_backup_path(firmware: Firmware) -> str ### Description Builds the backup download path from firmware information. ### Method _build_backup_path(firmware) ### Parameters - **firmware** (Firmware) - Required - The firmware object containing hardware_version and firmware_version. ### Return - **str** - The backup path, e.g., `/cgi/ArcherVR1200vV12007142239n.bin?`. ### Exceptions - **ClientException** - Raised if the path cannot be built from the firmware info. ### Example For hardware `"Archer VR1200v V1"` and firmware `"1.0.0 Build 200714 Rel.2239n"`, returns `/cgi/ArcherVR1200vV12007142239n.bin?`. ``` -------------------------------- ### backup_config Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/README.md Downloads router settings backup as bytes. Only available on VR1200v; call authorize() first. ```APIDOC ## backup_config ### Description Download router settings backup as bytes (VR1200v only; call `authorize()` first). ### Method Function call ### Parameters None ### Return bytes ``` -------------------------------- ### TPLinkSG108EClient constructor Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Initializes the client with host, password, optional username, logger, SSL verification, and timeout. Strips trailing slash from host and creates a session with cached LAN MAC/IP flags. ```python def __init__(self, host: str, password: str, username: str = "admin", logger: Logger | None = None, verify_ssl: bool = True, timeout: int = 30) -> None: ``` -------------------------------- ### Run unit tests with unittest discover Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/README.md Executes all tests in the ./test directory using Python's built-in unittest module. ```bash python -m unittest discover ./test ``` -------------------------------- ### GET {host}/cgi/logout Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Logs out the current session and invalidates the token. ```APIDOC ## [GET] {host}/cgi/logout ### Description Logs out the current session and invalidates the token. ### Method GET ### Endpoint {host}/cgi/logout ### Authentication JSESSIONID cookie + TokenID header ### Response #### Success Response (200) - **body** (string) - Logout act reply #### Response Example ``` $.ret=0; ``` ``` -------------------------------- ### GET {host}/led_on_set.cgi Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Sets the LED state on SG108E switches. Requires a session cookie. ```APIDOC ## [GET] {host}/led_on_set.cgi ### Description Sets the LED state on SG108E switches. Requires a session cookie. ### Method GET ### Endpoint {host}/led_on_set.cgi?rd_led=0|1&led_cfg=Apply ### Headers - **Cookie** (string) - Required - The session cookie obtained from logon.cgi. ### Parameters #### Query Parameters - **rd_led** (integer) - Required - The LED state: 0 or 1. - **led_cfg** (string) - Required - Must be "Apply". ### Response #### Success Response (200) - **body** (HTML) - The response page HTML. #### Response Example ... ``` -------------------------------- ### GET {host}/SystemInfoRpm.htm Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Fetches system information for SG108E switches. Requires a session cookie. ```APIDOC ## [GET] {host}/SystemInfoRpm.htm ### Description Fetches system information for SG108E switches. Requires a session cookie. ### Method GET ### Endpoint {host}/SystemInfoRpm.htm ### Headers - **Cookie** (string) - Required - The session cookie obtained from logon.cgi. ### Response #### Success Response (200) - **body** (HTML) - The system information page HTML. #### Response Example ... ``` -------------------------------- ### TPLinkEXClientGCMOAEP.__init__ Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/ex.md Initializes the EX GCM client for firmwares that sign with RSA-OAEP. Sets default username to 'user' and swaps the session cipher for OAEP signature padding. ```APIDOC ## TPLinkEXClientGCMOAEP.__init__(host: str, password: str, username: str = 'user', logger: Logger = None, verify_ssl: bool = True, timeout: int = 30) -> None ### Description Initializes the EX GCM client for firmwares that sign with RSA-OAEP. Sets default username to 'user' and swaps the session cipher for OAEP signature padding. ### Parameters - **host** (str) - Required - The router's host URL. - **password** (str) - Required - The router's password. - **username** (str) - Optional - The username, defaults to 'user'. - **logger** (Logger) - Optional - A logger instance. - **verify_ssl** (bool) - Optional - Whether to verify SSL certificates, defaults to True. - **timeout** (int) - Optional - Timeout in seconds, defaults to 30. ### Example ```python from tplinkrouterc6u import TPLinkEXClientGCMOAEP router = TPLinkEXClientGCMOAEP('http://192.168.1.1', 'password', username='user') router.authorize() for cell in router.get_lte_serving_cells(): print(cell.band, cell.rsrp) router.logout() ``` ``` -------------------------------- ### GET {host}/userRpm/SysRebootHelpRpm.htm Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Reboots the WDR router. Requires Basic auth and a Referer header. ```APIDOC ## [GET] {host}/userRpm/SysRebootHelpRpm.htm ### Description Reboots the WDR router. Requires Basic auth and a Referer header. ### Method GET ### Endpoint {host}/userRpm/SysRebootHelpRpm.htm?Reboot=Reboot ### Headers - **Authorization** (string) - Required - Basic authentication header. - **Referer** (string) - Required - Must be {host}/userRpm/MenuRpm.htm. ### Parameters #### Query Parameters - **Reboot** (string) - Required - Must be "Reboot" to trigger reboot. ### Response #### Success Response (200) - **body** (HTML) - The reboot confirmation page HTML. #### Response Example ... ``` -------------------------------- ### TplinkBaseRouter.__init__(host, password, username='admin', logger=None, verify_ssl=True, timeout=30) Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c6u.md Initializes the router client with connection parameters and sets internal endpoint URLs and headers. This constructor is the entry point for all read/write operations on LuCI-based TP-Link routers. ```APIDOC ## Constructor: TplinkBaseRouter.__init__ ### Description Initializes the router client with connection parameters and sets internal endpoint URLs and headers. This constructor is the entry point for all read/write operations on LuCI-based TP-Link routers. ### Parameters - **host** (str) - Required - Router IP address or hostname - **password** (str) - Required - Router admin password - **username** (str) - Optional - Default: 'admin' - **logger** (Logger) - Optional - Logger instance - **verify_ssl** (bool) - Optional - Default: True - **timeout** (int) - Optional - Default: 30 ### Returns None ``` -------------------------------- ### GET {host}/userRpm/FixMapCfgRpm.htm Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Fetches reservations for WDR routers. Requires Basic auth and a Referer header. ```APIDOC ## [GET] {host}/userRpm/FixMapCfgRpm.htm ### Description Fetches reservations for WDR routers. Requires Basic auth and a Referer header. ### Method GET ### Endpoint {host}/userRpm/FixMapCfgRpm.htm ### Headers - **Authorization** (string) - Required - Basic authentication header. - **Referer** (string) - Required - Must be {host}/userRpm/MenuRpm.htm. ### Response #### Success Response (200) - **body** (HTML) - The reservations page HTML. #### Response Example ... ``` -------------------------------- ### TPLinkSG108EClient.__init__ Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/sg108e.md Initializes the client for the TL-SG108E switch. Strips trailing slash from host, creates a session, and sets up internal state. ```APIDOC ## TPLinkSG108EClient.__init__ ### Description Initializes the client for the TL-SG108E switch. Strips trailing slash from host, creates a session, and sets up internal state. ### Method Constructor ### Signature ```python def __init__(self, host: str, password: str, username: str = "admin", logger: Logger | None = None, verify_ssl: bool = True, timeout: int = 30) -> None: ``` ### Parameters - **host** (str) - Required - The hostname or IP address of the switch. - **password** (str) - Required - The password for authentication. - **username** (str) - Optional - The username for authentication (default: "admin"). - **logger** (Logger | None) - Optional - A logger instance for logging. - **verify_ssl** (bool) - Optional - Whether to verify SSL certificates (default: True). - **timeout** (int) - Optional - Timeout in seconds for requests (default: 30). ### Returns None ``` -------------------------------- ### backup_config() -> bytes Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/backup-mixin.md Public entry point that downloads the router configuration backup. It calls get_firmware(), derives the backup path, and delegates the authenticated download to _backup_get(). Returns the raw configuration backup as bytes. Requires an active session; the VR1200v implementation raises ClientException('Not authorized') if called before authorize(). ```APIDOC ## backup_config() -> bytes ### Description Downloads the router configuration backup as raw bytes. ### Method backup_config() ### Parameters None ### Return - **bytes** - The raw router configuration backup. ### Exceptions - **ClientException** - Raised if not authorized (e.g., 'Not authorized') or if the backup download fails. ### Usage Example ```python from tplinkrouterc6u import TplinkVR1200vRouter from tplinkrouterc6u.common.exception import ClientException router = TplinkVR1200vRouter('http://192.168.1.1', 'password') router.authorize() try: backup = router.backup_config() with open('router-backup.bin', 'wb') as f: f.write(backup) except ClientException as e: print('download failed:', e) finally: router.logout() ``` ``` -------------------------------- ### GET {host}/data/version.json Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Fetches version information for CPE210 devices. Requires a session cookie and X-Requested-With header. ```APIDOC ## [GET] {host}/data/version.json ### Description Fetches version information for CPE210 devices. Requires a session cookie and X-Requested-With header. ### Method GET ### Endpoint {host}/data/version.json ### Headers - **Cookie** (string) - Required - The session cookie. - **X-Requested-With** (string) - Required - Must be "XMLHttpRequest". ### Response #### Success Response (200) - **success** (boolean) - Whether the request was successful. - **data** (object) - The version data. - **timeout** (boolean) - Whether the session timed out. #### Response Example { "success": true, "data": {}, "timeout": false } ``` -------------------------------- ### GET {host}/userRpm/AssignedIpAddrListRpm.htm Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Fetches DHCP leases for WDR routers. Requires Basic auth and a Referer header. ```APIDOC ## [GET] {host}/userRpm/AssignedIpAddrListRpm.htm ### Description Fetches DHCP leases for WDR routers. Requires Basic auth and a Referer header. ### Method GET ### Endpoint {host}/userRpm/AssignedIpAddrListRpm.htm ### Headers - **Authorization** (string) - Required - Basic authentication header. - **Referer** (string) - Required - Must be {host}/userRpm/MenuRpm.htm. ### Response #### Success Response (200) - **body** (HTML) - The DHCP leases page HTML. #### Response Example ... ``` -------------------------------- ### set_wifi(wifi, enable=None, ssid=None, hidden=None, encryption=None, psk_version=None, psk_cipher=None, psk_key=None, hwmode=None, htmode=None, channel=None, txpower=None, disabled_all=None, portal_password=None) Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/luci-gateway-devices.md Configures Wi-Fi settings for a given band (host or guest). For guest bands, writes guest settings; for host bands, writes wireless configuration. ```APIDOC ## set_wifi(wifi, enable=None, ssid=None, hidden=None, encryption=None, psk_version=None, psk_cipher=None, psk_key=None, hwmode=None, htmode=None, channel=None, txpower=None, disabled_all=None, portal_password=None) ### Description Configures Wi-Fi settings for a given band (host or guest). For guest bands, writes guest settings; for host bands, writes wireless configuration. ### Method set_wifi ### Parameters - **wifi** (Connection) - Required - The Wi-Fi band to configure (e.g., Connection.HOST_5G). - **enable** (bool) - Optional - Whether to enable the Wi-Fi. - **ssid** (str) - Optional - The SSID to set. - **hidden** (bool) - Optional - Whether to hide the SSID. - **encryption** (str) - Optional - The encryption type. - **psk_version** (str) - Optional - The PSK version. - **psk_cipher** (str) - Optional - The PSK cipher. - **psk_key** (str) - Optional - The PSK key. - **hwmode** (str) - Optional - The hardware mode. - **htmode** (str) - Optional - The HT mode. - **channel** (int) - Optional - The channel number. - **txpower** (int) - Optional - The transmit power. - **disabled_all** (bool) - Optional - Inverse of enable; if True, disables the Wi-Fi. - **portal_password** (str) - Optional - The portal password for guest networks. ### Response None. Raises ValueError for invalid/unsupported types or empty kwargs. ``` -------------------------------- ### GET {host}/login.htm Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Probes the R-series router by fetching the login page. The response is HTML containing 'TL-R'. ```APIDOC ## [GET] {host}/login.htm ### Description Probes the R-series router by fetching the login page. The response is HTML containing 'TL-R'. ### Method GET ### Endpoint {host}/login.htm ### Response #### Success Response (200) - **body** (HTML) - The HTML content containing 'TL-R'. #### Response Example ...TL-R... ``` -------------------------------- ### set_wifi(wifi, enable=None, ssid=None, hidden=None, encryption=None, psk_version=None, psk_cipher=None, psk_key=None, hwmode=None, htmode=None, channel=None, txpower=None, disabled_all=None, portal_password=None) -> None Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c6u.md Configures Wi-Fi settings for a given connection (e.g., 2.4GHz, 5GHz, guest networks). Maps the Connection enum to the appropriate form ID and sends a write request to the router's wireless endpoint. ```APIDOC ## Method: set_wifi ### Description Configures Wi-Fi settings for a given connection (e.g., 2.4GHz, 5GHz, guest networks). Maps the Connection enum to the appropriate form ID and sends a write request to the router's wireless endpoint. ### Parameters - **wifi** (Connection) - Required - The Wi-Fi band/network to configure - **enable** (bool) - Optional - Enable/disable the Wi-Fi - **ssid** (str) - Optional - SSID name - **hidden** (bool) - Optional - Hide SSID - **encryption** (str) - Optional - Encryption type - **psk_version** (str) - Optional - PSK version - **psk_cipher** (str) - Optional - PSK cipher - **psk_key** (str) - Optional - PSK key/password - **hwmode** (str) - Optional - Hardware mode - **htmode** (str) - Optional - HT mode - **channel** (int) - Optional - Channel number - **txpower** (int) - Optional - Transmit power - **disabled_all** (bool) - Optional - Disable all Wi-Fi - **portal_password** (str) - Optional - Portal password ### Returns None ### Errors - Raises `ValueError` for unsupported Connection or when all parameters are None. ``` -------------------------------- ### TPLinkC50Client constructor Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/c50-wr841.md Initializes the client with host, password, optional username, logger, SSL verification, and timeout. Creates its own Session and initializes crypto state slots to None until authorize() is called. ```python def __init__(self, host: str, password: str, username: str = "admin", logger: Logger = None, verify_ssl: bool = True, timeout: int = 30) -> None: ``` -------------------------------- ### GET {host}/ Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/endpoints.md Fetches the index page to obtain a session token. The token is required for subsequent authenticated requests. ```APIDOC ## [GET] {host}/ ### Description Fetches the index page to obtain a session token. The token is required for subsequent authenticated requests. ### Method GET ### Endpoint {host}/ ### Authentication None ### Response #### Success Response (200) - **body** (HTML) - Index page containing `var token="…";` #### Response Example ```html … var token="…"; … ``` ``` -------------------------------- ### ClientException raised when backup path cannot be built Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/backup-mixin.md Raised by _build_backup_path when the hardware or firmware version strings do not match the private regexes. The message includes the raw hardware and firmware version values. ```python ClientException('Unable to build backup path from firmware info: {} / {}'.format( firmware.hardware_version, firmware.firmware_version)) ``` -------------------------------- ### TPLinkXDRClient.supports Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/xdr.md Checks if the router is supported by this client by GETting the host root and checking if the page text contains any supported series entry. ```APIDOC ## TPLinkXDRClient.supports ### Description Checks if the router is supported by this client by GETting the host root and checking if the page text contains any supported series entry. ### Method supports ### Signature ```python def supports() -> bool: ``` ### Parameters None ### Returns - **bool** - True if the router is supported, False otherwise. ``` -------------------------------- ### TPLinkCPE210Client._post_data / _get_data Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/cpe-eap.md Internal methods for POST and GET requests to data endpoints. They handle nonce, error checking, and session timeout. ```APIDOC ## _post_data(data, path) / _get_data(path, **params) ### Description Internal methods for POST and GET requests to data endpoints. ### Method _post_data / _get_data ### Endpoint N/A (Python methods) ### Parameters - **path** (str) - Required - The endpoint path. - **data** (dict) - Required for _post_data - The data to post. - **params** (dict) - Optional for _get_data - Query parameters. ### Request Example ```python client._post_data(data={"key": "value"}, path="/data/example.json") client._get_data(path="/data/example.json", operation="load") ``` ### Response - **dict** - The data payload from the response. ``` -------------------------------- ### TPLinkEAP115Client.__init__ Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/_autodocs/api-reference/cpe-eap.md Constructor for the TPLinkEAP115Client class. Initializes the client with host, credentials, and optional settings. ```APIDOC ## Constructor ### Description Initializes a new TPLinkEAP115Client instance. ### Method Constructor ### Signature ```python def __init__(self, host: str, password: str, username: str = "admin", logger: Logger = None, verify_ssl: bool = True, timeout: int = 30) -> None: ``` ### Parameters - **host** (str) - Required - The base URL of the router. - **password** (str) - Required - The password for authentication. - **username** (str) - Optional - The username for authentication (default: "admin"). - **logger** (Logger) - Optional - A logger instance for logging. - **verify_ssl** (bool) - Optional - Whether to verify SSL certificates (default: True). - **timeout** (int) - Optional - Timeout in seconds for requests (default: 30). ### Notes Strips trailing slash from host and sets Referer header. ``` -------------------------------- ### get_firmware Source: https://github.com/alexandrerohin/tp-link-archer-c6u/blob/main/README.md Retrieves firmware information about the router. ```APIDOC ## get_firmware ### Description Gets firmware info about the router. ### Method Function call ### Parameters None ### Return [Firmware](#firmware) ```