mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
some fix
This commit is contained in:
3
Init.ino
3
Init.ino
@@ -263,7 +263,8 @@ void statistics() {
|
||||
#endif
|
||||
urls += "&";
|
||||
//-----------------------------------------------------------------
|
||||
urls += DATE_COMPILING + "_" + firmware_version;
|
||||
urls += "firm version: " + firmware_version + " " + DATE_COMPILING + " " + TIME_COMPILING;
|
||||
//-----------------------------------------------------------------
|
||||
String stat = getURL(urls);
|
||||
//Serial.println(stat);
|
||||
}
|
||||
|
||||
87
Ticker_for_TickerScheduler/Ticker/Ticker.cpp
Normal file
87
Ticker_for_TickerScheduler/Ticker/Ticker.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Ticker.cpp - esp8266 library that calls functions periodically
|
||||
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "c_types.h"
|
||||
#include "eagle_soc.h"
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
|
||||
static const int ONCE = 0;
|
||||
static const int REPEAT = 1;
|
||||
|
||||
#include "Ticker.h"
|
||||
|
||||
Ticker::Ticker()
|
||||
: _timer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Ticker::~Ticker()
|
||||
{
|
||||
detach();
|
||||
}
|
||||
|
||||
void Ticker::_attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg)
|
||||
{
|
||||
if (_timer)
|
||||
{
|
||||
os_timer_disarm(_timer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_timer = new ETSTimer;
|
||||
}
|
||||
|
||||
os_timer_setfn(_timer, reinterpret_cast<ETSTimerFunc*>(callback), reinterpret_cast<void*>(arg));
|
||||
os_timer_arm(_timer, milliseconds, (repeat)?REPEAT:ONCE);
|
||||
}
|
||||
|
||||
void Ticker::detach()
|
||||
{
|
||||
if (!_timer)
|
||||
return;
|
||||
|
||||
os_timer_disarm(_timer);
|
||||
delete _timer;
|
||||
_timer = nullptr;
|
||||
_callback_function = nullptr;
|
||||
}
|
||||
|
||||
bool Ticker::active() const
|
||||
{
|
||||
return (bool)_timer;
|
||||
}
|
||||
|
||||
void Ticker::_static_callback(void* arg)
|
||||
{
|
||||
Ticker* _this = (Ticker*)arg;
|
||||
if (_this == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_this->_callback_function)
|
||||
{
|
||||
_this->_callback_function();
|
||||
}
|
||||
}
|
||||
136
Ticker_for_TickerScheduler/Ticker/Ticker.h
Normal file
136
Ticker_for_TickerScheduler/Ticker/Ticker.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Ticker.h - esp8266 library that calls functions periodically
|
||||
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef TICKER_H
|
||||
#define TICKER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <functional>
|
||||
#include <Schedule.h>
|
||||
|
||||
extern "C" {
|
||||
typedef struct _ETSTIMER_ ETSTimer;
|
||||
}
|
||||
|
||||
class Ticker
|
||||
{
|
||||
public:
|
||||
Ticker();
|
||||
~Ticker();
|
||||
typedef void (*callback_t)(void);
|
||||
typedef void (*callback_with_arg_t)(void*);
|
||||
typedef std::function<void(void)> callback_function_t;
|
||||
|
||||
void attach_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
attach(seconds,std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void attach(float seconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
attach(seconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
void attach_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
attach_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void attach_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
attach_ms(milliseconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void attach(float seconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach() callback argument size must be <= 4 bytes");
|
||||
// C-cast serves two purposes:
|
||||
// static_cast for smaller integer types,
|
||||
// reinterpret_cast + const_cast for pointer types
|
||||
uint32_t arg32 = (uint32_t)arg;
|
||||
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach_ms() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)arg;
|
||||
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
void once_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
once(seconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void once(float seconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
once(seconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
void once_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
once_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
}
|
||||
|
||||
void once_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
_callback_function = callback;
|
||||
once_ms(milliseconds, _static_callback, (void*)this);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void once(float seconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)(arg);
|
||||
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
|
||||
{
|
||||
static_assert(sizeof(TArg) <= sizeof(uint32_t), "attach_ms() callback argument size must be <= 4 bytes");
|
||||
uint32_t arg32 = (uint32_t)(arg);
|
||||
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
|
||||
}
|
||||
|
||||
void detach();
|
||||
bool active() const;
|
||||
|
||||
protected:
|
||||
void _attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg);
|
||||
static void _static_callback (void* arg);
|
||||
|
||||
protected:
|
||||
ETSTimer* _timer;
|
||||
callback_function_t _callback_function = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif//TICKER_H
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Basic Ticker usage
|
||||
|
||||
Ticker is an object that will call a given function with a certain period.
|
||||
Each Ticker calls one function. You can have as many Tickers as you like,
|
||||
memory being the only limitation.
|
||||
|
||||
A function may be attached to a ticker and detached from the ticker.
|
||||
There are two variants of the attach function: attach and attach_ms.
|
||||
The first one takes period in seconds, the second one in milliseconds.
|
||||
|
||||
The built-in LED will be blinking.
|
||||
*/
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
Ticker flipper;
|
||||
|
||||
int count = 0;
|
||||
|
||||
void flip() {
|
||||
int state = digitalRead(LED_BUILTIN); // get the current state of GPIO1 pin
|
||||
digitalWrite(LED_BUILTIN, !state); // set pin to the opposite state
|
||||
|
||||
++count;
|
||||
// when the counter reaches a certain value, start blinking like crazy
|
||||
if (count == 20) {
|
||||
flipper.attach(0.1, flip);
|
||||
}
|
||||
// when the counter reaches yet another value, stop blinking
|
||||
else if (count == 120) {
|
||||
flipper.detach();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
|
||||
// flip the pin every 0.3s
|
||||
flipper.attach(0.3, flip);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "Arduino.h"
|
||||
#include "Ticker.h"
|
||||
|
||||
#define LED1 2
|
||||
#define LED2 4
|
||||
#define LED3 12
|
||||
#define LED4 14
|
||||
#define LED5 15
|
||||
|
||||
|
||||
class ExampleClass {
|
||||
public:
|
||||
ExampleClass(int pin, int duration) : _pin(pin), _duration(duration) {
|
||||
pinMode(_pin, OUTPUT);
|
||||
_myTicker.attach_ms(_duration, std::bind(&ExampleClass::classBlink, this));
|
||||
}
|
||||
~ExampleClass() {};
|
||||
|
||||
int _pin, _duration;
|
||||
Ticker _myTicker;
|
||||
|
||||
void classBlink() {
|
||||
digitalWrite(_pin, !digitalRead(_pin));
|
||||
}
|
||||
};
|
||||
|
||||
void staticBlink() {
|
||||
digitalWrite(LED2, !digitalRead(LED2));
|
||||
}
|
||||
|
||||
void scheduledBlink() {
|
||||
digitalWrite(LED3, !digitalRead(LED2));
|
||||
}
|
||||
|
||||
void parameterBlink(int p) {
|
||||
digitalWrite(p, !digitalRead(p));
|
||||
}
|
||||
|
||||
Ticker staticTicker;
|
||||
Ticker scheduledTicker;
|
||||
Ticker parameterTicker;
|
||||
Ticker lambdaTicker;
|
||||
|
||||
ExampleClass example(LED1, 100);
|
||||
|
||||
|
||||
void setup() {
|
||||
pinMode(LED2, OUTPUT);
|
||||
staticTicker.attach_ms(100, staticBlink);
|
||||
|
||||
pinMode(LED3, OUTPUT);
|
||||
scheduledTicker.attach_ms_scheduled(100, scheduledBlink);
|
||||
|
||||
pinMode(LED4, OUTPUT);
|
||||
parameterTicker.attach_ms(100, std::bind(parameterBlink, LED4));
|
||||
|
||||
pinMode(LED5, OUTPUT);
|
||||
lambdaTicker.attach_ms(100, []() {
|
||||
digitalWrite(LED5, !digitalRead(LED5));
|
||||
});
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Passing paramters to Ticker callbacks
|
||||
|
||||
Apart from void(void) functions, the Ticker library supports
|
||||
functions taking one argument. This argument's size has to be less or
|
||||
equal to 4 bytes (so char, short, int, float, void*, char* types will do).
|
||||
|
||||
This sample runs two tickers that both call one callback function,
|
||||
but with different arguments.
|
||||
|
||||
The built-in LED will be pulsing.
|
||||
*/
|
||||
|
||||
#include <Ticker.h>
|
||||
|
||||
Ticker tickerSetHigh;
|
||||
Ticker tickerSetLow;
|
||||
|
||||
void setPin(int state) {
|
||||
digitalWrite(LED_BUILTIN, state);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(1, LOW);
|
||||
|
||||
// every 25 ms, call setPin(0)
|
||||
tickerSetLow.attach_ms(25, setPin, 0);
|
||||
|
||||
// every 26 ms, call setPin(1)
|
||||
tickerSetHigh.attach_ms(26, setPin, 1);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
29
Ticker_for_TickerScheduler/Ticker/keywords.txt
Normal file
29
Ticker_for_TickerScheduler/Ticker/keywords.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For Wire
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
attach KEYWORD2
|
||||
attach_ms KEYWORD2
|
||||
once KEYWORD2
|
||||
once_ms KEYWORD2
|
||||
detach KEYWORD2
|
||||
active KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Instances (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
Ticker KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
10
Ticker_for_TickerScheduler/Ticker/library.properties
Normal file
10
Ticker_for_TickerScheduler/Ticker/library.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
name=Ticker
|
||||
version=1.0
|
||||
author=Ivan Grokhtokov <ivan@esp8266.com>
|
||||
maintainer=Ivan Grokhtokov <ivan@esp8266.com>
|
||||
sentence=Allows to call functions with a given interval.
|
||||
paragraph=
|
||||
category=Timing
|
||||
url=
|
||||
architectures=esp8266
|
||||
dot_a_linkage=true
|
||||
@@ -8,8 +8,8 @@ void initUpgrade() {
|
||||
//new_version = getURL("http://91.204.228.124:1100/update/esp8266/version.txt");
|
||||
#endif
|
||||
|
||||
Serial.println("[i] Last firmware version: ");
|
||||
Serial.print(new_version);
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(new_version);
|
||||
|
||||
String tmp = "{}";
|
||||
|
||||
|
||||
1
WiFi.ino
1
WiFi.ino
@@ -107,6 +107,7 @@ bool StartAPMode() {
|
||||
IPAddress myIP = WiFi.softAPIP();
|
||||
Serial.print("AP IP address: ");
|
||||
Serial.println(myIP);
|
||||
jsonWrite(configJson, "ip", myIP.toString());
|
||||
|
||||
if (jsonReadtoInt(optionJson, "pass_status") != 1) {
|
||||
ts.add(ROUTER_SEARCHING, 10 * 1000, [&](void*) {
|
||||
|
||||
@@ -1 +1,17 @@
|
||||
{"SSDP":"MODULES","chipID":"905542-1458415","ssidAP":"WiFi","passwordAP":"","ssid":"your_ssid","password":"your_password","timezone":3,"mqttServer":"","mqttPort":0,"mqttUser":"","mqttPass":"","scenario":"1","timers":"0","pushingbox_id":"","web_login":"admin","web_pass":"admin"}
|
||||
{
|
||||
"SSDP": "MODULES",
|
||||
"chipID": "",
|
||||
"ssidAP": "WiFi",
|
||||
"passwordAP": "",
|
||||
"ssid": "your_ssid",
|
||||
"password": "your_password",
|
||||
"timezone": 3,
|
||||
"mqttServer": "",
|
||||
"mqttPort": 0,
|
||||
"mqttUser": "",
|
||||
"mqttPass": "",
|
||||
"scenario": "1",
|
||||
"pushingbox_id": "",
|
||||
"web_login": "admin",
|
||||
"web_pass": "admin"
|
||||
}
|
||||
@@ -1 +1,17 @@
|
||||
{"SSDP":"MODULES","chipID":"905542-1458415","ssidAP":"WiFi","passwordAP":"","ssid":"MW40V_782C","password":"05978600","timezone":3,"mqttServer":"m12.cloudmqtt.com","mqttPort":14053,"mqttUser":"lbscvzuj","mqttPass":"bLxlveOgaF8F","scenario":"1","timers":"0","pushingbox_id":"","web_login":"admin","web_pass":"admin"}
|
||||
{
|
||||
"SSDP": "MODULES",
|
||||
"chipID": "",
|
||||
"ssidAP": "WiFi",
|
||||
"passwordAP": "",
|
||||
"ssid": "MW40V_782C",
|
||||
"password": "05978600",
|
||||
"timezone": 3,
|
||||
"mqttServer": "m12.cloudmqtt.com",
|
||||
"mqttPort": 14053,
|
||||
"mqttUser": "lbscvzuj",
|
||||
"mqttPass": "bLxlveOgaF8F",
|
||||
"scenario": "1",
|
||||
"pushingbox_id": "",
|
||||
"web_login": "admin",
|
||||
"web_pass": "admin"
|
||||
}
|
||||
@@ -3,22 +3,4 @@ button 2 13 Прихожая Реле 0 2
|
||||
button 3 14 Кухня Реле 0 3
|
||||
pwm 1 3 Яркость#коредор: Реле 1023 4
|
||||
pwm 2 4 Яркость#ванная: Реле 510 5
|
||||
//---------------------------------------------------------------------
|
||||
analog 0 Аналоговый#вход,#% Датчики progress-round 1 1024 1 1024 6
|
||||
inputDigit digit1 При#скольки#включить? Датчики 10 7
|
||||
inputDigit digit2 При#скольки#выключить? Датчики 0 8
|
||||
button 4 na Нагреватель Датчики 0 9
|
||||
//---------------------------------------------------------------------
|
||||
button 5 na Вкл#обратный#таймер Таймеры 0 16
|
||||
inputDigit digit3 Через#сколько#секунд#включить? Таймеры 5 17
|
||||
button 6 na Включится#по#таймеру Таймеры 0 18
|
||||
inputTime time1 Во#сколько#включить? Таймеры 20-30-00 19
|
||||
button 7 5 Включится#по#таймеру Таймеры 0 20
|
||||
//---------------------------------------------------------------------
|
||||
switch 1 0 20
|
||||
text 1 Вход: Охрана 20
|
||||
textSet 1 не#обнаружено-time
|
||||
button 8 na Сбросить Охрана 0 21
|
||||
//---------------------------------------------------------------------
|
||||
button 9 scenario Вкл#выкл#все#сценарии Сценарии 1 23
|
||||
button 10 line1,line2, Вкл#выкл#выбранные#сценарии Сценарии 1 24
|
||||
analog 0 Аналоговый#вход,#% Датчики progress-round 1 1024 1 1024 6
|
||||
@@ -7,27 +7,4 @@ button1 = 0
|
||||
buttonSet 2 0
|
||||
buttonSet 3 0
|
||||
pwmSet 2 0
|
||||
end
|
||||
analog > digit1
|
||||
buttonSet 4 1
|
||||
end
|
||||
analog < digit2
|
||||
buttonSet 4 0
|
||||
end
|
||||
button5 = 1
|
||||
timerStart 1 digit3 sec
|
||||
end
|
||||
timer1 = 0
|
||||
buttonSet 6 1
|
||||
end
|
||||
timenow = time1
|
||||
buttonSet 7 1
|
||||
end
|
||||
switch1 = 1
|
||||
textSet 1 обнаружено#движение-time
|
||||
push Внимание обнаружено#движение!
|
||||
end
|
||||
button8 = 1
|
||||
textSet 1 не#обнаружено-time
|
||||
buttonSet 8 0
|
||||
end
|
||||
@@ -3,22 +3,4 @@ button 2 13 Прихожая Реле 0 2
|
||||
button 3 14 Кухня Реле 0 3
|
||||
pwm 1 3 Яркость#коредор: Реле 1023 4
|
||||
pwm 2 4 Яркость#ванная: Реле 510 5
|
||||
//---------------------------------------------------------------------
|
||||
analog 0 Аналоговый#вход,#% Датчики progress-round 1 1024 1 1024 6
|
||||
inputDigit digit1 При#скольки#включить? Датчики 10 7
|
||||
inputDigit digit2 При#скольки#выключить? Датчики 0 8
|
||||
button 4 na Нагреватель Датчики 0 9
|
||||
//---------------------------------------------------------------------
|
||||
button 5 na Вкл#обратный#таймер Таймеры 0 16
|
||||
inputDigit digit3 Через#сколько#секунд#включить? Таймеры 5 17
|
||||
button 6 na Включится#по#таймеру Таймеры 0 18
|
||||
inputTime time1 Во#сколько#включить? Таймеры 20-30-00 19
|
||||
button 7 5 Включится#по#таймеру Таймеры 0 20
|
||||
//---------------------------------------------------------------------
|
||||
switch 1 0 20
|
||||
text 1 Вход: Охрана 20
|
||||
textSet 1 не#обнаружено-time
|
||||
button 8 na Сбросить Охрана 0 21
|
||||
//---------------------------------------------------------------------
|
||||
button 9 scenario Вкл#выкл#все#сценарии Сценарии 1 23
|
||||
button 10 line1,line2, Вкл#выкл#выбранные#сценарии Сценарии 1 24
|
||||
analog 0 Аналоговый#вход,#% Датчики progress-round 1 1024 1 1024 6
|
||||
@@ -7,27 +7,4 @@ button1 = 0
|
||||
buttonSet 2 0
|
||||
buttonSet 3 0
|
||||
pwmSet 2 0
|
||||
end
|
||||
analog > digit1
|
||||
buttonSet 4 1
|
||||
end
|
||||
analog < digit2
|
||||
buttonSet 4 0
|
||||
end
|
||||
button5 = 1
|
||||
timerStart 1 digit3 sec
|
||||
end
|
||||
timer1 = 0
|
||||
buttonSet 6 1
|
||||
end
|
||||
timenow = time1
|
||||
buttonSet 7 1
|
||||
end
|
||||
switch1 = 1
|
||||
textSet 1 обнаружено#движение-time
|
||||
push Внимание обнаружено#движение!
|
||||
end
|
||||
button8 = 1
|
||||
textSet 1 не#обнаружено-time
|
||||
buttonSet 8 0
|
||||
end
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "SPIFFS version: 2.3+"
|
||||
"title": "SPIFFS version: 2.3.1"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
|
||||
@@ -8,6 +8,8 @@ void setup() {
|
||||
//--------------------------------------------------------------
|
||||
SPIFFS.begin();
|
||||
configSetup = readFile("config.json", 4096);
|
||||
configSetup.replace(" ", "");
|
||||
configSetup.replace("\r\n", "");
|
||||
Serial.println(configSetup);
|
||||
jsonWrite(configJson, "SSDP", jsonRead(configSetup, "SSDP"));
|
||||
jsonWrite(configJson, "lang", jsonRead(configSetup, "lang"));
|
||||
@@ -20,7 +22,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
chipID = String( ESP.getChipId() ) + "-" + String( ESP.getFlashChipId());
|
||||
chipID = String( ESP.getChipId() ) + "-" + String(ESP.getFlashChipId());
|
||||
jsonWrite(configSetup, "chipID", chipID);
|
||||
Serial.setDebugOutput(0);
|
||||
#endif
|
||||
@@ -39,24 +41,25 @@ void setup() {
|
||||
WIFI_init();
|
||||
Serial.println("[V] WIFI_init");
|
||||
//--------------------------------------------------------------
|
||||
Web_server_init();
|
||||
Serial.println("[V] Web_server_init");
|
||||
//--------------------------------------------------------------
|
||||
Time_Init();
|
||||
Serial.println("[V] Time_Init");
|
||||
//--------------------------------------------------------------
|
||||
MQTT_init();
|
||||
Serial.println("[V] MQTT_init");
|
||||
//--------------------------------------------------------------
|
||||
Push_init();
|
||||
Serial.println("[V] Push_init");
|
||||
//--------------------------------------------------------------
|
||||
statistics_init();
|
||||
Serial.println("[V] statistics_init");
|
||||
//--------------------------------------------------------------
|
||||
initUpgrade();
|
||||
Serial.println("[V] initUpgrade");
|
||||
//--------------------------------------------------------------
|
||||
//Web_server_init();
|
||||
//Serial.println("[V] Web_server_init");
|
||||
//--------------------------------------------------------------
|
||||
MQTT_init();
|
||||
Serial.println("[V] MQTT_init");
|
||||
//--------------------------------------------------------------
|
||||
Time_Init();
|
||||
Serial.println("[V] Time_Init");
|
||||
//--------------------------------------------------------------
|
||||
Push_init();
|
||||
Serial.println("[V] Push_init");
|
||||
//--------------------------------------------------------------
|
||||
|
||||
Serial.print("[i] Date compiling: ");
|
||||
Serial.println(DATE_COMPILING);
|
||||
|
||||
@@ -71,8 +74,11 @@ void setup() {
|
||||
|
||||
Serial.print("[i] Last firmware version: ");
|
||||
Serial.println(new_version);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef OTA_enable
|
||||
|
||||
15
main.ino
15
main.ino
@@ -275,10 +275,12 @@ void getMemoryLoad(String text) {
|
||||
Serial.println(String(memory_remain) + " k bytes");
|
||||
|
||||
}
|
||||
|
||||
//esp32 full memory = 362868 k bytes
|
||||
//esp8266 full memory = 53312 k bytes
|
||||
|
||||
|
||||
//===================================================================
|
||||
/*
|
||||
void web_print (String text) {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
jsonWrite(json, "test1", jsonRead(json, "test2"));
|
||||
@@ -292,13 +294,21 @@ void web_print (String text) {
|
||||
ws.textAll(json);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//===================================================================
|
||||
/*
|
||||
"socket": [
|
||||
"ws://{{ip}}/ws"
|
||||
],
|
||||
*/
|
||||
//===================================================================
|
||||
/*
|
||||
{
|
||||
"type": "h4",
|
||||
"title": "('{{build2}}'=='{{firmware_version}}'?'NEW':'OLD')"
|
||||
},
|
||||
*/
|
||||
|
||||
//===================================================================
|
||||
/*
|
||||
{
|
||||
"type": "hr"
|
||||
@@ -331,3 +341,4 @@ void web_print (String text) {
|
||||
"type": "hr"
|
||||
},
|
||||
*/
|
||||
//===================================================================
|
||||
|
||||
10
mqtt.ino
10
mqtt.ino
@@ -19,6 +19,7 @@ void MQTT_init() {
|
||||
|
||||
saveConfig();
|
||||
|
||||
|
||||
client.disconnect();
|
||||
MQTT_Connecting();
|
||||
|
||||
@@ -40,10 +41,13 @@ void MQTT_init() {
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
request->send(200, "text/text", tmp);
|
||||
request->send(200, "text/text", tmp);
|
||||
#endif
|
||||
});
|
||||
|
||||
MQTT_Connecting();
|
||||
|
||||
|
||||
//проверка подключения к серверу
|
||||
ts.add(WIFI_MQTT_CONNECTION_CHECK, wifi_mqtt_reconnecting, [&](void*) {
|
||||
up_time();
|
||||
@@ -51,7 +55,7 @@ void MQTT_init() {
|
||||
Serial.println("[V] WiFi-ok");
|
||||
if (client.connected()) {
|
||||
Serial.println("[V] MQTT-ok");
|
||||
web_print("MQTT-ok");
|
||||
//web_print("MQTT-ok");
|
||||
} else {
|
||||
MQTT_Connecting();
|
||||
mqtt_lost_error++;
|
||||
@@ -62,7 +66,7 @@ void MQTT_init() {
|
||||
ts.remove(WIFI_MQTT_CONNECTION_CHECK);
|
||||
StartAPMode();
|
||||
}
|
||||
}, nullptr, true);
|
||||
}, nullptr, false);
|
||||
}
|
||||
|
||||
//================================================ОБНОВЛЕНИЕ====================================================
|
||||
|
||||
9
set.h
9
set.h
@@ -7,7 +7,7 @@ String new_version;
|
||||
|
||||
#define TIME_COMPILING String(__TIME__)
|
||||
#define DATE_COMPILING String(__DATE__)
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
#define wifi_mqtt_reconnecting 20000
|
||||
//-----------------------------------------------------------------
|
||||
#define analog_update_int 5000
|
||||
@@ -52,8 +52,6 @@ ESP8266HTTPUpdateServer httpUpdater;
|
||||
#include <HTTPUpdate.h>
|
||||
#include <HTTPClient.h>
|
||||
//HTTPClient http;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//==общие библиотеки и объекты==//
|
||||
@@ -74,9 +72,10 @@ AsyncEventSource events("/events");
|
||||
#include "time.h"
|
||||
#include <TickerScheduler.h>
|
||||
TickerScheduler ts(30);
|
||||
enum {ROUTER_SEARCHING, WIFI_MQTT_CONNECTION_CHECK, LEVEL, ANALOG_, DALLAS, DHTT, DHTH, DHTC, DHTP, DHTD, STEPPER1, STEPPER2, ANALOG_LOG, LEVEL_LOG, DALLAS_LOG, PH_LOG, CMD, TIMER_COUNTDOWN, TIMERS, TIME, STATISTICS};
|
||||
enum {ROUTER_SEARCHING, WIFI_MQTT_CONNECTION_CHECK, LEVEL, ANALOG_, DALLAS, DHTT, DHTH, DHTC, DHTP, DHTD, STEPPER1, STEPPER2, ANALOG_LOG, LEVEL_LOG, DALLAS_LOG, PH_LOG, CMD, TIMER_COUNTDOWN, TIMERS, TIME, STATISTICS, TEST};
|
||||
|
||||
//ssl//#include "dependencies/WiFiClientSecure/WiFiClientSecure.h" //using older WiFiClientSecure
|
||||
//#include "Ticker_for_TickerScheduler/Ticker/Ticker.h"
|
||||
#include <PubSubClient.h>
|
||||
WiFiClient espClient;
|
||||
//ssl//WiFiClientSecure espClient;
|
||||
@@ -140,7 +139,7 @@ String current_time;
|
||||
int scenario_line_status [] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
|
||||
int wifi_lost_error = 0;
|
||||
int mqtt_lost_error = -1;
|
||||
int mqtt_lost_error = 0;
|
||||
|
||||
String var;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user