AlexandrErohin / TP-Link-Archer-C6U

Python package for API access and management for TP-Link Routers. See supported routers list
GNU General Public License v3.0
43 stars 14 forks source link

Signal strength data #14

Open fayeinmay opened 7 months ago

fayeinmay commented 7 months ago

Hi,

I was wondering if it is possible to get the signal strength data of wifi devices somehow?

image

AlexandrErohin commented 7 months ago

Hi Could you check what route is used to open this router's page? go to browser's Inspect window > Network tab

fayeinmay commented 7 months ago

I think by route you're referring to the URL? It would be http://192.168.0.1/webpages/index.html?t=ea3f7fe8#networkMap

image

AlexandrErohin commented 7 months ago

Could you clear logs, select XHR and again go to wifi clients page?

fayeinmay commented 7 months ago

image

AlexandrErohin commented 7 months ago

could you run this script and post the results?

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/smart_network?form=game_accelerator'))
print('---')
print(client.request('admin/wireless?form=statistics'))
fayeinmay commented 7 months ago

Seems like it's not the game_accelerator stuff.

None
---
[{'mac': 'E8-6B-EA-E2-FE-54', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 1053459, 'txpkts': 12850}, {'mac': 'B4-6D-C2-C5-56-29', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 41330698, 'txpkts': 82594429}, {'mac': 'C8-C9-A3-25-73-77', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 1048029, 'txpkts': 1151859}, {'mac': '00-20-00-D0-68-84', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 1056904, 'txpkts': 19688}, {'mac': 'C4-3C-B0-62-FF-50', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 5126109, 'txpkts': 8288635}, {'mac': 'D8-C0-A6-D5-B4-65', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 1071864, 'txpkts': 25588}, {'mac': '48-55-19-D9-54-EA', 'type': '2.4GHz', 'encryption': 'none', 'rxpkts': 1048167, 'txpkts': 1310477}, {'mac': '38-42-0B-9A-96-6E', 'type': '5GHz', 'encryption': 'none', 'rxpkts': 1106431, 'txpkts': 359367}, {'mac': '48-22-54-1C-48-E0', 'type': '5GHz', 'encryption': 'none', 'rxpkts': 1386410, 'txpkts': 118530}, {'mac': '72-63-88-15-2E-D3', 'type': '5GHz', 'encryption': 'none', 'rxpkts': 1069875, 'txpkts': 24724}]
AlexandrErohin commented 7 months ago

Could you post the request to admin/smart_network?form=game_accelerator that you catched in browser? In screenshot you have opened Headers, please copy info from Request tab

fayeinmay commented 7 months ago

sign=5406c3ae9f55dde5d205d1216c539fc2a74143444c6e1a37976f586a45bc3ba309da8493d3365fc0f51ce48b092e078d7cbe992c55493b3c5968897b1dd36b57&data=dYR8YXE6DmK6a6QQn2UyNqYhTcxRrLDnhuwP3HOK4o0=

AlexandrErohin commented 7 months ago

there is the wrong characters in the end of your string

fayeinmay commented 7 months ago

Weird. I corrected the comment.

AlexandrErohin commented 7 months ago

Try this one

from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/smart_network?form=game_accelerator', 'operation=load')
fayeinmay commented 7 months ago

Output was None

gordonaspin commented 7 months ago

you need "operation=loadDevice"


from tplinkrouterc6u import TplinkRouter
from logging import Logger

client = TplinkRouter('192.168.0.1', 'yourPassword', logger=Logger('test'))
client.authorize()
print(client.request('admin/smart_network?form=game_accelerator', 'operation=loadDevice')

it returns an array:

[{
        "index": 22,
        "trafficUsage": 12581880,
        "deviceType": "other",
        "remainTime": 0,
        "deviceName": "device-name",
        "key": "446132B6F7CE",
        "uploadSpeed": 0,
        "onlineTime": 164152.82,
        "mac": "44-61-32-B6-F7-CE",
        "downloadSpeed": 0,
        "enablePriority": False,
        "txrate": 433333,
        "ip": "192.168.0.219",
        "rxrate": 433333,
        "timePeriod": -1,
        "deviceTag": "5G",
        "signal": -52
    },
]
AlexandrErohin commented 7 months ago

@gordonaspin Thank you!

gordonaspin commented 7 months ago

It's a pain. You have to decode the operation. The way I do it is put a breakpoint on the XHR matching the URL and a breakpoint on the decryptData function and use the console to call the decryptData function with the encrypted post data. Is there a better way ? I was thinking maybe to write a proxy server as a man-in-the-middle.

AlexandrErohin commented 7 months ago

@gordonaspin yeah, I do the same