2020-10-25 20:48:57 +01:00
|
|
|
/*
|
|
|
|
***************************************************************************
|
|
|
|
** Program : OTGW-firmware.h
|
2021-01-31 23:44:58 +01:00
|
|
|
** Version : v0.7.3
|
2020-10-25 20:48:57 +01:00
|
|
|
**
|
2021-01-11 00:37:30 +01:00
|
|
|
** Copyright (c) 2021 Robert van den Breemen
|
2020-10-25 20:48:57 +01:00
|
|
|
**
|
|
|
|
** TERMS OF USE: MIT License. See bottom of file.
|
|
|
|
***************************************************************************
|
|
|
|
*/
|
2020-10-25 20:35:34 +01:00
|
|
|
|
|
|
|
#include <ezTime.h> // https://github.com/ropg/ezTime
|
|
|
|
#include <TelnetStream.h> // https://github.com/jandrassy/TelnetStream/commit/1294a9ee5cc9b1f7e51005091e351d60c8cddecf
|
|
|
|
#include <ArduinoJson.h> // https://arduinojson.org/
|
2021-01-11 09:12:07 +01:00
|
|
|
#include "Wire.h"
|
2020-10-25 20:35:34 +01:00
|
|
|
#include "Debug.h"
|
|
|
|
#include "safeTimers.h"
|
|
|
|
#include "networkStuff.h"
|
2021-01-30 18:35:11 +01:00
|
|
|
#include "OTGW-Core.h" // Core code for this firmware
|
|
|
|
#include "OTGW-upgrade.h" // Schelte Bron's upgrade PIC code
|
2020-10-25 20:35:34 +01:00
|
|
|
|
2021-01-11 09:12:07 +01:00
|
|
|
//Defaults and macro definitions
|
2021-01-30 16:00:16 +01:00
|
|
|
#define _HOSTNAME "OTGW"
|
2020-10-25 20:35:34 +01:00
|
|
|
#define SETTINGS_FILE "/settings.ini"
|
2020-12-29 14:13:29 +01:00
|
|
|
#define CMSG_SIZE 512
|
2020-10-25 20:35:34 +01:00
|
|
|
#define JSON_BUFF_MAX 1024
|
2020-12-29 14:13:29 +01:00
|
|
|
#define CSTR(x) x.c_str()
|
2021-01-03 23:12:19 +01:00
|
|
|
#define CBOOLEAN(x) (x?"True":"False")
|
|
|
|
#define CONOFF(x) (x?"On":"Off")
|
2021-01-31 23:43:52 +01:00
|
|
|
#define CBINARY(x) (x?"1":"0")
|
|
|
|
#define EVALBOOLEAN(x) (stricmp(x,"true")==0||stricmp(x,"on")==0||stricmp(x,"1")==0)
|
2020-10-25 20:35:34 +01:00
|
|
|
|
2021-01-11 09:12:07 +01:00
|
|
|
//Global variables
|
2020-10-25 22:56:18 +01:00
|
|
|
WiFiClient wifiClient;
|
2020-10-25 23:25:49 +01:00
|
|
|
bool Verbose = false;
|
|
|
|
char cMsg[CMSG_SIZE];
|
|
|
|
char fChar[10];
|
|
|
|
String lastReset = "";
|
2021-01-31 23:43:52 +01:00
|
|
|
uint64_t upTimeSeconds = 0;
|
|
|
|
uint32_t rebootCount = 0;
|
|
|
|
Timezone myTZ;
|
2020-10-25 20:35:34 +01:00
|
|
|
|
2020-12-29 14:13:29 +01:00
|
|
|
const char *weekDayName[] { "Unknown", "Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Unknown" };
|
2020-10-25 20:35:34 +01:00
|
|
|
const char *flashMode[] { "QIO", "QOUT", "DIO", "DOUT", "Unknown" };
|
|
|
|
|
2021-01-31 23:43:52 +01:00
|
|
|
//Information on OTGW
|
|
|
|
String sPICfwversion = "";
|
2020-12-29 14:13:29 +01:00
|
|
|
|
|
|
|
//All things that are settings
|
2020-12-31 02:20:47 +01:00
|
|
|
String settingHostname = _HOSTNAME;
|
2020-10-25 22:56:18 +01:00
|
|
|
//MQTT settings
|
2021-01-31 23:43:52 +01:00
|
|
|
bool settingMQTTenable = true;
|
|
|
|
bool settingMQTTsecure = false;
|
2020-10-25 23:25:49 +01:00
|
|
|
String settingMQTTbroker= "192.168.88.254";
|
2020-12-31 02:20:47 +01:00
|
|
|
int16_t settingMQTTbrokerPort = 1883;
|
2020-10-25 22:56:18 +01:00
|
|
|
String settingMQTTuser = "";
|
|
|
|
String settingMQTTpasswd = "";
|
|
|
|
String settingMQTTtopTopic = "OTGW";
|
2021-01-31 23:43:52 +01:00
|
|
|
String settingTimezone = "NL"; //Default
|
2020-10-25 22:56:18 +01:00
|
|
|
|
2021-01-11 09:12:07 +01:00
|
|
|
// That's all folks...
|
2021-01-30 18:35:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
* persons to whom the Software is furnished to do so, subject to the
|
|
|
|
* following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
|
|
|
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
****************************************************************************
|
|
|
|
*/
|