blob: 8b6641ab7e868101f7bc833689176051db7b94cc [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"
Austin Schuh6b9c4152019-11-29 12:45:24 -08005#include "aos/events/ping_generated.h"
Austin Schuh60e77942022-05-16 17:48:24 -07006#include "aos/events/pong_generated.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:
18 EventLoop *event_loop_;
19 aos::Sender<examples::Pong> sender_;
Sarah Newman2f98cf02022-04-01 16:42:00 -070020 int32_t last_value_ = 0;
21 int32_t last_send_time_ = 0;
Austin Schuh9b1d6282022-06-10 17:03:21 -070022
23 bool quiet_ = true;
Austin Schuh6b9c4152019-11-29 12:45:24 -080024};
25
26} // namespace aos
27
28#endif // AOS_EVENTS_PONG_LIB_H_