Search in sources :

Example 1 with Hostapd

use of org.eclipse.kura.linux.net.wifi.Hostapd in project kura by eclipse.

the class GenericNetworkInterface method setWifiAccessPointConfig.

/**
 * Populate a WifiConfigIP4 object using the hostapd config
 *
 * @param wifiConfig
 * @throws KuraException
 */
private static void setWifiAccessPointConfig(WifiConfig wifiConfig) throws KuraException {
    wifiConfig.setMode(WifiMode.MASTER);
    Hostapd hostapd = Hostapd.getHostapd();
    if (hostapd != null) {
        wifiConfig.setSSID(hostapd.getSSID());
        // wifiConfig.setChannel((short)hostapd.getChannel());
        int[] channels = new int[1];
        channels[0] = hostapd.getChannel();
        wifiConfig.setChannels(channels);
        wifiConfig.setPasskey(hostapd.getPassword());
        // TODO: always true? is this needed?
        wifiConfig.setBroadcast(true);
        // security
        wifiConfig.setSecurity(hostapd.getSecurity());
        // hw mode
        WifiRadioMode radioMode = hostapd.getRadioMode();
        if (radioMode == WifiRadioMode.RADIO_MODE_80211b) {
            wifiConfig.setHardwareMode("b");
        } else if (radioMode == WifiRadioMode.RADIO_MODE_80211g) {
            wifiConfig.setHardwareMode("g");
        } else if (radioMode == WifiRadioMode.RADIO_MODE_80211nHT20 || radioMode == WifiRadioMode.RADIO_MODE_80211nHT40above || radioMode == WifiRadioMode.RADIO_MODE_80211nHT40below) {
            // TODO: specify these 'n' modes separately?
            wifiConfig.setHardwareMode("n");
        }
    }
}
Also used : WifiRadioMode(org.eclipse.kura.net.wifi.WifiRadioMode) Hostapd(org.eclipse.kura.linux.net.wifi.Hostapd)

Aggregations

Hostapd (org.eclipse.kura.linux.net.wifi.Hostapd)1 WifiRadioMode (org.eclipse.kura.net.wifi.WifiRadioMode)1