blob: 17e5d355483082f28bb192174a093420d8f2ccef [file] [log] [blame]
Austin Schuh6b9c4152019-11-29 12:45:24 -08001#ifndef AOS_EVENTS_PONG_LIB_H_
2#define AOS_EVENTS_PONG_LIB_H_
3
4#include "aos/events/event_loop.h"
James Kuszmaul6f255b22023-11-06 13:46:54 -08005#include "aos/events/ping_static.h"
6#include "aos/events/pong_static.h"
Austin Schuh6b9c4152019-11-29 12:45:24 -08007
8namespace aos {
9
10// Class which replies to a Ping message with a Pong message immediately.
11class Pong {
12 public:
13 Pong(EventLoop *event_loop);
14
Austin Schuh9b1d6282022-06-10 17:03:21 -070015 void set_quiet(bool quiet) { quiet_ = quiet; }
16
Austin Schuh6b9c4152019-11-29 12:45:24 -080017 private:
James Kuszmaul60bb8682023-08-07 07:39:34 -070018 void HandlePing(const examples::Ping &ping);
Austin Schuh6b9c4152019-11-29 12:45:24 -080019 EventLoop *event_loop_;
James Kuszmaul60bb8682023-08-07 07:39:34 -070020 aos::Fetcher<examples::Ping> fetcher_;
James Kuszmaul6f255b22023-11-06 13:46:54 -080021 aos::Sender<examples::PongStatic> sender_;
Sarah Newman2f98cf02022-04-01 16:42:00 -070022 int32_t last_value_ = 0;
23 int32_t last_send_time_ = 0;
Austin Schuh9b1d6282022-06-10 17:03:21 -070024
25 bool quiet_ = true;
Austin Schuh6b9c4152019-11-29 12:45:24 -080026};
27
28} // namespace aos
29
30#endif // AOS_EVENTS_PONG_LIB_H_