Package com.facebook.openwifi.cloudsdk
Class UCentralUtils
- java.lang.Object
-
- com.facebook.openwifi.cloudsdk.UCentralUtils
-
public class UCentralUtils extends Object
uCentral utility methods/structures.
-
-
Field Summary
Fields Modifier and Type Field Description static Map<String,List<Integer>>
AVAILABLE_CHANNELS_BAND
Map from band to ordered (increasing) list of available channels
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
freqToBand(int freqMHz)
Return which band contains the given frequency (MHz).static Map<String,List<String>>
getBandsMap(Map<String,List<UCentralSchema.Radio>> deviceStatus)
Get the APs on a band who participate in an optimization algorithm.static Map<String,String>
getBssidsMap(Map<String,? extends State> latestState)
Get the mapping between bssids and APs.static Map<String,Map<String,List<Integer>>>
getDeviceAvailableChannels(Map<String,List<UCentralSchema.Radio>> deviceStatus, Map<String,Map<String,Capabilities.Phy>> deviceCapabilities, Map<String,List<Integer>> defaultAvailableChannels)
Get the capabilities of the APs who participate in an optimization algorithm.static int
getLowerChannelLimit(String band)
Return the lowest available channel for the given bandstatic String
getScriptOutput(CommandInfo info)
Given the result of the "script" API, return the actual script output (decoded/decompressed if needed), or null if the script returned an error.static int
getUpperChannelLimit(String band)
Return the lowest available channel for the given bandstatic Map<String,State.Interface.Client>
getWifiClientInfo(State state)
Return a map of Wi-Fi client (STA) MAC addresses to the Client structure found for that interface.static boolean
isChannelInBand(int channel, String band)
Determines if the given channel is in the given band.static Integer
parseChannelWidth(String channelWidthStr, boolean treatSeparate)
Tries to parse channel width, if it encounters an error it will return null.static Integer
parseReferenceIndex(String reference)
Tries to parse the index from the reference string in the JSON returned from other services.static List<WifiScanEntry>
parseWifiScanEntries(com.google.gson.JsonObject result, long timestampMs)
Parse a JSON wifi scan result into a list of WifiScanEntry objects.static boolean
setRadioConfigField(String serialNumber, UCentralApConfiguration config, String fieldName, Map<String,Integer> newValueList)
Set all radios config of an AP to a given value.
-
-
-
Method Detail
-
getLowerChannelLimit
public static int getLowerChannelLimit(String band)
Return the lowest available channel for the given band
-
getUpperChannelLimit
public static int getUpperChannelLimit(String band)
Return the lowest available channel for the given band
-
parseWifiScanEntries
public static List<WifiScanEntry> parseWifiScanEntries(com.google.gson.JsonObject result, long timestampMs)
Parse a JSON wifi scan result into a list of WifiScanEntry objects.- Parameters:
result
- result of the wifiscantimestampMs
- Unix time in ms- Returns:
- list of wifiscan entries, or null if any parsing/deserialization error occurred.
-
setRadioConfigField
public static boolean setRadioConfigField(String serialNumber, UCentralApConfiguration config, String fieldName, Map<String,Integer> newValueList)
Set all radios config of an AP to a given value. Returns true if changed, or false if unchanged for any reason.
-
getBandsMap
public static Map<String,List<String>> getBandsMap(Map<String,List<UCentralSchema.Radio>> deviceStatus)
Get the APs on a band who participate in an optimization algorithm. Get the info from the configuration field in deviceStatus (Since the State doesn't explicitly show the "band" info) Returns the results map
-
getDeviceAvailableChannels
public static Map<String,Map<String,List<Integer>>> getDeviceAvailableChannels(Map<String,List<UCentralSchema.Radio>> deviceStatus, Map<String,Map<String,Capabilities.Phy>> deviceCapabilities, Map<String,List<Integer>> defaultAvailableChannels)
Get the capabilities of the APs who participate in an optimization algorithm.- Parameters:
deviceStatus
- map of {device, status}deviceCapabilities
- map of {device, capabilities info}defaultAvailableChannels
- map of {band, list of available channels}- Returns:
- the results map of {band, {device, list of available channels}}
-
getBssidsMap
public static Map<String,String> getBssidsMap(Map<String,? extends State> latestState)
Get the mapping between bssids and APs. Get the info from the State data Returns the results map
-
isChannelInBand
public static boolean isChannelInBand(int channel, String band)
Determines if the given channel is in the given band.- Parameters:
channel
- channel numberband
- "2G" or "5G"- Returns:
- true if the given channel is in the given band; false otherwise
-
freqToBand
public static String freqToBand(int freqMHz)
Return which band contains the given frequency (MHz).
-
parseChannelWidth
public static Integer parseChannelWidth(String channelWidthStr, boolean treatSeparate)
Tries to parse channel width, if it encounters an error it will return null. It can handle 80p80 in two ways. First it can just treat it as 160. Second, it can just apply to the first 80 channel and ignore the second. This is controlled by treatSeparate.- Parameters:
channelWidthStr
- the channel widthtreatSeparate
- treats each band separately- Returns:
- channel width in MHz
-
parseReferenceIndex
public static Integer parseReferenceIndex(String reference)
Tries to parse the index from the reference string in the JSON returned from other services. Note that this only returns the index, the caller is responsible for making sure that the correct field is passed in and the index is used in the correct fields. If there's an error parsing, it will return null.- Parameters:
reference
- The reference string, keyed under "$ref"- Returns:
- the index of the reference or null if an error occurred.
-
getWifiClientInfo
public static Map<String,State.Interface.Client> getWifiClientInfo(State state)
Return a map of Wi-Fi client (STA) MAC addresses to the Client structure found for that interface. This does NOT support clients connected on multiple interfaces simultaneously.
-
getScriptOutput
public static String getScriptOutput(CommandInfo info)
Given the result of the "script" API, return the actual script output (decoded/decompressed if needed), or null if the script returned an error.
-
-