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 void processFirmwareUpdateConfig(
90 uint64_t fieldBit, TDeviceConfig_FirmwareUpdate *config);
91
92 void fillStatusLedConfig(TDeviceConfig_StatusLed *config) const;
93 void fillPowerStatusLedConfig(TDeviceConfig_PowerStatusLed *config) const;
94 void fillScreenBrightnessConfig(TDeviceConfig_ScreenBrightness *config) const;
95 void fillButtonVolumeConfig(TDeviceConfig_ButtonVolume *config) const;
96 void fillHomeScreenContentConfig(
98 void fillHomeScreenDelayConfig(
100 void fillAutomaticTimeSyncConfig(
101 TDeviceConfig_AutomaticTimeSync *config) const;
102 void fillDisableUserInterfaceConfig(
104 void fillHomeScreenDelayTypeConfig(
106 void fillModbusConfig(TDeviceConfig_Modbus *config) const;
107 void fillFirmwareUpdateConfig(TDeviceConfig_FirmwareUpdate *config) const;
108
109 bool endFlagReceived = false;
110 uint8_t resultCode = 255;
111 int messageCounter = 0;
112 bool firstDeviceConfigAfterRegistration = false;
113 uint64_t requireSetDeviceConfigFields = 0;
114
115 static uint64_t fieldBitsUsedByDevice;
116 static uint64_t homeScreenContentAvailable;
117 static Supla::Modbus::ConfigProperties modbusProperties;
118 static uint8_t resendAttempts;
119};
120
121} // namespace Device
122} // namespace Supla
123
124#endif // SRC_SUPLA_DEVICE_REMOTE_DEVICE_CONFIG_H_
Definition modbus_configurator.h:64
Definition proto.h:2869
Definition proto.h:2856
Definition proto.h:2860
Definition proto.h:2987
Definition proto.h:2895
Definition proto.h:2874
Definition proto.h:2966
Definition proto.h:2846
Definition proto.h:2850
Definition proto.h:2842
Definition proto.h:2808
Definition proto.h:2796