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#include <supla/modbus/modbus_configurator.h>
25
26namespace Supla {
27
28enum class HomeScreenContent {
29 HOME_SCREEN_OFF,
30 HOME_SCREEN_TEMPERATURE,
31 HOME_SCREEN_TEMPERATURE_HUMIDITY,
32 HOME_SCREEN_TIME,
33 HOME_SCREEN_TIME_DATE,
34 HOME_SCREEN_TEMPERATURE_TIME,
35 HOME_SCREEN_MAIN_AND_AUX_TEMPERATURE,
36 HOME_SCREEN_MODE_OR_TEMPERATURE,
37};
38
39namespace Device {
40
41class RemoteDeviceConfig {
42 public:
43 // Registers config field. Register each field separately (only single bit
44 // value are accepted)
45 static void RegisterConfigField(uint64_t fieldBit);
46 // Configures screen saver available modes. Set all available modes
47 // in single call (this method overwrites previous values)
48 static void SetHomeScreenContentAvailable(uint64_t allValues);
49 static uint64_t GetHomeScreenContentAvailable();
50 static enum HomeScreenContent HomeScreenContentBitToEnum(uint64_t fieldBit);
51 static uint64_t HomeScreenEnumToBit(enum HomeScreenContent type);
52 static uint64_t HomeScreenIntToBit(int mode);
53 static void SetModbusProperties(
54 const Supla::Modbus::ConfigProperties &modbusProperties);
55 static void ClearResendAttemptsCounter();
56
57 explicit RemoteDeviceConfig(bool firstDeviceConfigAfterRegistration = false);
58 virtual ~RemoteDeviceConfig();
59
60 void processConfig(TSDS_SetDeviceConfig *config);
61
62 uint8_t getResultCode() const;
63 bool isEndFlagReceived() const;
64 bool isSetDeviceConfigRequired() const;
65 // returns false when it failed to build cfg message
66 bool fillSetDeviceConfig(TSDS_SetDeviceConfig *config) const;
67 void handleSetDeviceConfigResult(TSDS_SetDeviceConfigResult *result);
68
69 private:
70 void processStatusLedConfig(uint64_t fieldBit,
72 void processPowerStatusLedConfig(uint64_t fieldBit,
74 void processScreenBrightnessConfig(uint64_t fieldBit,
76 void processButtonVolumeConfig(uint64_t fieldBit,
78 void processHomeScreenContentConfig(uint64_t fieldBit,
80 void processHomeScreenDelayConfig(uint64_t fieldBit,
82 void processAutomaticTimeSyncConfig(uint64_t fieldBit,
84 void processDisableUserInterfaceConfig(
85 uint64_t fieldBit, TDeviceConfig_DisableUserInterface *config);
86 void processHomeScreenDelayTypeConfig(
87 uint64_t fieldBit, TDeviceConfig_HomeScreenOffDelayType *config);
88 void processModbusConfig(uint64_t fieldBit, TDeviceConfig_Modbus *config);
89
90 void fillStatusLedConfig(TDeviceConfig_StatusLed *config) const;
91 void fillPowerStatusLedConfig(TDeviceConfig_PowerStatusLed *config) const;
92 void fillScreenBrightnessConfig(TDeviceConfig_ScreenBrightness *config) const;
93 void fillButtonVolumeConfig(TDeviceConfig_ButtonVolume *config) const;
94 void fillHomeScreenContentConfig(
96 void fillHomeScreenDelayConfig(
98 void fillAutomaticTimeSyncConfig(
100 void fillDisableUserInterfaceConfig(
102 void fillHomeScreenDelayTypeConfig(
104 void fillModbusConfig(TDeviceConfig_Modbus *config) const;
105
106 bool endFlagReceived = false;
107 uint8_t resultCode = 255;
108 int messageCounter = 0;
109 bool firstDeviceConfigAfterRegistration = false;
110 uint64_t requireSetDeviceConfigFields = 0;
111
112 static uint64_t fieldBitsUsedByDevice;
113 static uint64_t homeScreenContentAvailable;
114 static Supla::Modbus::ConfigProperties modbusProperties;
115 static uint8_t resendAttempts;
116};
117
118} // namespace Device
119} // namespace Supla
120
121#endif // SRC_SUPLA_DEVICE_REMOTE_DEVICE_CONFIG_H_
Definition modbus_configurator.h:64
Definition proto.h:2853
Definition proto.h:2840
Definition proto.h:2844
Definition proto.h:2879
Definition proto.h:2858
Definition proto.h:2950
Definition proto.h:2830
Definition proto.h:2834
Definition proto.h:2826
Definition proto.h:2792
Definition proto.h:2780