/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsICellInfo;

[scriptable, uuid(d8fae631-7ade-4024-b288-7efe75e6b091)]
interface nsICellInfoListCallback : nsISupports
{
  /**
   * result is an array of nsICellInfo, which could be instances of
   * nsIGsmCellInfo, nsIWcdmaCellInfo, nsICdmaCellInfo or nsILteCellInfo.
   */
  void notifyGetCellInfoList(in uint32_t count,
                             [array, size_is(count)] in nsICellInfo result);

  /**
   * Callback function with error message.
   */
  void notifyGetCellInfoListFailed(in DOMString error);
};

[scriptable, uuid(a9a34341-5a33-4e0a-98e1-13e7ea4228be)]
interface nsICellInfo : nsISupports
{
  const long CELL_INFO_TYPE_GSM   = 1;
  const long CELL_INFO_TYPE_CDMA  = 2;
  const long CELL_INFO_TYPE_LTE   = 3;
  const long CELL_INFO_TYPE_WCDMA = 4;

  const long TIMESTAMP_TYPE_UNKNOWN  = 0;
  const long TIMESTAMP_TYPE_ANTENNA  = 1;
  const long TIMESTAMP_TYPE_MODEM    = 2;
  const long TIMESTAMP_TYPE_OEM_RIL  = 3;
  const long TIMESTAMP_TYPE_JAVA_RIL = 4;

  const long UNKNOWN_VALUE = 0x7FFFFFFF;

  /**
   * Network type. One of the CELL_INFO_TYPE_* constants.
   */
  readonly attribute long type;

  /*
   * Registration state of this cell.
   */
  readonly attribute boolean registered;

  /**
   * Time stamp type. One of the TIMESTAMP_TYPE_* constants.
   */
  readonly attribute long timestampType;

  /**
   * Time in nanoseconds since boot.
   */
  readonly attribute long long timestamp;
};

[scriptable, uuid(cc476ded-350f-4c25-9a57-6a876e32f092)]
interface nsIGsmCellInfo : nsICellInfo
{
  /**
   * 3-digit Mobile Country Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mcc;

  /**
   * 2 or 3-digit Mobile Network Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mnc;

  /**
   * 16-bit Location Area Code, 0..65535, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long lac;

  /**
   * 16-bit GSM Cell Identity described in TS 27.007, 0..65535,
   * UNKNOWN_VALUE if unknown.
   */
  readonly attribute long cid;

  /**
   * Valid values are 0-31 as defined in TS 27.007 8.5, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long signalStrength;

  /**
   * Bit error rate 0-7 as defined in TS 27.007 8.5, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long bitErrorRate;
};

[scriptable, uuid(aa52647b-38dd-487c-be36-b46ed2e99554)]
interface nsIWcdmaCellInfo : nsICellInfo
{
  /**
   * 2 or 3-digit Mobile Network Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mcc;

  /**
   * 2 or 3-digit Mobile Network Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mnc;

  /**
   * 16-bit Location Area Code, 0..65535, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long lac;

  /**
   * 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455,
   * UNKNOWN_VALUE if unknown.
   */
  readonly attribute long cid;

  /**
   * 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511,
   * UNKNOWN_VALUE if unknown.
   */
  readonly attribute long psc;

  /**
   * Valid values are 0-31 as defined in TS 27.007 8.5, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long signalStrength;

  /**
   * Bit error rate 0-7 as defined in TS 27.007 8.5, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long bitErrorRate;
};

[scriptable, uuid(60a38ca7-ca62-4384-aa07-eac7d4893786)]
interface nsICdmaCellInfo : nsICellInfo
{
  /**
   * Network Id, 0..65535, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long networkId;

  /**
   * CDMA System Id, 0..32767, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long systemId;

  /**
   * Base Station Id, 0..65535, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long baseStationId;

  /**
   * Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
   * It is represented in units of 0.25 seconds and ranges from -2592000 to
   * 2592000, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long longitude;

  /**
   * Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
   * It is represented in units of 0.25 seconds and ranges from -1296000 to
   * 1296000, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long latitude;

  /**
   * Valid values are positive integers, UNKNOWN_VALUE if unknown. This value is
   * the actual RSSI value multiplied by -1.
   */
  readonly attribute long cdmaDbm;

  /**
   * Valid values are positive integers, UNKNOWN_VALUE if unknown. This value is
   * the actual Ec/Io multiplied by -10.
   */
  readonly attribute long cdmaEcio;

  /**
   * Valid values are positive integers, UNKNOWN_VALUE if unknown. This value is
   * the actual Evdo RSSI value multiplied by -1.
   */
  readonly attribute long evdoDbm;

  /**
   * Valid values are positive integers, UNKNOWN_VALUE if unknown. This value is
   * the actual Evdo Ec/Io multiplied by -10.
   */
  readonly attribute long evdoEcio;

  /**
   * Valid values are 0-8, UNKNOWN_VALUE if unknown. 8 is the highest signal to
   * noise ratio.
   */
  readonly attribute long evdoSnr;
};

[scriptable, uuid(e7b3e826-bb85-49b2-a2f1-70af46c47733)]
interface nsILteCellInfo : nsICellInfo
{
  /**
   * 3-digit Mobile Country Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mcc;

  /**
   * 2 or 3-digit Mobile Network Code, 0..999, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long mnc;

  /**
   * 28-bit Cell Identity, 0..268435455, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long cid;

  /**
   * Physical cell id, 0..503, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long pcid;

  /**
   * 16-bit tracking area code, 0..65535, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long tac;

  /**
   * Valid values are 0-31 as defined in TS 27.007 8.5, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long signalStrength;

  /**
   * The current Reference Signal Receive Power in dBm multipled by -1.
   * Range: 44 to 140 dBm, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long rsrp;

  /**
   * The current Reference Signal Receive Quality in dB multiplied by -1.
   * Range: 3 to 20 dB, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long rsrq;

  /**
   * The current reference signal signal-to-noise ratio in 0.1 dB units.
   * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB), UNKNOWN_VALUE if
   * unknown.
   */
  readonly attribute long rssnr;

  /**
   * The current Channel Quality Indicator. Range: 0 to 15, UNKNOWN_VALUE if
   * unknown.
   */
  readonly attribute long cqi;

  /**
   * Timing advance in micro seconds for a one way trip from cell to device.
   * Approximate distance can be calculated using 300m/us * timingAdvance.
   * Range: 0 to 0x7FFFFFFE, UNKNOWN_VALUE if unknown.
   */
  readonly attribute long timingAdvance;
};