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 #include <stima_module.h>
29 
30 /*********************************************************************
31 * MODULE
32 *********************************************************************/
37 #define MODULE_MAIN_VERSION (3)
38 
43 #define MODULE_MINOR_VERSION (11)
44 
49 #define MODULE_CONFIGURATION_VERSION (2)
50 
51 
56 #define MODULE_TYPE (STIMA_MODULE_TYPE_REPORT_GSM)
57 
58 #if (MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE)
63 #define USE_MQTT (false)
64 #else
69 #define USE_MQTT (true)
70 #endif
71 
76 #define USE_LCD (true)
77 
82 #define USE_SDCARD (false | USE_MQTT)
83 
84 #if (MODULE_TYPE != STIMA_MODULE_TYPE_PASSIVE)
89 #define USE_NTP (true)
90 #endif
91 
96 #define USE_RTC (true)
97 
102 #define USE_TIMER_1 (!USE_RTC)
103 
108 #define USE_RPC_METHOD_CONFIGURE (true)
109 
114 #define USE_RPC_METHOD_PREPARE (false)
115 
120 #define USE_RPC_METHOD_PREPANDGET (false)
121 
126 #define USE_RPC_METHOD_GETJSON (false)
127 
132 #define USE_RPC_METHOD_REBOOT (true)
133 
134 
139 #define USE_RPC_METHOD_RECOVERY (true)
140 
141 /*********************************************************************
142 * CONFIGURATION
143 *********************************************************************/
148 #define CONFIGURATION_DEFAULT_TH_ADDRESS (I2C_TH_DEFAULT_ADDRESS)
149 
154 #define CONFIGURATION_DEFAULT_RAIN_ADDRESS (I2C_RAIN_DEFAULT_ADDRESS)
155 
160 #define CONFIGURATION_RESET_PIN (8)
161 
166 #define CONFIGURATION_DEFAULT_NTP_SERVER (NTP_DEFAULT_SERVER)
167 
168 #if (USE_MQTT)
173 #define CONFIGURATION_DEFAULT_MQTT_PORT (MQTT_DEFAULT_PORT)
174 
179 #define CONFIGURATION_DEFAULT_MQTT_SERVER (MQTT_DEFAULT_SERVER)
180 
185 #define CONFIGURATION_DEFAULT_MQTT_ROOT_TOPIC (MQTT_DEFAULT_ROOT_TOPIC)
186 
191 #define CONFIGURATION_DEFAULT_MQTT_MAINT_TOPIC (MQTT_DEFAULT_MAINT_TOPIC)
192 
197 #define CONFIGURATION_DEFAULT_MQTT_RPC_TOPIC (MQTT_DEFAULT_RPC_TOPIC)
198 
203 #define CONFIGURATION_DEFAULT_MQTT_USERNAME (MQTT_DEFAULT_USERNAME)
204 
209 #define CONFIGURATION_DEFAULT_MQTT_PASSWORD (MQTT_DEFAULT_PASSWORD)
210 
215 #define CONFIGURATION_DEFAULT_STATIONSLUG (DEFAULT_STATIONSLUG)
216 
221 #define CONFIGURATION_DEFAULT_BOARDSLUG (DEFAULT_BOARDSLUG)
222 
223 #endif
224 
225 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
230 #define CONFIGURATION_DEFAULT_ETHERNET_DHCP_ENABLE (ETHERNET_DEFAULT_DHCP_ENABLE)
231 
236 #define CONFIGURATION_DEFAULT_ETHERNET_MAC (ETHERNET_DEFAULT_MAC)
237 
242 #define CONFIGURATION_DEFAULT_ETHERNET_IP (ETHERNET_DEFAULT_IP)
243 
248 #define CONFIGURATION_DEFAULT_ETHERNET_NETMASK (ETHERNET_DEFAULT_NETMASK)
249 
254 #define CONFIGURATION_DEFAULT_ETHERNET_GATEWAY (ETHERNET_DEFAULT_GATEWAY)
255 
260 #define CONFIGURATION_DEFAULT_ETHERNET_PRIMARY_DNS (ETHERNET_DEFAULT_PRIMARY_DNS)
261 
262 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
267 #define CONFIGURATION_DEFAULT_GSM_APN (GSM_DEFAULT_APN)
268 
273 #define CONFIGURATION_DEFAULT_GSM_USERNAME (GSM_DEFAULT_USERNAME)
274 
279 #define CONFIGURATION_DEFAULT_GSM_PASSWORD (GSM_DEFAULT_PASSWORD)
280 
281 #endif
282 
283 /*********************************************************************
284 * SENSORS
285 *********************************************************************/
286 
291 #define SENSOR_ERROR_COUNT_MAX (20)
292 
293 /*********************************************************************
294 * POWER DOWN
295 *********************************************************************/
296 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
301 #define USE_POWER_DOWN (false)
302 
303 #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)
308 #define USE_POWER_DOWN (true)
309 
310 #endif
311 
316 #define DEBOUNCING_POWER_DOWN_TIME_MS (10)
317 
318 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
323 #define W5500_CHIP_SELECT_PIN (10)
324 
325 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
330 #define GSM_ON_OFF_PIN (SIM800_ON_OFF_PIN)
331 
332 #if (USE_SIM_800L)
337 #define GSM_RESET_PIN (SIM800_RESET_PIN)
338 #endif
339 
340 #endif
341 
342 #if (USE_SDCARD)
347 #define SDCARD_CHIP_SELECT_PIN (7)
348 
353 #define SDCARD_INFO_FILE_NAME ("info.dat")
354 
359 #define SDCARD_LOGGING_FILE_NAME ("stima.log")
360 
365 #define SDCARD_CONFIG_FILE_NAME ("config.cfg")
366 
371 #define SDCARD_CONFIG_SAVED_FILE_NAME ("config.sav")
372 
373 #endif
374 
375 /*********************************************************************
376 * WATCHDOG
377 *********************************************************************/
386 #ifdef ARDUINO_ARCH_AVR
387 #define WDT_TIMER (WDTO_8S)
388 #else
389 #define WDT_TIMER (8)
390 #endif
391 
392 /*********************************************************************
393 * RTC
394 *********************************************************************/
399 #define RTC_FREQUENCY (PCF8563_CLKOUT_FREQUENCY_SECONDS)
400 
405 #define RTC_INTERRUPT_PIN (6)
406 
407 /*********************************************************************
408 * TIMER1
409 *********************************************************************/
414 #define TIMER1_INTERRUPT_TIME_MS (1000)
415 
420 #define TIMER1_TCNT1_VALUE (0xFFFFUL - (TIMER1_INTERRUPT_TIME_MS*1000UL/(1024 / (F_CPU/1000000)))+1)
421 
422 
423 /*********************************************************************
424 * CONSTANT DATA
425 *********************************************************************/
430 #define USE_CONSTANTDATA_COUNT (3)
431 
432 /*********************************************************************
433 * TASKS
434 *********************************************************************/
439 #define SENSORS_RETRY_COUNT_MAX (3)
440 
445 #define SENSORS_RETRY_DELAY_MS (50)
446 
451 #define SENSORS_TESTING_DELAY_S (60)
452 
457 #define DATA_PROCESSING_RETRY_COUNT_MAX (2)
458 
463 #define DATA_PROCESSING_RETRY_DELAY_MS (500)
464 
469 #define DATA_SAVING_RETRY_COUNT_MAX (2)
470 
475 #define DATA_SAVING_DELAY_MS (100)
476 
481 #define MQTT_RETRY_COUNT_MAX (3)
482 
487 #define MQTT_DELAY_MS (3000)
488 
493 #define IP_STACK_TIMEOUT_MS (MQTT_TIMEOUT_MS)
494 
499 #define SUPERVISOR_CONNECTION_RETRY_COUNT_MAX (3)
500 
505 #define SUPERVISOR_CONNECTION_TIMEOUT_MS (120000)
506 
507 #if (USE_SDCARD)
512 #define SDCARD_MQTT_PTR_FILE_NAME ("mqtt_ptr.txt")
513 
519 #define SDCARD_MQTT_PTR_RPC_FILE_NAME ("rpc_ptr.txt")
520 
521 #endif
522 
527 #define NTP_RETRY_COUNT_MAX (5)
528 
533 #define NTP_RETRY_DELAY_MS (1000)
534 
539 #define NTP_TIME_FOR_RESYNC_S (SECS_PER_DAY)
540 
541 #define NTP_MAX_DIFF_VALID_TIME_S (SECS_PER_DAY)
542 
547 #define LCD_TIME_FOR_REINITIALIZE_S (SECS_PER_DAY)
548 
553 #define DISPLAY_SET_MAX (2)
554 
555 #if (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_ETH || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_ETH)
560 #define ETHERNET_RETRY_COUNT_MAX (5)
561 
566 #define ETHERNET_RETRY_DELAY_MS (ETHERNET_ATTEMPT_MS)
567 
568 #elif (MODULE_TYPE == STIMA_MODULE_TYPE_SAMPLE_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_REPORT_GSM || MODULE_TYPE == STIMA_MODULE_TYPE_PASSIVE_GSM)
569 #endif
570 
575 #define DATE_TIME_STRING_LENGTH (25)
576 
577 #endif