package com.amazon.ads.ema.api.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * WiFi connection information
 */
public class WifiInfo implements Parcelable {
    public static final Creator<WifiInfo> CREATOR = new Creator<>() {
        @Override
        public WifiInfo createFromParcel(Parcel in) {
            return new WifiInfo(in);
        }

        @Override
        public WifiInfo[] newArray(int size) {
            return new WifiInfo[size];
        }
    };
    public boolean connected;
    public String ssid;
    public int signalStrengthDbm;       // Signal strength in dBm (e.g., -45)
    public int signalLevel;             // Signal level 0-4 (4 = excellent)
    public int linkSpeedMbps;           // Link speed in Mbps
    public int frequency;               // Frequency in MHz (2400-2500 or 5000-6000)
    public String ipAddress;
    public String macAddress;

    public WifiInfo() {
    }

    protected WifiInfo(Parcel in) {
        connected = in.readByte() != 0;
        ssid = in.readString();
        signalStrengthDbm = in.readInt();
        signalLevel = in.readInt();
        linkSpeedMbps = in.readInt();
        frequency = in.readInt();
        ipAddress = in.readString();
        macAddress = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (connected ? 1 : 0));
        dest.writeString(ssid);
        dest.writeInt(signalStrengthDbm);
        dest.writeInt(signalLevel);
        dest.writeInt(linkSpeedMbps);
        dest.writeInt(frequency);
        dest.writeString(ipAddress);
        dest.writeString(macAddress);
    }

    @Override
    public int describeContents() {
        return 0;
    }
}
