2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "adapters/net.hpp"
|
2016-10-18 07:34:35 +00:00
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "drawtypes/animation.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
#include "drawtypes/animation.hpp"
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "drawtypes/label.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
#include "drawtypes/ramp.hpp"
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "modules/meta.hpp"
|
|
|
|
|
|
|
|
LEMONBUDDY_NS
|
|
|
|
|
|
|
|
namespace modules {
|
2016-10-18 07:34:35 +00:00
|
|
|
enum class connection_state { NONE = 0, CONNECTED, DISCONNECTED, PACKETLOSS };
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
class network_module : public timer_module<network_module> {
|
|
|
|
public:
|
|
|
|
using timer_module::timer_module;
|
|
|
|
|
2016-11-02 19:22:45 +00:00
|
|
|
void setup();
|
|
|
|
void teardown();
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
bool build(builder* builder, string tag) const;
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-02 19:22:45 +00:00
|
|
|
void subthread_routine();
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
private:
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto FORMAT_CONNECTED = "format-connected";
|
|
|
|
static constexpr auto FORMAT_PACKETLOSS = "format-packetloss";
|
|
|
|
static constexpr auto FORMAT_DISCONNECTED = "format-disconnected";
|
|
|
|
static constexpr auto TAG_RAMP_SIGNAL = "<ramp-signal>";
|
2016-10-18 07:34:35 +00:00
|
|
|
static constexpr auto TAG_RAMP_QUALITY = "<ramp-quality>";
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto TAG_LABEL_CONNECTED = "<label-connected>";
|
|
|
|
static constexpr auto TAG_LABEL_DISCONNECTED = "<label-disconnected>";
|
|
|
|
static constexpr auto TAG_LABEL_PACKETLOSS = "<label-packetloss>";
|
|
|
|
static constexpr auto TAG_ANIMATION_PACKETLOSS = "<animation-packetloss>";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-18 07:34:35 +00:00
|
|
|
net::wired_t m_wired;
|
|
|
|
net::wireless_t m_wireless;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
ramp_t m_ramp_signal;
|
2016-10-18 07:34:35 +00:00
|
|
|
ramp_t m_ramp_quality;
|
2016-06-15 03:32:35 +00:00
|
|
|
animation_t m_animation_packetloss;
|
2016-10-18 07:34:35 +00:00
|
|
|
map<connection_state, label_t> m_label;
|
2016-05-31 09:49:33 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
stateflag m_connected{false};
|
2016-10-18 07:34:35 +00:00
|
|
|
stateflag m_packetloss{false};
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-18 07:34:35 +00:00
|
|
|
int m_signal = 0;
|
|
|
|
int m_quality = 0;
|
2016-06-15 03:32:35 +00:00
|
|
|
int m_counter = -1; // -1 to ignore the first run
|
2016-10-18 07:34:35 +00:00
|
|
|
|
|
|
|
string m_interface;
|
|
|
|
int m_ping_nth_update = 0;
|
2016-10-11 12:07:59 +00:00
|
|
|
int m_udspeed_minwidth = 3;
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
LEMONBUDDY_NS_END
|