syntax = "proto3";

package meshtastic;

import "meshtastic/config.proto";
import "meshtastic/mesh.proto";

option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";
option java_outer_classname = "MQTTProtos";
option java_package = "org.meshtastic.proto";
option swift_prefix = "";

/*
 * This message wraps a MeshPacket with extra metadata about the sender and how it arrived.
 */
message ServiceEnvelope {
  /*
   * The (probably encrypted) packet
   */
  MeshPacket packet = 1;

  /*
   * The global channel ID it was sent on
   */
  string channel_id = 2;

  /*
   * The sending gateway node ID. Can we use this to authenticate/prevent fake
   * nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as
   * the globally trusted nodenum
   */
  string gateway_id = 3;
}

/*
 * Information about a node intended to be reported unencrypted to a map using MQTT.
 */
message MapReport {
  /*
   * A full name for this user, i.e. "Kevin Hester"
   */
  string long_name = 1;

  /*
   * A VERY short name, ideally two characters.
   * Suitable for a tiny OLED screen
   */
  string short_name = 2;

  /*
   * Role of the node that applies specific settings for a particular use-case
   */
  Config.DeviceConfig.Role role = 3;

  /*
   * Hardware model of the node, i.e. T-Beam, Heltec V3, etc...
   */
  HardwareModel hw_model = 4;

  /*
   * Device firmware version string
   */
  string firmware_version = 5;

  /*
   * The region code for the radio (US, CN, EU433, etc...)
   */
  Config.LoRaConfig.RegionCode region = 6;

  /*
   * Modem preset used by the radio (LongFast, MediumSlow, etc...)
   */
  Config.LoRaConfig.ModemPreset modem_preset = 7;

  /*
   * Whether the node has a channel with default PSK and name (LongFast, MediumSlow, etc...)
   * and it uses the default frequency slot given the region and modem preset.
   */
  bool has_default_channel = 8;

  /*
   * Latitude: multiply by 1e-7 to get degrees in floating point
   */
  sfixed32 latitude_i = 9;

  /*
   * Longitude: multiply by 1e-7 to get degrees in floating point
   */
  sfixed32 longitude_i = 10;

  /*
   * Altitude in meters above MSL
   */
  int32 altitude = 11;

  /*
   * Indicates the bits of precision for latitude and longitude set by the sending node
   */
  uint32 position_precision = 12;

  /*
   * Number of online nodes (heard in the last 2 hours) this node has in its list that were received locally (not via MQTT)
   */
  uint32 num_online_local_nodes = 13;

  /*
   * User has opted in to share their location (map report) with the mqtt server
   * Controlled by map_report.should_report_location
   */
  bool has_opted_report_location = 14;
}
