Как я получаю доступный Wi-Fi APS и их мощность сигнала в .NET?

Здесь у вас есть одна версия, использующая Reduce () и Object.assign () :

const input = [
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 1, value: 3},
    {index: 1, value: 3},
    {index: 2, value: 3},
    {index: 2, value: 3},
    {index: 0, value: 3}
];

let obj = input.reduce((res, curr) =>
{
    if (res[[curr.index]])
        res[[curr.index]].push(curr);
    else
        res = Object.assign({[curr.index]: [curr]}, res);

    return res;
}, {});

console.log(obj);
[ 116]

В предыдущем примере будут созданы группы всех объектов с одинаковым свойством index. Однако, если вы хотите разделить объекты полосами, которые имеют равные indexes, вы можете сделать это:

const input = [
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 1, value: 3},
    {index: 1, value: 3},
    {index: 2, value: 3},
    {index: 2, value: 3},
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 0, value: 3},
    {index: 2, value: 3},
    {index: 2, value: 3}
];

let obj = input.reduce((res, curr) =>
{
    if (curr.index === res.last)
        res.r[res.idx - 1].push(curr);
    else
    {
        res.r = Object.assign({[res.idx]: [curr]}, res.r);
        res.last = curr.index;
        res.idx = res.idx + 1;
    }

    return res;
}, {r: {}, idx: 0, last: null});

console.log(obj.r);

28
задан Community 23 May 2017 в 12:16
поделиться

5 ответов

Это - проект обертки с управляемым кодом в c# в http://www.codeplex.com/managedwifi

, Это поддерживает Windows Vista и XP SP2 (или более поздняя версия).

пример кода:

using NativeWifi;
using System;
using System.Text;

namespace WifiExample
{
    class Program
    {
        /// <summary>
        /// Converts a 802.11 SSID to a string.
        /// </summary>
        static string GetStringForSSID(Wlan.Dot11Ssid ssid)
        {
            return Encoding.ASCII.GetString( ssid.SSID, 0, (int) ssid.SSIDLength );
        }

        static void Main( string[] args )
        {
            WlanClient client = new WlanClient();
            foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces )
            {
                // Lists all networks with WEP security
                Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 );
                foreach ( Wlan.WlanAvailableNetwork network in networks )
                {
                    if ( network.dot11DefaultCipherAlgorithm == Wlan.Dot11CipherAlgorithm.WEP )
                    {
                        Console.WriteLine( "Found WEP network with SSID {0}.", GetStringForSSID(network.dot11Ssid));
                    }
                }

                // Retrieves XML configurations of existing profiles.
                // This can assist you in constructing your own XML configuration
                // (that is, it will give you an example to follow).
                foreach ( Wlan.WlanProfileInfo profileInfo in wlanIface.GetProfiles() )
                {
                    string name = profileInfo.profileName; // this is typically the network's SSID

                    string xml = wlanIface.GetProfileXml( profileInfo.profileName );
                }

                // Connects to a known network with WEP security
                string profileName = "Cheesecake"; // this is also the SSID
                string mac = "52544131303235572D454137443638";
                string key = "hello";
                string profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key);

                wlanIface.SetProfile( Wlan.WlanProfileFlags.AllUser, profileXml, true );
                wlanIface.Connect( Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName );
            }
        }
    }
}
18
ответ дан Jirapong 28 November 2019 в 03:53
поделиться

Используйте Собственные API Wi-Fi, подарок на всей Vista и системах XP SP3. XP SP2 имеет другой API, с которым можно сделать то же самое.

, Как перечислить сети

, Как получить мощность сигнала

3
ответ дан Nick 28 November 2019 в 03:53
поделиться

Вы могли бы смочь достигнуть его с помощью запросов WMI. Смотрите на этот поток .

0
ответ дан andynormancx 28 November 2019 в 03:53
поделиться

Я нашел другой способ сделать это, хотя это действительно стоит некоторых денег.

существует lib.NET, доступный в rawether.net , который позволяет Вам достигнуть драйверы Ethernet.

-3
ответ дан LDomagala 28 November 2019 в 03:53
поделиться

Если Вы используете перспективу wmi, не работает со всеми сетевыми адаптерами, другая альтернатива для перспективы должна использовать команду netsh. Взгляните на эта codeproject статья.

0
ответ дан Lee Treveil 28 November 2019 в 03:53
поделиться
Другие вопросы по тегам:

Похожие вопросы: