78 lines
2.5 KiB
C++
78 lines
2.5 KiB
C++
//
|
|
// FILE: ClockClient.h
|
|
// VERSION: 0.1
|
|
// PURPOSE: FREMO Clock Client
|
|
//
|
|
//
|
|
|
|
#ifndef _clockClientLoaded
|
|
#define _clockClientLoaded
|
|
|
|
#include <appDebug.h>
|
|
#include <FastclockScanner.h>
|
|
|
|
#define MAX_CLOCK_CHANGE_CALLBACKS 5
|
|
|
|
|
|
typedef void (*ClockChangeCallback)(int h, int m, int s);
|
|
|
|
class ClockClient
|
|
{
|
|
public:
|
|
ClockClient();
|
|
static void begin();
|
|
static void loop();
|
|
static void setListenToClock(const char *_name) { listenToName = strdup(_name); }
|
|
static const char * getLastMessage();
|
|
static int getProtocolVersion() { return protocolVersion; }
|
|
static const char * getText() { return text; }
|
|
static const char * getClock() { return clock; }
|
|
static const char * getName() { return name; }
|
|
static bool isActive() { return active; }
|
|
static float getSpeed() { return speed; }
|
|
static unsigned int getClockHours() { return clockHours; }
|
|
static unsigned int getClockMinutes() { return clockMinutes; }
|
|
static unsigned int getClockSeconds() { return clockSeconds; }
|
|
static unsigned int getClockWeekday() { return weekday; }
|
|
static const char * getClockWeekdayName();
|
|
static void addClockChangeCallback(ClockChangeCallback callback);
|
|
static int getNumberOfKnownClocks();
|
|
static const char ** getKnownClocks();
|
|
static unsigned int getListenPort() { return listenPort; }
|
|
static char * getMulticastIP() { return multicast; }
|
|
static char * getFastclockServerIP() { return fastclockIP; }
|
|
static unsigned int getFastclockServerPort() { return fastclockPort; }
|
|
static char * getClockString() {
|
|
static char output[9];
|
|
snprintf(output, sizeof(output), "%02d:%02d:%02d", clockHours, clockMinutes, clockSeconds);
|
|
return output;
|
|
}
|
|
static void setDefaults();
|
|
static void interpretClockMessage(int len, char* msg);
|
|
|
|
|
|
private:
|
|
static FastclockScanner fastclockScanner;
|
|
static int numClockChangeCallbacks;
|
|
static ClockChangeCallback clockChangeCallback[MAX_CLOCK_CHANGE_CALLBACKS];
|
|
static int protocolVersion;
|
|
static char * listenToName;
|
|
static char * name;
|
|
static char * text;
|
|
static char * clocktype;
|
|
static bool active;
|
|
static bool isFastclock; // false --> real clock
|
|
static double speed;
|
|
static char * clock;
|
|
static unsigned int clockHours;
|
|
static unsigned int clockMinutes;
|
|
static unsigned int clockSeconds;
|
|
static unsigned int weekday;
|
|
static char * fastclockIP;
|
|
static unsigned int fastclockPort;
|
|
static unsigned int listenPort;
|
|
static char * multicast;
|
|
};
|
|
|
|
#endif
|