description {
 * @brief Wireless Sensor Networks

The WSN interface provides access to a Wireless Sensor Network (driver
implementations include WSN's such as Crossbow's MICA2 motes and TeCo's RCore
particles).

The current implementation supports a single group of network nodes. Support
for multiple groups will be added in the future.
}

/** Data subtypes                                                               */
message { DATA, STATE, 1, player_wsn_data_t };

/** Command subtype: set device state                                           */
message { CMD, DEVSTATE, 1, player_wsn_cmd_t };

/** Request/reply: put the node in sleep mode (0) or wake it up (1).            */
message { REQ, POWER, 1, player_wsn_power_config_t };
/** Request/reply: change the data type to RAW or converted metric units.       */
message { REQ, DATATYPE, 2, player_wsn_datatype_config_t };
/** Request/reply: change the receiving data frequency.                         */
message { REQ, DATAFREQ, 3, player_wsn_datafreq_config_t };

/** @brief Structure describing the WSN node's data packet.                     */
typedef struct player_wsn_node_data
{
  /** The node's light measurement from a light sensor.                   */
  float light;
  /** The node's accoustic measurement from a microphone.                 */
  float mic;
  /** The node's acceleration on X-axis from an acceleration sensor.      */
  float accel_x;
  /** The node's acceleration on Y-axis from an acceleration sensor.      */
  float accel_y;
  /** The node's acceleration on Z-axis from an acceleration sensor.      */
  float accel_z;
  /** The node's magnetic measurement on X-axis from a magnetometer.      */
  float magn_x;
  /** The node's magnetic measurement on Y-axis from a magnetometer.      */
  float magn_y;
  /** The node's magnetic measurement on Z-axis from a magnetometer.      */
  float magn_z;
  /** The node's templerature measurement from a temperature sensor.      */
  float temperature;
  /** The node's remaining battery voltage.                               */
  float battery;
} player_wsn_node_data_t;

/** @brief Data (@ref PLAYER_WSN_DATA)

The WSN data packet describes a wireless sensor network node.                   */
typedef struct player_wsn_data
{
  /** The type of WSN node.                                               */
  uint32_t node_type;
  /** The ID of the WSN node.                                             */
  uint32_t node_id;
  /** The ID of the WSN node's parent (if existing).                      */
  uint32_t node_parent_id;
  /** The WSN node's data packet.                                         */
  player_wsn_node_data_t data_packet;
} player_wsn_data_t;

/** @brief Command: set device state (@ref PLAYER_WSN_CMD_DEVSTATE)
This @p wsn command sets the state of the node's indicator lights or
its buzzer/sounder (if equipped with one).                                      */
typedef struct player_wsn_cmd
{
  /** The ID of the WSN node. -1 for all.                                 */
  int32_t node_id;
  /** The Group ID of the WSN node. -1 for all.                           */
  int32_t group_id;
  /** The device number.                                                  */
  uint32_t device;
  /** The state: 0=disabled, 1=enabled.                                   */
  uint8_t enable;
} player_wsn_cmd_t;

/** @brief Request/reply: Put the node in sleep mode (0) or wake it up (1).

Send a @ref PLAYER_WSN_REQ_POWER request to power or wake up a node in the WSN.
Null response.                                                                  */
typedef struct player_wsn_power_config
{
  /** The ID of the WSN node. -1 for all.                                 */
  int32_t node_id;
  /** The Group ID of the WSN node. -1 for all.                           */
  int32_t group_id;
  /** Power setting: 0 for off, 1 for on.                                 */
  uint8_t value;
} player_wsn_power_config_t;

/** @brief Request/reply: change the data type to RAW or converted engineering
units.

Send a @ref PLAYER_WSN_REQ_DATATYPE request to switch between RAW or converted
engineering units values in the data packet. Null response.                     */
typedef struct player_wsn_datatype_config
{
  /** Data type setting: 0 for RAW values, 1 for converted units.         */
  uint8_t value;
} player_wsn_datatype_config_t;

/** @brief Request/reply: Change data delivery frequency.

By default, the frequency set for receiving data is set on the wireless node.
Send a @ref PLAYER_WSN_REQ_DATAFREQ request to change the frequency. Fill in
the node ID or set -1 for all nodes. Null response.                             */
typedef struct player_wsn_datafreq_config
{
  /** The ID of the WSN node. -1 for all.                                 */
  int32_t node_id;
  /** The Group ID of the WSN node. -1 for all.                           */
  int32_t group_id;
  /** Requested frequency in Hz.                                          */
  double  frequency;
} player_wsn_datafreq_config_t;
