STIMA  3
stima-config.h
Go to the documentation of this file.
1 
3 /*********************************************************************
4 Copyright (C) 2017 Marco Baldinetti <m.baldinetti@digiteco.it>
5 authors:
6 Paolo Patruno <p.patruno@iperbole.bologna.it>
7 Marco Baldinetti <m.baldinetti@digiteco.it>
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **********************************************************************/
22 
23 #ifndef _STIMA_CONFIG_H
24 #define _STIMA_CONFIG_H
25 
26 #include <sensors_config.h>
27 #include <constantdata_config.h>
28 
29 /*********************************************************************
30 * MODULE
31 *********************************************************************/
36 #define MODULE_MAIN_VERSION (3)
37 
42 #define MODULE_MINOR_VERSION (18)
43 
48 #define MODULE_CONFIGURATION_VERSION (2)
49 
50 
55 #define MODULE_TYPE (STIMA_MODULE_TYPE_REPORT_GSM)
56 
57 #if (MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE)
62 #define USE_MQTT (false)
63 #else
68 #define USE_MQTT (true)
69 #endif
70 
75 #define USE_LCD (true)
76 
81 #define USE_SDCARD (false | USE_MQTT)
82 
83 #if (MODULE_TYPE != STIMA_MODULE_TYPE_PASSIVE)
88 #define USE_NTP (true)
89 #endif
90 
95 #define USE_RTC (true)
96 
101 #define USE_TIMER_1 (!USE_RTC)
102 
107 #define USE_RPC_METHOD_CONFIGURE (true)
108 
113 #define USE_RPC_METHOD_PREPARE (false)
114 
119 #define USE_RPC_METHOD_PREPANDGET (false)
120 
125 #define USE_RPC_METHOD_GETJSON (false)
126 
131 #define USE_RPC_METHOD_REBOOT (true)
132 
133 
138 #define USE_RPC_METHOD_RECOVERY (true)
139 
140 /*********************************************************************
141 * CONFIGURATION
142 *********************************************************************/
147 #define CONFIGURATION_DEFAULT_TH_ADDRESS (I2C_TH_DEFAULT_ADDRESS)
148 
153 #define CONFIGURATION_DEFAULT_RAIN_ADDRESS (I2C_RAIN_DEFAULT_ADDRESS)
154 
159 #define CONFIGURATION_RESET_PIN (8)
160 
165 #define CONFIGURATION_DEFAULT_NTP_SERVER (NTP_DEFAULT_SERVER)
166 
167 #if (USE_MQTT)
172 #define CONFIGURATION_DEFAULT_MQTT_PORT (MQTT_DEFAULT_PORT)
173 
178 #define CONFIGURATION_DEFAULT_MQTT_SERVER (MQTT_DEFAULT_SERVER)
179 
184 #define CONFIGURATION_DEFAULT_MQTT_ROOT_TOPIC (MQTT_DEFAULT_ROOT_TOPIC)
185 
190 #define CONFIGURATION_DEFAULT_MQTT_MAINT_TOPIC (MQTT_DEFAULT_MAINT_TOPIC)
191 
196 #define CONFIGURATION_DEFAULT_MQTT_RPC_TOPIC (MQTT_DEFAULT_RPC_TOPIC)
197 
202 #define CONFIGURATION_DEFAULT_MQTT_USERNAME (MQTT_DEFAULT_USERNAME)
203 
208 #define CONFIGURATION_DEFAULT_MQTT_PASSWORD (MQTT_DEFAULT_PASSWORD)
209 
214 #define CONFIGURATION_DEFAULT_STATIONSLUG (DEFAULT_STATIONSLUG)
215 
220 #define CONFIGURATION_DEFAULT_BOARDSLUG (DEFAULT_BOARDSLUG)
221 
222 #endif
223 
224 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
229 #define CONFIGURATION_DEFAULT_ETHERNET_DHCP_ENABLE (ETHERNET_DEFAULT_DHCP_ENABLE)
230 
235 #define CONFIGURATION_DEFAULT_ETHERNET_MAC (ETHERNET_DEFAULT_MAC)
236 
241 #define CONFIGURATION_DEFAULT_ETHERNET_IP (ETHERNET_DEFAULT_IP)
242 
247 #define CONFIGURATION_DEFAULT_ETHERNET_NETMASK (ETHERNET_DEFAULT_NETMASK)
248 
253 #define CONFIGURATION_DEFAULT_ETHERNET_GATEWAY (ETHERNET_DEFAULT_GATEWAY)
254 
259 #define CONFIGURATION_DEFAULT_ETHERNET_PRIMARY_DNS (ETHERNET_DEFAULT_PRIMARY_DNS)
260 
261 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
266 #define CONFIGURATION_DEFAULT_GSM_APN (GSM_DEFAULT_APN)
267 
272 #define CONFIGURATION_DEFAULT_GSM_USERNAME (GSM_DEFAULT_USERNAME)
273 
278 #define CONFIGURATION_DEFAULT_GSM_PASSWORD (GSM_DEFAULT_PASSWORD)
279 
280 #endif
281 
282 /*********************************************************************
283 * SENSORS
284 *********************************************************************/
285 
290 #define SENSOR_ERROR_COUNT_MAX (20)
291 
292 /*********************************************************************
293 * POWER DOWN
294 *********************************************************************/
295 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
300 #define USE_POWER_DOWN (false)
301 
302 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE)
307 #define USE_POWER_DOWN (true)
308 
309 #endif
310 
315 #define DEBOUNCING_POWER_DOWN_TIME_MS (10)
316 
317 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
322 #define W5500_CHIP_SELECT_PIN (10)
323 
324 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
329 #define GSM_ON_OFF_PIN (SIM800_ON_OFF_PIN)
330 
331 #if (USE_SIM_800L)
336 #define GSM_RESET_PIN (SIM800_RESET_PIN)
337 #endif
338 
339 #endif
340 
341 #if (USE_SDCARD)
346 #define SDCARD_CHIP_SELECT_PIN (7)
347 
352 #define SDCARD_INFO_FILE_NAME ("info.dat")
353 
358 #define SDCARD_LOGGING_FILE_NAME ("stima.log")
359 
364 #define SDCARD_CONFIG_FILE_NAME ("config.cfg")
365 
370 #define SDCARD_CONFIG_SAVED_FILE_NAME ("config.sav")
371 
372 #endif
373 
374 /*********************************************************************
375 * WATCHDOG
376 *********************************************************************/
385 #ifdef ARDUINO_ARCH_AVR
386 #define WDT_TIMER (WDTO_8S)
387 #else
388 #define WDT_TIMER (8)
389 #endif
390 
391 /*********************************************************************
392 * RTC
393 *********************************************************************/
398 #define RTC_FREQUENCY (PCF8563_CLKOUT_FREQUENCY_SECONDS)
399 
404 #define RTC_INTERRUPT_PIN (6)
405 
406 /*********************************************************************
407 * TIMER1
408 *********************************************************************/
413 #define TIMER1_INTERRUPT_TIME_MS (1000)
414 
419 #define TIMER1_TCNT1_VALUE (0xFFFFUL - (TIMER1_INTERRUPT_TIME_MS*1000UL/(1024 / (F_CPU/1000000)))+1)
420 
421 
422 /*********************************************************************
423 * CONSTANT DATA
424 *********************************************************************/
429 #define USE_CONSTANTDATA_COUNT (3)
430 
431 /*********************************************************************
432 * TASKS
433 *********************************************************************/
438 #define SENSORS_RETRY_COUNT_MAX (5)
439 
444 #define SENSORS_RETRY_DELAY_MS (100)
445 
450 #define SENSORS_TESTING_DELAY_S (60)
451 
456 #define DATA_PROCESSING_RETRY_COUNT_MAX (2)
457 
462 #define DATA_PROCESSING_RETRY_DELAY_MS (500)
463 
468 #define DATA_SAVING_RETRY_COUNT_MAX (2)
469 
474 #define DATA_SAVING_DELAY_MS (100)
475 
480 #define MQTT_RETRY_COUNT_MAX (3)
481 
486 #define MQTT_DELAY_MS (3000)
487 
492 #define IP_STACK_TIMEOUT_MS (MQTT_TIMEOUT_MS)
493 
498 #define SUPERVISOR_CONNECTION_RETRY_COUNT_MAX (3)
499 
504 #define SUPERVISOR_CONNECTION_TIMEOUT_MS (120000)
505 
506 #if (USE_SDCARD)
511 #define SDCARD_MQTT_PTR_FILE_NAME ("mqtt_ptr.txt")
512 
518 #define SDCARD_MQTT_PTR_RPC_FILE_NAME ("rpc_ptr.txt")
519 
520 #endif
521 
526 #define NTP_RETRY_COUNT_MAX (5)
527 
532 #define NTP_RETRY_DELAY_MS (1000)
533 
538 #define NTP_TIME_FOR_RESYNC_S (SECS_PER_DAY)
539 
540 #define NTP_MAX_DIFF_VALID_TIME_S (SECS_PER_DAY)
541 
546 #define LCD_TIME_FOR_REINITIALIZE_S (SECS_PER_DAY)
547 
552 #define DISPLAY_SET_MAX (2)
553 
554 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
559 #define ETHERNET_RETRY_COUNT_MAX (5)
560 
565 #define ETHERNET_RETRY_DELAY_MS (ETHERNET_ATTEMPT_MS)
566 
567 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
568 #endif
569 
574 #define DATE_TIME_STRING_LENGTH (25)
575 
576 #endif