WLAN-Pi / wlanpi-core

wlanpi-core provides a way to share data between core services and applications on the WLAN Pi.
BSD 3-Clause "New" or "Revised" License
2 stars 6 forks source link

API For Wi-Fi Channel Scanning #9

Open JudahZF opened 3 months ago

JudahZF commented 3 months ago

Hi There,

I'm building some software for Wi-Fi monitoring at events, and the wlan pi looks like a great tool. Will there ever be an API to get the results of a Wi-Fi scan. I understand the data goes into Grafana, but I can't find any way of getting it out and into another system (although I may have missed it). I am happy to work on a PR to add this if it seems like a good idea? Would it be best placed here with the API or in the Grafana repo with the nlscan app?

Thanks, Judah

joshschmelzle commented 2 months ago

Hey Judah, currently, the wlanpi-core API services are not externally exposed by default and are currently primarily used for RPC between the frontend and backend. I think the right approach would be some (new) API service similar to wlanpi-core, but on an exposed port with some sort of self service token management (perhaps CLI first but eventually in the webui as well). I don't think that the grafana repo is the right place for this. How do you imagine receiving the scan data in your software? Do you need information elements parsed and passed back to you in JSON or can you accept raw information elements?

joshschmelzle commented 2 months ago

We are also already working on changes to allow the WebUI to get and display scan results.

JudahZF commented 2 months ago

Hi Josh, Thanks for the reply. I think JSON data would be the ideal, but I would probably be able to work with most types of data transfer, as I am building individual services to handle the data from each system I plan on working with. Would the best approach be to start working on something like this myself that can then be an add on or moved into wlan pi, or wait for the project to have a repo / idea of how this would work and then contribute?

joshschmelzle commented 2 months ago

I would wait so that we don't duplicate efforts with different implementations.

joshschmelzle commented 2 months ago

@JudahZF the latest version of core has scanning capabilities.

Usage examples:

curl -X 'GET' \
  'http://<IP>:8000/api/v1/network/wlan/scan?type=active&interface=<INTERFACE>&timeout=20' \
  -H 'accept: application/json'
http://<IP>:<PORT>/api/v1/network/wlan/scan?type=active&interface=<INTERFACE>&timeout=20

Output response example:

{
    "nets": [
        {
            "ssid": "SSID_1",
            "bssid": "02:d1:37:56:78:9a",
            "key_mgmt": "wpa-eap/wpa-eap-sha256",
            "signal": -44,
            "freq": 5580,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_2",
            "bssid": "02:4d:7b:9c:3d:11",
            "key_mgmt": "wpa-psk/sae",
            "signal": -45,
            "freq": 5180,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_3",
            "bssid": "02:3e:8c:25:bd:2f",
            "key_mgmt": "wpa-psk/sae",
            "signal": -39,
            "freq": 5180,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_4",
            "bssid": "02:17:fc:91:2a:7e",
            "key_mgmt": "wpa-psk/sae",
            "signal": -45,
            "freq": 5180,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_5",
            "bssid": "02:5b:ac:16:34:9f",
            "key_mgmt": "sae",
            "signal": -47,
            "freq": 5620,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_6",
            "bssid": "02:e6:39:7c:12:8a",
            "key_mgmt": "wpa-eap-suite-b-192",
            "signal": -47,
            "freq": 5620,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_7",
            "bssid": "02:bc:df:3e:5f:73",
            "key_mgmt": "wpa-ft-eap/wpa-eap-sha256",
            "signal": -47,
            "freq": 5620,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_8",
            "bssid": "02:8a:9f:35:2b:1e",
            "key_mgmt": "wpa-ft-eap/wpa-eap-sha256",
            "signal": -47,
            "freq": 5620,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_9",
            "bssid": "02:cb:12:8f:37:6d",
            "key_mgmt": "wpa-eap",
            "signal": -54,
            "freq": 5805,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_10",
            "bssid": "02:f4:af:25:49:dc",
            "key_mgmt": "sae",
            "signal": -54,
            "freq": 5805,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_11",
            "bssid": "02:8d:93:72:68:3e",
            "key_mgmt": "owe",
            "signal": -54,
            "freq": 5805,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_12",
            "bssid": "02:1a:76:8e:2c:fa",
            "key_mgmt": "wpa-psk/wpa-ft-psk/sae/ft-sae",
            "signal": -70,
            "freq": 5320,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_13",
            "bssid": "02:e3:2d:43:bc:1f",
            "key_mgmt": "wpa-psk",
            "signal": -70,
            "freq": 5320,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_14",
            "bssid": "02:14:67:89:23:ae",
            "key_mgmt": "sae/ft-sae",
            "signal": -56,
            "freq": 5200,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_15",
            "bssid": "02:9b:8c:65:73:29",
            "key_mgmt": "wpa-eap-sha256",
            "signal": -56,
            "freq": 5200,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_16",
            "bssid": "02:4a:97:81:2f:5b",
            "key_mgmt": "wpa-ft-eap/wpa-eap-sha256",
            "signal": -88,
            "freq": 2462,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_17",
            "bssid": "02:ac:57:9e:46:9c",
            "key_mgmt": "wpa-ft-eap/wpa-eap-sha256",
            "signal": -35,
            "freq": 2462,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_18",
            "bssid": "02:f8:39:84:51:7d",
            "key_mgmt": "wpa-eap-suite-b-192",
            "signal": -41,
            "freq": 2462,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_19",
            "bssid": "02:c4:51:73:6e:9b",
            "key_mgmt": "wpa-eap",
            "signal": -44,
            "freq": 2412,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_20",
            "bssid": "02:73:9f:46:28:1c",
            "key_mgmt": "sae",
            "signal": -44,
            "freq": 2412,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_21",
            "bssid": "02:e9:5d:7b:92:4a",
            "key_mgmt": "owe",
            "signal": -44,
            "freq": 2412,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_22",
            "bssid": "02:98:21:46:53:9f",
            "key_mgmt": "wpa-eap-sha256",
            "signal": -49,
            "freq": 2462,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_23",
            "bssid": "02:4f:73:29:54:2c",
            "key_mgmt": "sae",
            "signal": -58,
            "freq": 5745,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_24",
            "bssid": "02:63:5b:48:3d:21",
            "key_mgmt": "",
            "signal": -38,
            "freq": 5180,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_25",
            "bssid": "02:ad:7e:93:4f:37",
            "key_mgmt": "",
            "signal": -34,
            "freq": 2412,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_26",
            "bssid": "02:1b:2e:6d:3e:9a",
            "key_mgmt": "wpa-psk",
            "signal": -73,
            "freq": 2412,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_27",
            "bssid": "02:72:3a:5e:39:8b",
            "key_mgmt": "sae",
            "signal": -41,
            "freq": 5975,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_28",
            "bssid": "02:86:49:5b:8f:13",
            "key_mgmt": "sae/ft-sae",
            "signal": -41,
            "freq": 5975,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_29",
            "bssid": "02:d9:2f:8b:7c:6e",
            "key_mgmt": "wpa-eap-sha256",
            "signal": -41,
            "freq": 5975,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_30",
            "bssid": "02:2c:5b:9a:7e:5d",
            "key_mgmt": "wpa-psk",
            "signal": -75,
            "freq": 2437,
            "minrate": 11000000
        },
        {
            "ssid": "SSID_31",
            "bssid": "02:46:39:2b:83:19",
            "key_mgmt": "wpa-psk",
            "signal": -87,
            "freq": 2437,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_32",
            "bssid": "02:94:71:2e:45:76",
            "key_mgmt": "",
            "signal": -78,
            "freq": 2437,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_33",
            "bssid": "02:8e:7a:95:1e:7f",
            "key_mgmt": "wpa-eap-suite-b-192",
            "signal": -49,
            "freq": 6455,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_34",
            "bssid": "02:7f:3e:1c:95:6a",
            "key_mgmt": "sae",
            "signal": -49,
            "freq": 6455,
            "minrate": 24000000
        },
        {
            "ssid": "SSID_35",
            "bssid": "02:45:92:36:28:4b",
            "key_mgmt": "wpa-ft-eap/wpa-eap-sha256",
            "signal": -49,
            "freq": 6455,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_36",
            "bssid": "02:d6:8f:5a:74:9c",
            "key_mgmt": "wpa-psk",
            "signal": -87,
            "freq": 5720,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_37",
            "bssid": "02:3c:7b:4a:96:23",
            "key_mgmt": "owe",
            "signal": -49,
            "freq": 6135,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_38",
            "bssid": "02:e2:8b:3d:95:12",
            "key_mgmt": "wpa-psk",
            "signal": -62,
            "freq": 5200,
            "minrate": 6000000
        },
        {
            "ssid": "SSID_39",
            "bssid": "02:47:9f:6d:13:5b",
            "key_mgmt": "wpa-psk",
            "signal": -77,
            "freq": 2437,
            "minrate": 11000000
        },
        {
            "ssid": "SSID_40",
            "bssid": "02:62:5f:7e:45:2c",
            "key_mgmt": "wpa-psk",
            "signal": -88,
            "freq": 2437,
            "minrate": 1000000
        },
        {
            "ssid": "SSID_41",
            "bssid": "02:9e:3f:6e:4c:8b",
            "key_mgmt": "wpa-psk",
            "signal": -90,
            "freq": 2437,
            "minrate": 1000000
        }
    ]
}

What changes might you want to see in the output?

JudahZF commented 2 months ago

Looks good. It would be useful to be able to see the Channel width as well if possible, as this would give a good environment overview.

joshschmelzle commented 2 months ago

@bentumbler @Orbitix can either of you handle tackling adding channel width to the v1/network/wlan/scan endpoint response?

bentumbler commented 1 month ago

yes. I'll schedule this in during this week