/* 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"

[scriptable, uuid(1aed4c36-979e-4d20-9fa0-55139da8301e)]
interface nsICellInfoListCallback : nsISupports
{
  /**
   * result is an array of nsICellInfo.
   */
  void notifyGetCellInfoList(in jsval result);

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

[scriptable, uuid(86667898-c9ab-44ee-8a9a-026916b3183e)]
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;

  /**
   * 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(6345967c-61fc-45a1-8362-39e9261df052)]
interface nsIGsmCellInfo : nsICellInfo
{
  /**
   * 3-digit Mobile Country Code, 0..999, INT_MAX if unknown.
   */
  readonly attribute long mcc;

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

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

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

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

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

[scriptable, uuid(19693f98-943d-45e7-a3e8-25373228ce6b)]
interface nsIWcdmaCellInfo : nsICellInfo
{
  /**
   * 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown.
   */
  readonly attribute long mcc;

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

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

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

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

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

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

[scriptable, uuid(76b4a35d-7e45-42bc-a2e0-bc07a6434db3)]
interface nsICdmaCellInfo : nsICellInfo
{
  /**
   * Network Id, 0..65535, INT_MAX if unknown.
   */
  readonly attribute long networkId;

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

  /**
   * Base Station Id, 0..65535, INT_MAX 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, INT_MAX 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, INT_MAX if unknown.
   */
  readonly attribute long latitude;

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

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

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

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

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

[scriptable, uuid(122937d9-1ee5-45e0-a360-5959d578bc31)]
interface nsILteCellInfo : nsICellInfo
{
  /**
   * 3-digit Mobile Country Code, 0..999, INT_MAX if unknown.
   */
  readonly attribute long mcc;

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

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

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

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

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

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

  /**
   * The current Reference Signal Receive Quality in dB multiplied by -1.
   * Range: 3 to 20 dB, INT_MAX 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), INT_MAX if unknown.
   */
  readonly attribute long rssnr;

  /**
   * The current Channel Quality Indicator. Range: 0 to 15, INT_MAX 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, INT_MAX if unknown.
   */
  readonly attribute long timingAdvance;
};