// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
syntax = "proto3";

package pubsub;

import "pw_protobuf_protos/common.proto";
import "morse_code.proto";
import "state_manager.proto";

service PubSub {
  rpc Publish(Event) returns (pw.protobuf.Empty);
  rpc Subscribe(pw.protobuf.Empty) returns (stream Event);
}

message LedValue {
  uint32 r = 1;
  uint32 g = 2;
  uint32 b = 3;
}

message MorseCodeValue {
  bool turn_on = 1;
  bool message_finished = 2;
}

message MorseEncodeRequest {
  string msg = 1;
  uint32 repeat = 2;
}

message TimerRequest {
  uint32 token = 1;
  uint32 timeout_s = 2;
}

message TimerExpired {
  uint32 token = 1;
}

message StateManagerControl {
  enum Action {
    UNKNOWN = 0;
    INCREMENT_THRESHOLD = 1;
    DECREMENT_THRESHOLD = 2;
    SILENCE_ALARMS = 3;
  }
  Action action = 1;
}

message Event {
  // This definition must be kept up to date with
  // modules/pubsub/pubsub_events.h.
  oneof type {
    bool button_a_pressed = 1;
    bool button_b_pressed = 2;
    bool button_x_pressed = 3;
    bool button_y_pressed = 4;
    bool proximity = 5;
    uint32 proximity_level = 6;
    uint32 air_quality = 7;
    MorseCodeValue morse_code_value = 8;
    TimerRequest timer_request = 9;
    TimerExpired timer_expired = 10;
    morse_code.SendRequest morse_encode_request = 11;
    float ambient_light_lux = 12;
    state_manager.State sense_state = 13;
    StateManagerControl state_manager_control = 14;
  }
}
