MeterLogger
config.h
Go to the documentation of this file.
1 /* config.h
2 *
3 * Copyright (c) 2014-2015, Tuan PM <tuanpm at live dot com>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of Redis nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without
16 * specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef USER_CONFIG_H_
32 #define USER_CONFIG_H_
33 #include "user_config.h"
34 #include "cron/cron.h"
35 
36 #ifdef IMPULSE
37 #define METER_SERIAL_LEN 13
38 #else
39 #define METER_SERIAL_LEN 8
40 #endif
41 
42 static const char key[] = KEY;
43 
44 typedef struct{
45  uint32_t cfg_holder;
46  uint8_t device_id[16];
47 
48  uint8_t sta_ssid[64];
49  uint8_t sta_pwd[64];
50  uint32_t sta_type;
51  bool ap_enabled;
52 
53  uint8_t mqtt_host[64];
54  uint32_t mqtt_port;
55  uint8_t mqtt_user[32];
56  uint8_t mqtt_pass[32];
57  uint32_t mqtt_keepalive;
58  uint8_t security;
59  uint8_t key[16];
60 #ifndef IMPULSE
61  uint8_t ac_thermo_state; // thermo actuator state
62  uint32_t offline_close_at; // close thermo actuator at kwh set via mqtt open_at_delta function
64 #else
65  char impulse_meter_serial[METER_SERIAL_LEN];
66  char impulse_meter_energy[32 + 1]; // in Wh
67  char impulses_per_kwh[32 + 1];
68  volatile uint32_t impulse_meter_count;
69 #endif // IMPULSE
70  uint16_t ccit_crc16;
71 } syscfg_t;
72 
73 typedef struct {
75  uint8 pad[3];
76 } SAVE_FLAG;
77 
82 
83 extern syscfg_t sys_cfg;
84 
85 #endif /* USER_CONFIG_H_ */
cron_jobs_t cron_jobs
Definition: config.h:63
#define KEY
Definition: user_config.h:62
uint32_t sta_type
Definition: config.h:50
uint32_t offline_close_at
Definition: config.h:62
syscfg_t sys_cfg
Definition: config.c:12
#define ICACHE_FLASH_ATTR
Definition: c_types.h:99
uint8_t security
Definition: config.h:58
void ICACHE_FLASH_ATTR cfg_save_defered()
Definition: config.c:144
uint32_t cfg_holder
Definition: config.h:45
bool ap_enabled
Definition: config.h:51
unsigned char uint8
Definition: c_types.h:45
uint32_t mqtt_port
Definition: config.h:54
#define METER_SERIAL_LEN
Definition: config.h:39
static const char key[]
Definition: config.h:42
uint8 flag
Definition: config.h:74
uint16_t ccit_crc16
Definition: config.h:70
ICACHE_FLASH_ATTR void config_save_timer_func(void *arg)
Definition: config.c:151
uint32_t mqtt_keepalive
Definition: config.h:57
void ICACHE_FLASH_ATTR cfg_load()
Definition: config.c:77
uint8_t ac_thermo_state
Definition: config.h:61
void ICACHE_FLASH_ATTR cfg_save()
Definition: config.c:28