mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 07:06:11 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I0023ac6e40456fc4a8169c3173bcbff3b5ccc476
89 lines
2.8 KiB
C++
89 lines
2.8 KiB
C++
#ifndef PLATFORM_API2_WIFI_H_
|
|
#define PLATFORM_API2_WIFI_H_
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "absl/strings/string_view.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
|
|
// Possible authentication types for a WiFi network.
|
|
enum class WifiAuthType {
|
|
// WiFi Authentication type; either none (non-secured a.k.a. open) link, or
|
|
// WPA PSK (WiFi Protected Access PreShared Key), or
|
|
// see https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access
|
|
// WEP (Wired Equivalent Privacy);
|
|
// see https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy
|
|
kUnknown = 0,
|
|
kOpen = 1,
|
|
kWpaPsk = 2,
|
|
kWep = 3,
|
|
};
|
|
|
|
// Possible statuses of a device's connection to a WiFi network.
|
|
enum class WifiConnectionStatus {
|
|
kUnknown = 0,
|
|
kConnected = 1,
|
|
kConnectionFailure = 2,
|
|
kAuthFailure = 3,
|
|
};
|
|
|
|
// Represents a WiFi network found during a call to WifiMedium#scan().
|
|
class WifiScanResult {
|
|
public:
|
|
virtual ~WifiScanResult() {}
|
|
|
|
// Gets the SSID of this WiFi network.
|
|
virtual std::string GetSsid() const = 0;
|
|
// Gets the signal strength of this WiFi network in dBm.
|
|
virtual std::int32_t GetSignalStrengthDbm() const = 0;
|
|
// Gets the frequency band of this WiFi network in MHz.
|
|
virtual std::int32_t GetFrequencyMhz() const = 0;
|
|
// Gets the authentication type of this WiFi network.
|
|
virtual WifiAuthType GetAuthType() const = 0;
|
|
};
|
|
|
|
// Container of operations that can be performed over the WiFi medium.
|
|
class WifiMedium {
|
|
public:
|
|
virtual ~WifiMedium() {}
|
|
|
|
class ScanResultCallback {
|
|
public:
|
|
virtual ~ScanResultCallback() {}
|
|
|
|
virtual void OnScanResults(
|
|
const std::vector<WifiScanResult>& scan_results) = 0;
|
|
};
|
|
|
|
// Does not take ownership of the passed-in scan_result_callback -- destroying
|
|
// that is up to the caller.
|
|
virtual bool Scan(const ScanResultCallback& scan_result_callback) = 0;
|
|
|
|
// If 'password' is an empty string, none has been provided. Returns
|
|
// WifiConnectionStatus::CONNECTED on success, or the appropriate failure code
|
|
// otherwise.
|
|
virtual WifiConnectionStatus ConnectToNetwork(absl::string_view ssid,
|
|
absl::string_view password,
|
|
WifiAuthType auth_type) = 0;
|
|
|
|
// Blocks until it's certain of there being a connection to the internet, or
|
|
// returns false if it fails to do so.
|
|
//
|
|
// How this method wants to verify said connection is totally up to it (so it
|
|
// can feel free to ping whatever server, download whatever resource, etc.
|
|
// that it needs to gain confidence that the internet is reachable hereon in).
|
|
virtual bool VerifyInternetConnectivity() = 0;
|
|
|
|
// Returns the local device's IP address in the IPv4 dotted-quad format.
|
|
virtual std::string GetIpAddress() = 0;
|
|
};
|
|
|
|
} // namespace nearby
|
|
} // namespace location
|
|
|
|
#endif // PLATFORM_API2_WIFI_H_
|