supla-device
Loading...
Searching...
No Matches
remote_device_config.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_DEVICE_REMOTE_DEVICE_CONFIG_H_
20#define SRC_SUPLA_DEVICE_REMOTE_DEVICE_CONFIG_H_
21
22#include <supla-common/proto.h>
23#include <supla/protocol/supla_srpc.h>
24
25namespace Supla {
26
27enum class HomeScreenContent {
28 HOME_SCREEN_OFF,
29 HOME_SCREEN_TEMPERATURE,
30 HOME_SCREEN_TEMPERATURE_HUMIDITY,
31 HOME_SCREEN_TIME,
32 HOME_SCREEN_TIME_DATE,
33 HOME_SCREEN_TEMPERATURE_TIME,
34 HOME_SCREEN_MAIN_AND_AUX_TEMPERATURE,
35 HOME_SCREEN_MODE_OR_TEMPERATURE,
36};
37
38namespace Device {
39
40class RemoteDeviceConfig {
41 public:
42 // Registers config field. Register each field separately (only single bit
43 // value are accepted)
44 static void RegisterConfigField(uint64_t fieldBit);
45 // Configures screen saver available modes. Set all available modes
46 // in single call (this method overwrites previous values)
47 static void SetHomeScreenContentAvailable(uint64_t allValues);
48 static uint64_t GetHomeScreenContentAvailable();
49 static enum HomeScreenContent HomeScreenContentBitToEnum(uint64_t fieldBit);
50 static uint64_t HomeScreenEnumToBit(enum HomeScreenContent type);
51 static uint64_t HomeScreenIntToBit(int mode);
52
53 explicit RemoteDeviceConfig(bool firstDeviceConfigAfterRegistration = false);
54 virtual ~RemoteDeviceConfig();
55
56 void processConfig(TSDS_SetDeviceConfig *config);
57
58 uint8_t getResultCode() const;
59 bool isEndFlagReceived() const;
60 bool isSetDeviceConfigRequired() const;
61 // returns false when it failed to build cfg message
62 bool fillSetDeviceConfig(TSDS_SetDeviceConfig *config) const;
63 void handleSetDeviceConfigResult(TSDS_SetDeviceConfigResult *result);
64
65 private:
66 void processStatusLedConfig(uint64_t fieldBit,
68 void processPowerStatusLedConfig(uint64_t fieldBit,
70 void processScreenBrightnessConfig(uint64_t fieldBit,
72 void processButtonVolumeConfig(uint64_t fieldBit,
74 void processHomeScreenContentConfig(uint64_t fieldBit,
76 void processHomeScreenDelayConfig(uint64_t fieldBit,
78 void processAutomaticTimeSyncConfig(uint64_t fieldBit,
80 void processDisableUserInterfaceConfig(
81 uint64_t fieldBit, TDeviceConfig_DisableUserInterface *config);
82 void processHomeScreenDelayTypeConfig(
83 uint64_t fieldBit, TDeviceConfig_HomeScreenOffDelayType *config);
84
85 void fillStatusLedConfig(TDeviceConfig_StatusLed *config) const;
86 void fillPowerStatusLedConfig(TDeviceConfig_PowerStatusLed *config) const;
87 void fillScreenBrightnessConfig(TDeviceConfig_ScreenBrightness *config) const;
88 void fillButtonVolumeConfig(TDeviceConfig_ButtonVolume *config) const;
89 void fillHomeScreenContentConfig(
91 void fillHomeScreenDelayConfig(
93 void fillAutomaticTimeSyncConfig(
95 void fillDisableUserInterfaceConfig(
97 void fillHomeScreenDelayTypeConfig(
99
100 bool endFlagReceived = false;
101 uint8_t resultCode = 255;
102 int messageCounter = 0;
103 bool firstDeviceConfigAfterRegistration = false;
104 uint64_t requireSetDeviceConfigFields = 0;
105
106 static uint64_t fieldBitsUsedByDevice;
107 static uint64_t homeScreenContentAvailable;
108};
109
110} // namespace Device
111} // namespace Supla
112
113#endif // SRC_SUPLA_DEVICE_REMOTE_DEVICE_CONFIG_H_
Definition proto.h:2828
Definition proto.h:2815
Definition proto.h:2819
Definition proto.h:2854
Definition proto.h:2833
Definition proto.h:2805
Definition proto.h:2809
Definition proto.h:2801
Definition proto.h:2767
Definition proto.h:2755