import { NativeEventEmitter } from 'react-native'; import { Status } from './types/NetCommon'; import { AuthMode, ConnectionInfo, DisconnectReason, Profile, ScanResultItem, Standard, StatisticsInfo } from './types/NetWifiCommon'; /** * @brief callback class for applications to receive notifications on changes * in Wi-Fi state and scan results. * @remarks Applications must implement 'WifiEventCallback' and * register it via {@link WifiInterface.registerEventCallback} to receive * the notifications. */ export declare class WifiEventCallback { /** * @brief Called when a scan request is completed and a new scan result * is available. * @remark {@link WifiInterface.getScanResults} will return * the new scan result. {@link WifiInterface.startScan} will request * another scan. */ onScanDone: (() => void) | undefined; /** * @brief Called when connected to a new Wi-Fi access point. */ onConnected?: (() => void) | undefined; /** * @brief Called when disconnected. */ onDisconnected: ((reason: DisconnectReason) => void) | undefined; } export declare class WifiInterface extends NativeEventEmitter { private static sEventCallback; private mNetworkId; private eventListener?; /** * @brief Creates a `WifiInterface` instance. * @param networkInterfaceId - the identifier of the Wi-Fi network interface */ constructor(networkInterfaceId: number); /** * @brief Get the major version. * @return the major version. */ static getMajorVersion(): number; /** * @brief Get the minor version. * @return the minor version. */ static getMinorVersion(): number; /** * @brief Get the patch version. * @return the patch version. */ static getPatchVersion(): number; /** * @brief Register {@link WifiEventCallback}. The caller must implement * a {@link WifiEventCallback} to receive notifications. * @param callback - a callback which will be called back to notify * the caller of Wi-Fi events. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ registerEventCallback(callback: WifiEventCallback): Status; /** * @brief Unregister {@link WifiEventCallback}. */ unregisterEventCallback(): void; /** * @brief Request a scan on all supported channels asynchronously. * Registered {@link WifiEventListener#onScanDone} is called back when the * requested scan is finished. * @remarks App needs to declare com.amazon.wifi.privilege.wifi-scan in * application manifest. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ startScan(): Status; /** * @brief Get the result of the latest scan. * @remarks App needs to declare com.amazon.wifi.privilege.wifi-scan in * application manifest. * @param scanResults - the list of ScanResultsItem. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ getScanResults(scanResults: Array): Status; /** * @brief Get the Wi-Fi Profiles. * @remarks App needs to declare com.amazon.network.privilege.net-info or * `com.amazon.wifi.privilege.read-wifi-credential` for credential * information in application manifest. * @param profiles - the array of Wi-Fi Profiles. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ getProfiles(profiles: Array): Status; /** * @brief Create a new Wi-Fi Profile. * @remarks The new Wi-Fi Profile will be disabled by default unless * {@link Profile.configStatus} is {@link ConfigStatus.ENABLED}. * {@link WifiInterface.connect} with the SSID and the authentication mode of * new Wi-Fi Profile will disable other Wi-Fi Profiles and enable * the new Profile only. * {@link WifiInterface.saveProfiles} will persist the Wi-Fi Profiles * across reboots after Adding a new Wi-Fi Profile. * * App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param profile - new Profile to be added. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ addProfile(profile: Profile): Status; /** * @brief Remove a Wi-Fi Profile. * @remarks Remove a Wi-Fi Profile which is identified by an SSID and * an authentication mode. {@link WifiInterface.saveProfiles} will persist * the Wi-Fi Profiles across reboots after removing the Wi-Fi Profile. * * App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param ssid - the SSID of the profile to be removed. * @param authMode - the authentication mode of the Profile to be removed. * authMode can be set to {@link AuthMode.UNKNOWN} to match the access point * without authentication mode. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ removeProfile(ssid: string, authMode: AuthMode): Status; /** * @brief Save Wi-Fi Profiles in the system. * @remarks Persist the Wi-Fi Profiles across reboots. * App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ saveProfiles(): Status; /** * @brief Enable or disable all Wi-Fi Profiles. * @remarks App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param enableDisable - if true, enable all Wi-Fi Profiles. If false, * disable all Wi-Fi Profiles. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ enableAllProfiles(enableDisable: boolean): Status; /** * @brief Connect to the access point stored in Wi-Fi Profiles. * @remarks App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @param ssid - SSID of the access point. * @param authMode - authentication mode of the access point. * authMode can be set to {@link AuthMode.UNKNOWN} to match the access point * with any authentication mode. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ connect(ssid: string, authMode: AuthMode): Status; /** * @brief Disconnect the connected access point. * @remarks App needs to declare com.amazon.network.privilege.net-admin in * application manifest. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. * - {@link Status.PERMISSION_DENIED} if the caller does not have * required permission. */ disconnect(): Status; /** * @brief Get the current Wi-Fi connection information. If caller does not * have required permission, SSID will be masked as "", BSSID * will be masked to 02:00:00:00:00:00 * @remarks App needs to declare com.amazon.network.privilege.net-info in * application manifest. * @param info - the current connection information. * @returns * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getConnectionInfo(connectionInfo: ConnectionInfo): Status; /** * @brief Get the level of the signal strength. * @param rssi - Received Signal Strength Indicator (RSSI) in dBm. * @param levels - The number of levels to calculate. * @return a level of signal. */ calculateSignalLevel(rssi: number, levels: number): number; /** * Get the supported Wi-Fi Standard. * @return the supported Wi-Fi Standard. */ getStandard(): Standard; /** * @brief Get the current statistics information. * @return * - {@link Status.SUCCESS} on success. * - {@link Status.GENERAL_ERROR} if an unspecified failure happens. */ getStatisticsInfo(statisticsInfo: StatisticsInfo): Status; private eventDispatcher; }