// SPDX-FileCopyrightText: 2020 The Magma Authors.
// SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
//
// SPDX-License-Identifier: BSD-3-Clause

syntax = "proto3";

import "orc8r/protos/service303.proto";
import "orc8r/protos/common.proto";

package magma.lte;

option go_package = "magma/lte/cloud/go/protos";


// --------------------------------------------------------------------------
// Message Definitions for TR-069 message injection. This is used for manual
// testing of the TR-069 server.
// --------------------------------------------------------------------------
message GetParameterRequest {
  // Serial ID of eNodeB. Uniquely identifies the eNodeB.
  string device_serial = 1;

  // Fully qualified parameter name, e.g:
  // InternetGatewayDevice.LANDevice.1.Hosts.
  string parameter_name = 2;
}

message NameValue {
  string name = 1;
  // Note: parameter value is always passed back as string. Up to calling
  // function to determine type
  string value = 2;
}
message GetParameterResponse {
  string device_serial = 1;
  repeated NameValue parameters = 2;
}

message SetParameterRequest {
  // Serial ID of eNodeB. Uniquely identifies the eNodeB.
  string device_serial = 1;

  // Fully qualified parameter name, e.g:
  // InternetGatewayDevice.LANDevice.1.Hosts.
  string parameter_name = 2;

  // Data values for each data type
  oneof value {
    int32 value_int = 3;
    string value_string = 4;
    bool value_bool = 5;
  }

  // Key to be used at ACS discretion to determine when parameter was last
  // updated
  string parameter_key = 6;
}

message EnodebIdentity {
  // Serial ID of eNodeB. Uniquely identifies the eNodeB.
  string device_serial = 1;
}

message AllEnodebStatus {
  repeated SingleEnodebStatus enb_status_list = 1;
}

message SingleEnodebStatus {
  enum StatusProperty {
    OFF = 0;
    ON = 1;
    UNKNOWN = 2;
  }
  string device_serial = 1;
  string ip_address = 2;
  StatusProperty connected = 3;
  StatusProperty configured = 4;
  StatusProperty opstate_enabled = 5;
  StatusProperty rf_tx_on = 6;
  StatusProperty gps_connected = 7;
  StatusProperty ptp_connected = 8;
  StatusProperty mme_connected = 9;
  string gps_longitude = 10;
  string gps_latitude = 11;
  string fsm_state = 12;
  StatusProperty rf_tx_desired = 13;
}

// --------------------------------------------------------------------------
// Enodebd service definition.
// --------------------------------------------------------------------------
service Enodebd {

  // Sends GetParameterValues message to ENodeB. TR-069 supports multiple
  // parameter names per message, but only one is supported here.
  rpc GetParameter (GetParameterRequest) returns (GetParameterResponse);

  // Sends SetParameterValues message to ENodeB. TR-069 supports multiple
  // parameter names per message, but only one is supported here.
  rpc SetParameter (SetParameterRequest) returns (magma.orc8r.Void);

  // Configure eNodeB based on enodebd config file
  rpc Configure (EnodebIdentity) returns (magma.orc8r.Void);

  // Reboot eNodeB
  rpc Reboot (EnodebIdentity) returns (magma.orc8r.Void);

  // Reboot every connected eNodeB
  rpc RebootAll (magma.orc8r.Void) returns (magma.orc8r.Void);

  // Get current status
  rpc GetStatus (magma.orc8r.Void) returns (magma.orc8r.ServiceStatus);

  // Get status info for all connected eNodeB devices
  rpc GetAllEnodebStatus (magma.orc8r.Void) returns (AllEnodebStatus);

  // Get status info of a single connected eNodeB device
  rpc GetEnodebStatus (EnodebIdentity) returns (SingleEnodebStatus);
}
