Error missing terminating character

I have this missing terminating character, but I'm not sure what it wants or needs. I believe it's inside its inside the while second while loop. what can be done to fix this. I'm trying to input a...

I have this missing terminating character, but I’m not sure what it wants or needs. I believe it’s inside its inside the while second while loop. what can be done to fix this. I’m trying to input a text file with a string of paths. And then from there I parse through this string and put it to a link list. and then create a search function afterwards.

text file: path.txt

a/a1.txt
a/a2.txt
a/b/b3.txt
a/b/b4.txt
a/c/c4.txt
a/c/c5.txt
a/c/d/d6.txt
a/c/d/g
a/c/d/h
a/c/e/i/i7.txt
a/c/f/j/k/k8.txt

code:

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct sMyPath{
        char *element;
        struct sMyPath *next;
} tMyPath;


int main(void)
{
        FILE *pFile;
        pFile = fopen("path.txt", "r");
        char inputstr[1024];
        tMyPath *curr, *first = NULL, *last = NULL;

//get the text file, and put it into a string inputstr

        if (pFile != NULL)
        {
                while(!feof(pFile))
                {
                        fgets(inputstr, sizeof(inputstr), pFile);
                }
        fclose(pFile);
        }
        else
        {
                printf("Could not open the file.n");
        }

//using tokens to get each piece of the string
//seperate directories and text files, put it into a link list

        char *token = strtok(inputstr, "");
        while (token != NULL)
        {
        if(last == NULL){
                //creating node for directory
                first = last = malloc (sizeof (*first));
                first -> element = strdup (token);
                first -> next = NULL;
        } else {
                last -> next = malloc (sizeof (*last));
                last = last -> next;
                last -> element = strdup (token);
                last -> next = NULL;
        }
        token = strtok(NULL, "");
        }




//ask user for txt file
        char pathU[20];
        printf("enter text filen");
        gets(pathU);


//check if text file exist, if yes output entires in text file, else say no
        while(first != NULL)
        {
                if(strcmp (first -> element,pathU)==0)
                {
                        FILE *nFile;
                        char texxt[300];
                        nFile = fopen(pathU, "r");
                        while (!feof(nFile))
                        {
                                fgets(texxt, 300, nFile);
                                printf("Theses are the contentsn");
                                printf("%s", texxt);
                        }

                }

                else if(first == NULL)
                {
                        printf("invalid file namen");
                }

                else
                {
                first = first -> next;
                }




        }

return 0;
}

error:

search.c:36:33: warning: missing terminating " character
search.c: In function ‘main’:
search.c:36: error: missing terminating " character
search.c:37: error: expected expression before ‘while’
search.c:50:24: warning: missing terminating " character
search.c:50: error: missing terminating " character
search.c:95: error: expected declaration or statement at end of input

Содержание

  1. Часто встречающиеся ошибки стадии компиляции
  2. Предупреждения компилятора по версиям компилятора
  3. Предупреждения, появившиеся в Visual Studio 2022 версии 17.4 (компилятор версии 19.34)
  4. Предупреждения, появившиеся в Visual Studio 2022 версии 17.3 (компилятор версии 19.33)
  5. Предупреждения, появившиеся в Visual Studio 2022 версии 17.2 (компилятор версии 19.32)
  6. Предупреждения, появившиеся в Visual Studio 2022 версии 17.1 (компилятор версии 19.31)
  7. Предупреждения, появившиеся в Visual Studio 2022 версии 17.0 (компилятор версии 19.30)
  8. Предупреждения, появившиеся в Visual Studio 2019 версии 16.11 (компилятор версии 19.29.30100.0)
  9. Предупреждения, появившиеся в Visual Studio 2019 версии 16.10 (компилятор версии 19.29.30000.0)
  10. Предупреждения, появившиеся в Visual Studio 2019 версии 16.9 (компилятор версии 19.28.29700.0)
  11. Предупреждения, появившиеся в Visual Studio 2019 версии 16.8 (компилятор версии 19.28.29333.0)
  12. Предупреждения, появившиеся в Visual Studio 2019 версии 16.7 (компилятор версии 19.27.29112.0)
  13. Предупреждения, появившиеся в Visual Studio 2019 версии 16.6 (компилятор версии 19.26.28805.0)
  14. Предупреждения, появившиеся в Visual Studio 2019 версии 16.5 (компилятор версии 19.25.28610.0)
  15. Предупреждения, появившиеся в Visual Studio 2019 версии 16.4 (компилятор версии 19.24.28314.0)
  16. Предупреждения, появившиеся в Visual Studio 2019 версии 16.3 (компилятор версии 19.23.28105.0)
  17. Предупреждения, появившиеся в Visual Studio 2019 версии 16.2 (компилятор версии 19.22.27905.0)
  18. Предупреждения, появившиеся в Visual Studio 2019 версии 16.1 (компилятор версии 19.21.27702.0)
  19. Предупреждения, появившиеся в Visual Studio 2019 RTW (компилятор версии 19.20.27004.0)
  20. Предупреждения, появившиеся в Visual Studio 2017 версии 15.8 (компилятор версии 19.15.26726.0)
  21. Предупреждения, появившиеся в Visual Studio 2017 версии 15.7 (компилятор версии 19.14.26428.0)
  22. Предупреждения, появившиеся в Visual Studio 2017 версии 15.6 (компилятор версии 19.13.26128.0)
  23. Предупреждения, появившиеся в Visual Studio 2017 версии 15.5 (компилятор версии 19.12.25830.0)
  24. Предупреждения, появившиеся в Visual Studio 2017 версии 15.3 (компилятор версии 19.11.25506.0)
  25. Предупреждения, появившиеся в Visual Studio 2017 RTM (компилятор версии 19.10.25017.0)
  26. Предупреждения, появившиеся в Visual Studio 2015 с обновлением 3 (компилятор версии 19.00.24215.1)
  27. Предупреждения, появившиеся в Visual Studio 2015 с обновлением 2 (компилятор версии 19.00.23918.0)
  28. Предупреждения, появившиеся в Visual Studio 2015 с обновлением 1 (компилятор версии 19.00.23506.0)
  29. Предупреждения, появившиеся в Visual Studio 2015 RTM (компилятор версии 19.00.23026.0)
  30. Предупреждения, появившиеся в Visual Studio 2013 (версия компилятора 18.00.21005.1)
  31. Предупреждения, появившиеся в Visual Studio 2012 (версия компилятора 17.00.51106.1)
  32. Предупреждения, появившиеся в Visual Studio 2010 (версия компилятора 16.00.40219.01)
  33. Предупреждения, появившиеся в Visual Studio 2008 (версия компилятора 15.00.21022.08)
  34. Предупреждения, появившиеся в Visual Studio 2005 (версия компилятора 14.00.50727.762)
  35. Предупреждения, появившиеся в Visual Studio 2003 (версия компилятора 13.10.3077)
  36. Предупреждения, появившиеся в Visual Studio 2002 (версия компилятора 13.00.9466)

Часто встречающиеся ошибки стадии компиляции

Очень часто начинающие программисты впадают в суеверный ужас, когда видят, что компилятор нашел в тексте программы ошибку, но не понимают, в чем она заключается.

А если помножить этот факт на незнание английского языка («чего там ему не нравится. ») и слабое владение синтаксисом C++ («хм, а может, тут нужна точка с запятой…»), то проблема принимает масштаб катастрофы.

Тот факт, что компилятор в силу своих ограниченных возможностей изо всех сил старается объяснить, что конкретно неверно, не спасает ситуацию. Как быть, если гуглить неохота, а спросить не у кого?

В этом посте на правах копипаста с последующим переводом, дополнениями и исправлениями приведу описание наиболее распространенных сообщений об ошибках и предупреждений компилятора. Неприятность кроется в том факте, что разные компиляторы ругаются на одинаковые ошибки по-разному, а некоторые даже не замечают то, что другие принимают за ошибку. Все зависит от совести разработчиков компилятора, даты его выпуска, и др.

В качестве компилятора возьмем g++, который, в частности, может использоваться в среде Code::Blocks. Версия gcc (куда входит g++) для ОС Windows зовется MinGW. По ходу я буду давать аналоги ошибок из лексикона русскоязычной Microsoft Visual C++.

Итак, частые ошибки:

undeclared identifier

doy.cpp: In function ‘int main()’:
doy.cpp:25: ‘DayOfYear’ undeclared (first use this function)
doy.cpp:25: (Each undeclared identifier is reported only once for each function it appears in.)
doy.cpp:25: parse error before ‘;’ token

2) Смысл
Использован идентификатор DayOfYear , но компилятор не нашел его объявления. Он не знает, что такое DayOfYear .

  • Вы забыли включить какой-то заголовочный файл ( #include. )
  • Вы где-то ошиблись в написании идентификатора (при объявлении или использовании)
  • Вы вообще забыли, что эту переменную надо объявить

Попытавшись скомпилировать это в Microsoft Visual C++, вы увидите:

error C2065: DayOfYear: необъявленный идентификатор

cout undeclared

xyz.cpp: In function ‘int main()’:
xyz.cpp:6: ‘cout’ undeclared (first use this function)
xyz.cpp:6: (Each undeclared identifier is reported only once for each function it appears in.)

2) Смысл
Суперклассика. Без комментариев.

  • Вы забыли включить
  • Вы забыли написать using namespace std;

jump to case label

switch.cpp: In function ‘int main()’:
switch.cpp:14: jump to case label
switch.cpp:11: crosses initialization of ‘int y’

2) Смысл
Смысл туманен

3) Когда бывает
Вы попытались объявить и инициализировать переменную (объект, указатель и т.п.) в метке case оператора выбора switch. Правилами C++ это запрещено.

В Microsoft Visual C++ эта ошибка зовется

error C2360: пропуск инициализации ‘y’ из-за метки ‘case’

Выход: заключите операторы этого case’а в фигурные скобки <>.

multi-line string / unterminated string

using namespace std;

вызовет бурную реакцию компилятора:

string.cpp:7:12: warning: multi-line string literals are deprecated
string.cpp: In function ‘int main()’:
string.cpp:7: ‘so’ undeclared (first use this function)
string.cpp:7: (Each undeclared identifier is reported only once for each function it appears in.)
string.cpp:7: parse error before ‘Mary’
string.cpp:8:28: warning: multi-line string literals are deprecated
string.cpp:8:28: missing terminating » character
string.cpp:7:12: possible start of unterminated string literal

2) Смысл
Компилятор думает, что мы хотим создать строковую константу с содержащимся в ней переносом строки, что-то типа

что не поддерживается языком. Также делается предположение о том, что мы, возможно, забыли поставить кавычки в конце первой строки. Собственно, так оно и есть.

3) Когда бывает
Когда не соблюдается правильное количество и положение кавычек в строковых литералах. Надо быть внимательнее.

Microsoft Visual C++ со свойственной ему детской непосредственностью, отметит, что нельзя делать переносы в строках и возмутится, где точка с запятой:

error C2001: newline в константе
error C2146: синтаксическая ошибка: отсутствие «;» перед идентификатором «cout»

comparison between signed and unsigned integer expressions

xyz.cpp: In function ‘int main()’:
xyz.cpp:54: warning: comparison between signed and unsigned integer expressions

2) Смысл
Это — предупреждение компилятора, которое говорит о том, что мы пытаемся сравнить (==, и т.д.) целочисленное выражение (может принимать положительные, отрицательные значения и 0) и беззнаковое целочисленное выражение (может быть только положительным, либо 0).

3) Когда бывает
Собственно, тогда и бывает. Напомню, что тип int по умолчанию знаковый, а некоторые функции (например, vector::size() ) возвращают unsigned int .
К примеру, следующий на первый взгляд безобидный код вызовет описываемое предупреждение:

Следует помнить, что в памяти знаковые и беззнаковые типы имеют разные внутренние представления, поэтому надо быть чертовски осторожными с указателями.

В Microsoft Visual C++ предупреждение выглядит так:

suggest parentheses around assignment used as truth value

xyz.cpp: In function `int main()’:
xyz.cpp:54: warning: suggest parentheses around assignment used as truth value

2) Смысл
Тоже классика. Компилятор предполагает (и в 99% случаев прав), что вы по ошибке включили в скобки в качестве условия для if/while/for вместо условного выражения выражение присваивания.

3) Когда бывает
Чаще всего — в if ‘ах, когда вместо «==» используется «=»

if (length = maxLength)

if (length == maxLength)

Заминка в том, что это не ошибка, т.к. в скомпилированной программе (если мы проигнорируем предупреждение) выражение присваивания (которое возвращает значение правого аргумента) во всех случаях, кроме тех, когда оно вернет 0 , будет преобразовано к true .

Источник

Предупреждения компилятора по версиям компилятора

Компилятор может подавлять предупреждения, появившиеся после указанной версии, с помощью параметра компилятора /Wv . Этот параметр удобен для управления процессом сборки, когда вы вводите новую версию набора инструментов и хотите временно отключить новые предупреждения. Этот параметр подавляет только предупреждения, но не новые сообщения об ошибках. Не подавляйте все новые предупреждения постоянно! Мы рекомендуем всегда компилировать на самом высоком регулярном уровне /W4 предупреждений , и удалить /Wv параметр в сборке, как только это будет удобно.

В следующих версиях компилятора появились новые предупреждения:

Продукт Номер версии компилятора
Visual Studio 2002 13.00.9466
Visual Studio 2003 13.10.3077
Visual Studio 2005 14.00.50727.762
Visual Studio 2008 15.00.21022.08
Visual Studio 2010 16.00.40219.01
Visual Studio 2012 17.00.51106.1
Visual Studio 2013 18.00.21005.1
Visual Studio 2015 RTM 19.00.23026.0
Visual Studio 2015 с обновлением 1 19.00.23506.0
Visual Studio 2015 с обновлением 2 19.00.23918.0
Visual Studio 2015 с обновлением 3 19.00.24215.1
Visual Studio 2017 RTM 19.10.25017.0
Visual Studio 2017 версия 15.3 19.11.25506.0
Visual Studio 2017 версии 15.5 19.12.25830.0
Visual Studio 2017 версии 15.6 19.13.26128.0
Visual Studio 2017 версии 15.7 19.14.26428.0
Visual Studio 2017 версии 15.8 19.15.26726.0
Visual Studio 2017 версии 15.9 19.16.26926.0
Visual Studio 2019 RTM 19.20.27004.0
Visual Studio 2019 версии 16.1 19.21.27702.0
Visual Studio 2019 версии 16.2 19.22.27905.0
Visual Studio 2019 версии 16.3 19.23.28105.0
Visual Studio 2019 версии 16.4 19.24.28314.0
Visual Studio 2019, версия 16.5 19.25.28610.0
Visual Studio 2019 версии 16.6 19.26.28805.0
Visual Studio 2019 версии 16.7 19.27.29112.0
Visual Studio 2019 версии 16.8 19.28.29333.0
Visual Studio 2019 версии 16.9 19.28.29700.0
Visual Studio 2019 версии 16.10 19.29.30000.0
Visual Studio 2019 версии 16.11 19.29.30100.0
Visual Studio 2022 версии 17.0 RTW 19.30
Visual Studio 2022 версии 17.1 19.31
Visual Studio 2022 версии 17.2 19.32
Visual Studio 2022 версии 17.3 19.33
Visual Studio 2022 версии 17.4 19.34

В параметре можно указать только основное число, основное и вспомогательное номера, а также основной, дополнительный и номер сборки /Wv . Компилятор сообщает обо всех предупреждениях, которые соответствуют версиям, начинающимся с указанного числа. Он подавляет все предупреждения для версий, превышающих указанное число. Например, сообщает о предупреждениях, /Wv:17 появившиеся в любой версии Visual Studio 2012 или раньше, и отключает предупреждения, введенные любым компилятором из Visual Studio 2013 (версия 18) или более поздней версии. Чтобы отключить предупреждения, появившиеся в Visual Studio 2015 с обновлением 2 и более поздних версий, можно использовать . /Wv:19.00.23506 Используйте для /Wv:19.11 сообщения о предупреждениях, появившиеся в любой версии Visual Studio до Visual Studio 2017 версии 15.5, но подавляйте предупреждения, появившиеся в Visual Studio 2017 версии 15.5 и более поздних версий.

В следующих разделах перечислены предупреждения, появившиеся в каждой версии Visual C++, которые можно отключить с помощью параметра компилятора /Wv . Параметр /Wv не может подавлять предупреждения, которые отсутствуют в списке, которые предшествовали указанным версиям компилятора.

Предупреждения, появившиеся в Visual Studio 2022 версии 17.4 (компилятор версии 19.34)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.33 компилятора .

Предупреждение Сообщение
C5260 константная переменная «variable-name» имеет внутреннюю компоновку в включенном контексте файла заголовка, но внешнюю компоновку в контексте импортированной единицы заголовка; Рекомендуется объявить его » inline «, если он будет совместно использоваться в единицах перевода, или » static «, чтобы выразить намерение использовать его локально для этой единицы перевода
C5261 Целочисленный тип не может представлять все значения перечислителя в перечислении «enum-name«
C5262 здесь происходит неявное падение; Вам не хватает break заявления? Используется [[fallthrough]] , break если оператор намеренно опущен между вариантами
C5263 Вызов » std::move » для временного объекта предотвращает удаление копирования
C5264 «variable-name«: » const » переменная не используется

Предупреждения, появившиеся в Visual Studio 2022 версии 17.3 (компилятор версии 19.33)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.32 компилятора .

Предупреждение Сообщение
C5259 «специализированный тип«: для явной специализации требуется «шаблон <>«

Предупреждения, появившиеся в Visual Studio 2022 версии 17.2 (компилятор версии 19.32)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.31 компилятора .

Предупреждение Сообщение
C4983 «/analyze:sarif:hashname» игнорируется, так как аргумент для «/analyze:log» является одним файлом, а не каталогом
C5081 Безопасное горячее исправление не поддерживается в /GENPROFILE, /FASTGENPROFILE или /LTCG:PGI, отключая безопасное горячее исправление.
C5255 Обнаружен неуправляемый двунаправленный символ: «U+XXXX»
C5256 «перечисление«: неопределяющее объявление перечисления с фиксированным базовым типом разрешено только в виде автономного объявления.
C5257 «enumeration«: перечисление ранее было объявлено без фиксированного базового типа
C5258 Для этого использования не требуется явное запись символа
C5300 «#pragma omp atomic»: левый операнд оператора должен соответствовать левой части выражения assignment-expression
C5301 «#pragma omp для»: «символ» увеличивается, а условие цикла использует «сравнение«; неоконклюционный цикл?
C5302 «#pragma omp для»: «символ» уменьшается, а условие цикла использует «сравнение«; неоконклюционный цикл?

Предупреждения, появившиеся в Visual Studio 2022 версии 17.1 (компилятор версии 19.31)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.30 компилятора .

Предупреждение Сообщение
C5251 Имя сегмента изменилось после включения заголовка
C5253 Нелоклайская лямбда-выражения не может иметь запись по умолчанию
C5254 Для функции языка «terse static assert» требуется флаг компилятора » /std:c++17 «

Предупреждения, появившиеся в Visual Studio 2022 версии 17.0 (компилятор версии 19.30)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.29 компилятора .

Предупреждение Сообщение
C5244 «#include файла» в представлении модуля «имя_модуля-1» отображается ошибочно. Рекомендуется переместить директиву перед объявлением модуля или заменить текстовое включение на «import ;».
C5245 «function«: удалена функция без ссылок с внутренней компоновкой
C5246 «member«: инициализация подобъекта должна быть заключена в фигурные скобки
C5249 Bitfield типа «enumeration_name» имеет именованные перечислители со значениями, которые не могут быть представлены в заданной ширине битового поля «bitfield_width«.
C5250 «function_name«: встроенная функция не объявлена.
C5252 Несколько разных типов привели к одному и тому же хэш-значению типа XFG; PDB будет записывать сведения только для одного из них

Предупреждения, появившиеся в Visual Studio 2019 версии 16.11 (компилятор версии 19.29.30100.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.29.30099 компилятора .

Предупреждение Сообщение
C5247 section ‘section-name‘ зарезервирован для динамической инициализации C++. Создание раздела вручную помешает динамической инициализации C++ и может привести к неопределенному поведению.
C5248 section ‘section-name‘ зарезервирован для динамической инициализации C++. Переменные, помещенные вручную в раздел, могут быть оптимизированы, и их порядок относительно созданных компилятором динамических инициализаторов не указан

Предупреждения, появившиеся в Visual Studio 2019 версии 16.10 (компилятор версии 19.29.30000.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.28 компилятора .

Предупреждение Сообщение
C5233 явный лямбда-захват «идентификатор» не используется
C5234 ошибка файловой системы: «filename» не является допустимым именем заголовка; Игнорируя
C5235 Ошибка анализа JSON: проблема; игнорирование «filename«
C5236 Неправильно сформированный JSON: проблема; игнорирование «filename«
C5237 не удается разрешить запись блока заголовка «string» в файл заголовка в «filename«; игнорирование записи
C5238 ошибка файловой системы: не удается открыть имя файла для чтения; Игнорируя
C5239 «Symbol«: потенциально вызываемая функция, вызываемая из функции, объявленной __declspec(nothrow) . Если возникает исключение, может возникнуть неопределенное поведение.
C5240 attribute-string‘: атрибут игнорируется в этой синтаксической позиции
C5241 Использование » /exportHeader » для поиска имени заголовка не рекомендуется; предпочитать » /headerName:arg-1 arg-2=filename «
C5242 синтаксическая ошибка в pragma ‘pragma-name
C5243 Type-name: использование неполного класса symbol может привести к потенциальному нарушению правила определения из-за ограничения ABI

Предупреждения, появившиеся в Visual Studio 2019 версии 16.9 (компилятор версии 19.28.29700.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.28.29699 компилятора .

Предупреждение Сообщение
C5232 В C++20 это сравнение вызывает «идентификатор» рекурсивно

Предупреждения, появившиеся в Visual Studio 2019 версии 16.8 (компилятор версии 19.28.29333.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.27 компилятора .

Предупреждение Сообщение
C5072 ASAN enabled without debug information emission. Enable debug info for better ASAN error reporting
C5211 ‘keyword-1’ has been deprecated; prefer using ‘keyword-2’ instead
C5222 ‘attribute-name’: all unscoped attribute names are reserved for future standardization
C5223 all attribute names in the attribute namespace ‘msvc’ are reserved for the implementation
C5224 all attribute names in the attribute namespace ‘a-namespace’ are reserved for future standardization
C5225 ‘symbol’: exported inline function defined in a private module fragment is a non-standard extension
C5226 ‘symbol’: exported template defined in private module fragment has no reachable instantiation
C5227 nonstandard extension, resolved ‘symbol’ to ‘instance’ which is not visible with /permissive- on.
C5228 nonstandard extension, ‘identifier’ resolved to a member of a dependent base. This lookup is not allowed under /permissive-.
C5229 nonstandard extension, the hidden friend function ‘function-name’ was found by name lookup which isn’t allowed under /permissive-.
C5230 nonstandard extension, ‘identifier’ was resolved to ‘symbol’ under /permissive. Under /permissive- it would resolve to ‘other-symbol’.
C5231 the expression ‘co_await promise.final_suspend()’ must be non-throwing )

Предупреждения, появившиеся в Visual Studio 2019 версии 16.7 (компилятор версии 19.27.29112.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.26 компилятора .

Предупреждение Сообщение
C5207 the simple requirement asserts the validity of expression ‘e->id’. Did you mean ‘ < e >-> id’? You can suppress the warning using ‘< e->id >’
C5209 the C++20 syntax for an init-capture has changed to ‘& . opt identifier initializer’
C5210 ‘name’ is not a valid header unit reference; ignoring
C5212 ‘name’ is not a valid named reference; treating as reference to file
C5213 ‘name’ named reference is treated as a named partition but the name is not specified; treating as reference to file
C5214 applying ‘modifier’ to an operand with a volatile qualified type is deprecated in C++20
C5215 ‘name’ a function parameter with a volatile qualified type is deprecated in C++20
C5216 ‘name’ a volatile qualified return type is deprecated in C++20
C5217 a structured binding declaration that includes volatile is deprecated in C++20
C5218 destroying delete may not behave as intended when non-conforming switches ‘/Zc:sizedDealloc-‘ or ‘/Zc:alignedNew-‘ are used
C5219 implicit conversion from ‘type-1’ to ‘type-2’, possible loss of data
C5220 ‘name’: a non-static data member with a volatile qualified type no longer implies%$N that compiler generated copy/move constructors and copy/move assignment operators are not trivial
C5221 xfg::rename is deprecated.

Предупреждения, появившиеся в Visual Studio 2019 версии 16.6 (компилятор версии 19.26.28805.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.25 компилятора .

Предупреждение Сообщение
C5207 the simple requirement asserts the validity of expression ‘e->id’. Did you mean ‘ < e >-> id’? You can suppress the warning using ‘< e->id >’
C5208 unnamed class used in typedef name cannot declare members other than non-static data members, member enumerations, or member classes

Предупреждения, появившиеся в Visual Studio 2019 версии 16.5 (компилятор версии 19.25.28610.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.24 компилятора .

Предупреждение Сообщение
C5061 the use of a comma operator as a subscript expression has been deprecated
C5062 enum direct list initialization between ‘type-1’ and ‘type-2’ is no longer supported
C5063 ‘std::is_constant_evaluated’ always evaluates to true in manifestly constant-evaluated expressions
C5108 __VA_OPT__ is reserved for use in variadic macros
C5204 ‘type-name’: class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
C5205 delete of an abstract class ‘type-name’ that has a non-virtual destructor results in undefined behavior
C5206 deduced return types for coroutines is a non-standard extension

Предупреждения, появившиеся в Visual Studio 2019 версии 16.4 (компилятор версии 19.24.28314.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.23 компилятора .

Предупреждение Сообщение
C5200 feature ‘feature-name’ requires compiler flag ‘option-name’
C5201 a module declaration can appear only at the start of a translation unit unless a global module fragment is used
C5202 a global module fragment can only contain preprocessor directives
C5203 a parenthesized declarator name after ‘explicit’ will be considered an explicit-specifier in C++20

Предупреждения, появившиеся в Visual Studio 2019 версии 16.3 (компилятор версии 19.23.28105.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.22 компилятора .

Предупреждение Сообщение
C4856 ‘value’ is not a valid argument for ‘/d1initAll:FillPattern’ (value must be between 0 and 255). Command-line flag ignored
C4857 C++/CLI mode does not support C++ versions newer than C++17; setting language to /std:c++17

Предупреждения, появившиеся в Visual Studio 2019 версии 16.2 (компилятор версии 19.22.27905.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.21 компилятора .

Предупреждение Сообщение
C4855 implicit capture of ‘this’ via ‘[=]’ is deprecated in ‘version’
C5054 operator ‘operator-name’: deprecated between enumerations of different types
C5055 operator ‘operator-name’: deprecated between enumerations and floating-point types
C5056 operator ‘operator-name’: deprecated for array types
C5057 header unit reference to ‘name’ already exists. Ignoring header unit ‘header-name’
C5058 file system error: cannot find header file ‘file-name’ for header unit ‘unit-name’
C5059 runtime checks and address sanitizer is not currently supported — disabling runtime checks
C5060 /Qpar and address sanitizer not currently supported — disabling auto-parallelization

Предупреждения, появившиеся в Visual Studio 2019 версии 16.1 (компилятор версии 19.21.27702.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.20 компилятора .

Предупреждение Сообщение
C5052 Keyword ‘keyword-name’ was introduced in C++ and requires use of the ‘option-name’ command-line option
C5053 support for ‘explicit( )’ in C++17 and earlier is a vendor extension

Предупреждения, появившиеся в Visual Studio 2019 RTW (компилятор версии 19.20.27004.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.15 компилятора .

Предупреждение Сообщение
C4848 support for standard attribute ‘no_unique_address’ in C++17 and earlier is a vendor extension
C4854 binding dereferenced null pointer to reference has undefined behavior
C5051 attribute ‘attribute-name’ requires at least ‘standard-level’; ignored

Предупреждения, появившиеся в Visual Studio 2017 версии 15.8 (компилятор версии 19.15.26726.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.14 компилятора .

Предупреждение Сообщение
C4643 Forward declaring ‘identifier’ in namespace std is not permitted by the C++ Standard.
C4644 usage of the macro-based offsetof pattern in constant expressions is non-standard; use offsetof defined in the C++ standard library instead
C4845 ‘__declspec(no_init_all)’ is ignored if ‘/d1initall[0|1|2|3]’ was not specified on the command line
C4846 ‘value’ is not a valid argument for ‘/d1initall’: command-line flag ignored
C4847 ‘__declspec(no_init_all)’ can only be applied to a function, a class type, or a local variable: ignored
C4866 compiler may not enforce left-to-right evaluation order for call to ‘function’
C5046 ‘function’: Symbol involving type with internal linkage not defined
C5047 use of nonstandard __if_exists with modules is not supported
C5048 Use of macro ‘macroname’ may result in non-deterministic output
C5049 ‘string’: Embedding a full path may result in machine-dependent output
C5050 Possible incompatible environment while importing module ‘module_name’: issue
C5100 __VA_ARGS__ is reserved for use in variadic macros
C5101 use of preprocessor directive in function-like macro argument list is undefined behavior
C5102 ignoring invalid command-line macro definition ‘value’
C5103 pasting ‘token1’ and ‘token2’ does not result in a valid preprocessing token
C5104 found ‘string1#string2’ in macro replacement list, did you mean ‘string1″»#string2’?
C5105 macro expansion producing ‘defined’ has undefined behavior
C5106 macro redefined with different parameter names
C5107 missing terminating ‘char’ character

Предупреждения, появившиеся в Visual Studio 2017 версии 15.7 (компилятор версии 19.14.26428.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.13 компилятора .

Предупреждение Сообщение
C4642 ‘issue’: could not import the constraints for generic parameter ‘parameter’
C5045 Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified

Предупреждения, появившиеся в Visual Studio 2017 версии 15.6 (компилятор версии 19.13.26128.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.12 компилятора .

Предупреждение Сообщение
C5044 An argument to command-line option option points to a path ‘path’ that does not exist

Предупреждения, появившиеся в Visual Studio 2017 версии 15.5 (компилятор версии 19.12.25830.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.11 компилятора .

Предупреждение Сообщение
C4843 ‘type1’: An exception handler of reference to array or function type is unreachable, use ‘type2’ instead
C4844 ‘export module module_name;’ is now the preferred syntax for declaring a module interface
C5039 ‘function’: pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception.
C5040 dynamic exception specifications are valid only in C++14 and earlier; treating as noexcept(false)
C5041 ‘definition’: out-of-line definition for constexpr static data member is not needed and is deprecated in C++17
C5042 ‘declaration’: function declarations at block scope cannot be specified ‘inline’ in standard C++; remove ‘inline’ specifier
C5043 ‘specification’: exception specification does not match previous declaration

Предупреждения, появившиеся в Visual Studio 2017 версии 15.3 (компилятор версии 19.11.25506.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.10 компилятора .

Предупреждение Сообщение
C4597 undefined behavior: description
C4604 ‘type’: passing argument by value across native and managed boundary requires valid copy constructor. Otherwise the runtime behavior is undefined
C4749 conditionally supported: description
C4768 __declspec attributes before linkage specification are ignored
C4834 discarding return value of function with ‘nodiscard’ attribute
C4841 non-standard extension used: extension
C4842 the result of ‘offsetof’ applied to a type using multiple inheritance is not guaranteed to be consistent between compiler releases
C4869 ‘nodiscard’ may only be applied to classes, enumerations, and functions with non-void return type
C4984 ‘if constexpr’ is a C++17 language extension
C5033 ‘*storage-class*’ is no longer a supported storage class
C5034 use of intrinsic ‘intrinsic’ causes function function to be compiled as guest code
C5035 use of feature ‘feature’ causes function function to be compiled as guest code
C5036 varargs function pointer conversion when compiling with /hybrid:x86arm64 ‘type1’ to ‘type2’
C5037 ‘*member-function*’: an out-of-line definition of a member of a class template cannot have default arguments
C5038 data member ‘member1’ will be initialized after data member ‘member2’

Предупреждения, появившиеся в Visual Studio 2017 RTM (компилятор версии 19.10.25017.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.00 компилятора .

Предупреждение Сообщение
C4468 ‘fallthrough’: attribute must be followed by a case label or a default label
C4698 ‘feature’ is for evaluation purposes only and is subject to change or removal in future updates.
C4839 non-standard use of class ‘class’ as an argument to a variadic function
C4840 non-portable use of class ‘class’ as an argument to a variadic function

Предупреждения, появившиеся в Visual Studio 2015 с обновлением 3 (компилятор версии 19.00.24215.1)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.00.23918 компилятора .

Предупреждение Сообщение
C4467 usage of ATL attributes is deprecated
C4596 ‘name’: illegal qualified name in member declaration
C4598 ‘#include ‘: header number number in the source does not match source at that position
C4599 ‘argument’: source argument number number does not match source

Предупреждения, появившиеся в Visual Studio 2015 с обновлением 2 (компилятор версии 19.00.23918.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.00.23506 компилятора .

Предупреждение Сообщение
C4466 Could not perform coroutine heap elision
C4595 ‘class’: non-member operator new or delete functions may not be declared inline
C4828 The file contains a character starting at offset 0xvalue that is illegal in the current source character set (codepage number).
C4868 compiler may not enforce left-to-right evaluation order in braced initializer list

Предупреждения, появившиеся в Visual Studio 2015 с обновлением 1 (компилятор версии 19.00.23506.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:19.00.23026 компилятора .

Предупреждение Сообщение
C4426 optimization flags changed after including header, may be due to #pragma optimize()
C4654 Code placed before include of precompiled header line will be ignored. Add code to precompiled header.
C5031 #pragma warning(pop): likely mismatch, popping warning state pushed in different file
C5032 detected #pragma warning(push) with no corresponding #pragma warning(pop)

Предупреждения, появившиеся в Visual Studio 2015 RTM (компилятор версии 19.00.23026.0)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:18 компилятора .

Предупреждение Сообщение
C4427 ‘error’: overflow in constant division, undefined behavior
C4438 ‘type’: cannot be called safely in /await:clrcompat mode. If ‘type’ calls into the CLR it may result in CLR head corruption
C4455 ‘operator name’: literal suffix identifiers that do not start with an underscore are reserved
C4456 declaration of ‘name’ hides previous local declaration
C4457 declaration of ‘name’ hides function parameter
C4458 declaration of ‘name’ hides class member
C4459 declaration of ‘name’ hides global declaration
C4462 ‘type’ : cannot determine the GUID of the type. Program may fail at runtime.
C4463 overflow; assigning value to bit-field that can only hold values from value to value
C4473 ‘function’ : not enough arguments passed for format string
C4474 ‘function’ : too many arguments passed for format string
C4475 ‘function’ : length modifier ‘modifier’ cannot be used with type field character ‘character’ in format specifier
C4476 ‘function’ : unknown type field character ‘character’ in format specifier
C4477 ‘function’ : format string ‘string’ requires an argument of type ‘type’, but variadic argument number has type ‘type’
C4478 ‘function’ : positional and non-positional placeholders cannot be mixed in the same format string
C4494 ‘type’ : Ignoring __declspec(allocator) because the function return type is not a pointer or reference
C4495 nonstandard extension ‘__super’ used: replace with explicit base class name
C4496 nonstandard extension ‘for each’ used: replace with ranged-for statement
C4497 nonstandard extension ‘sealed’ used: replace with ‘final’
C4498 nonstandard extension used: ‘extension’
C4499 ‘specialization’: an explicit specialization cannot have a storage class (ignored)
C4576 a parenthesized type followed by an initializer list is a non-standard explicit type conversion syntax
C4577 ‘noexcept’ used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc
C4578 ‘abs’: conversion from ‘type’ to ‘type’, possible loss of data (Did you mean to call ‘name’ or to #include ?)
C4582 ‘type’: constructor is not implicitly called
C4583 ‘type’: destructor is not implicitly called
C4587 ‘type’: behavior change: constructor is no longer implicitly called
C4588 ‘type’: behavior change: destructor is no longer implicitly called
C4589 Constructor of abstract class ‘type’ ignores initializer for virtual base class ‘type’
C4591 ‘constexpr’ call-depth limit of number exceeded (/constexpr:depth )
C4592 ‘type’: symbol will be dynamically initialized (implementation limitation)
C4593 ‘type’: ‘constexpr’ call evaluation step limit of value exceeded; use /constexpr:steps to increase the limit
C4647 behavior change: __is_pod(type) has different value in previous versions
C4648 standard attribute ‘carries_dependency’ is ignored
C4649 attributes are ignored in this context
C4753 Cannot find bounds for pointer; MPX intrinsic function ignored
C4771 Bounds must be created using a simple pointer; MPX intrinsic function ignored
C4774 ‘description’ : format string expected in argument number is not a string literal
C4775 nonstandard extension used in format string ‘string’ of function ‘function’
C4776 ‘%character’ is not allowed in the format string of function ‘function’
C4777 ‘description’ : format string ‘string’ requires an argument of type ‘type’, but variadic argument number has type ‘type’
C4778 ‘description’ : unterminated format string ‘string’
C4838 conversion from ‘type’ to ‘type’ requires a narrowing conversion
C5022 ‘type’: multiple move constructors specified
C5023 ‘type’: multiple move assignment operators specified
C5024 ‘declaration’: move constructor was implicitly defined as deleted
C5025 ‘declaration’: move assignment operator was implicitly defined as deleted
C5026 ‘type’: move constructor was implicitly defined as deleted
C5027 ‘type’: move assignment operator was implicitly defined as deleted
C5028 ‘name’: Alignment specified in prior declaration (number) not specified in definition
C5029 nonstandard extension used: alignment attributes in C++ apply to variables, data members and tag types only
C5030 attribute ‘attribute’ is not recognized

Предупреждения, появившиеся в Visual Studio 2013 (версия компилятора 18.00.21005.1)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:17 компилятора .

Предупреждение Сообщение
C4301 ‘type’: overriding virtual function only differs from ‘declaration’ by const/volatile qualifier
C4316 ‘type’: object allocated on the heap may not be aligned number
C4380 ‘type’: A default constructor cannot be deprecated
C4388 ‘token’: signed/unsigned mismatch
C4423 ‘std::bad_alloc’: will be caught by class (‘type’) on line number
C4424 catch for ‘type’ preceded by ‘type’ on line number; unpredictable behavior may result if ‘std::bad_alloc’ is thrown
C4425 A SAL annotation cannot be applied to ‘. ‘
C4464 relative include path contains ‘..’
C4575 ‘__vectorcall’ incompatible with the ‘/clr’ option: converting to ‘__stdcall’
C4609 ‘type’ derives from default interface ‘type’ on type ‘type’. Use a different default interface for ‘type’, or break the base/derived relationship.
C4754 Conversion rules for arithmetic operations in the comparison at description(number) mean that one branch cannot be executed. Cast ‘type’ to ‘type’ (or similar type of number bytes).
C4755 Conversion rules for arithmetic operations in the comparison at description(number) mean that one branch cannot be executed in an inlined function. Cast ‘type’ to ‘type’ (or similar type of number bytes).
C4767 section name ‘name’ is longer than 8 characters and will be truncated by the linker
C4770 partially validated enum ‘name’ used as index
C4827 A public ‘ToString’ method with 0 parameters should be marked as virtual and override
C4882 passing functors with non-const call operators to concurrency::parallel_for_each is deprecated
C4973 ‘type’: marked as deprecated
C4974 ‘type’: marked as deprecated
C4981 Warbird: function ‘declaration’ marked as __forceinline not inlined because it contains exception semantics
C4990 Warbird: message
C4991 Warbird: function ‘declaration’ marked as __forceinline not inlined because protection level of inlinee is greater than the parent
C4992 Warbird: function ‘declaration’ marked as __forceinline not inlined because it contains inline assembly which cannot be protected

Предупреждения, появившиеся в Visual Studio 2012 (версия компилятора 17.00.51106.1)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:16 компилятора .

Предупреждение Сообщение
C4330 attribute ‘attribute’ for section ‘section’ ignored
C4415 duplicate __declspec(code_seg(‘name’))
C4416 __declspec(code_seg(. )) contains empty string: ignored
C4417 an explicit template instantiation cannot have __declspec(code_seg(. )): ignored
C4418 __declspec(code_seg(. )) ignored on an enum
C4419 ‘name’ has no effect when applied to private ref class ‘type’.
C4435 ‘type’: Object layout under /vd2 will change due to virtual base ‘type’
C4436 dynamic_cast from virtual base ‘type’ to ‘type’ in constructor or destructor could fail with partially-constructed object
C4437 dynamic_cast from virtual base ‘type’ to ‘type’ could fail in some contexts
C4443 expected pragma parameter to be ‘0’, ‘1’, or ‘2’
C4446 ‘type’: cannot map member ‘name’ into this type, due to conflict with the type name. The method was renamed to ‘name’
C4447 ‘main’ signature found without threading model. Consider using ‘int main(Platform::Array

^ args)’.

C4448 ‘type’ does not have a default interface specified in metadata. Picking: ‘type’, which may fail at runtime.
C4449 ‘type’ an unsealed type should be marked as ‘[WebHostHidden]’
C4450 ‘type’ should be marked as ‘[WebHostHidden]’ because it derives from ‘type’
C4451 ‘type’: Usage of ref class ‘type’ inside this context can lead to invalid marshaling of object across contexts
C4452 ‘type’: public type cannot be at global scope. It must be in a namespace that is a child of the name of the output .winmd file.
C4453 ‘type’: A ‘[WebHostHidden]’ type should not be used on the published surface of a public type that is not ‘[WebHostHidden]’
C4454 ‘type’ is overloaded by more than the number of input parameters without having [DefaultOverload] specified. Picking ‘declaration’ as the default overload
C4471 ‘name’: a forward declaration of an unscoped enumeration must have an underlying type (int assumed)
C4472 ‘name’ is a native enum: add an access specifier (private/public) to declare a managed/WinRT enum
C4492 ‘type’: matches base ref class method ‘type’, but is not marked ‘override’
C4493 delete expression has no effect as the destructor of ‘type’ does not have ‘public’ accessibility
C4585 ‘type’: A WinRT ‘public ref class’ must either be sealed or derive from an existing unsealed class
C4586 ‘type’: A public type cannot be declared in a top-level namespace called ‘Windows’
C4695 #pragma execution_character_set: ‘argument’ is not a supported argument: currently only ‘UTF-8’ is supported
C4703 potentially uninitialized local pointer variable ‘name’ used
C4728 /Yl- option ignored because PCH reference is required
C4745 volatile access of ‘name’ cannot be honored due to its size
C4746 volatile access of ‘name’ is subject to /volatile: setting; consider using __iso_volatile_load/store intrinsic functions
C4872 floating point division by zero detected when compiling the call graph for the concurrency::parallel_for_each at: ‘description’
C4880 casting from ‘type’ to ‘type’: casting away constness from a pointer or reference may result in undefined behavior in an amp restricted function
C4881 the constructor and/or the destructor will not be invoked for tile_static variable ‘type’
C4966 ‘description’ has __code_seg annotation with unsupported segment name, annotation ignored
C4988 ‘type’: variable declared outside class/function scope
C4989 ‘description’: type has conflicting definitions.

Предупреждения, появившиеся в Visual Studio 2010 (версия компилятора 16.00.40219.01)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:15 компилятора .

Предупреждение Сообщение
C4352 ‘name’: intrinsic function already defined
C4573 the usage of ‘type’ requires the compiler to capture ‘this’ but the current default capture mode does not allow it
C4574 ‘name’ is defined to be ‘0’: did you mean to use ‘#if name’?
C4689 ‘character’: unsupported character in #pragma detect_mismatch; #pragma ignored
C4751 /arch AVX flag does not apply to Intel(R) Streaming SIMD Extensions that are within inline ASM
C4752 found Intel(R) Advanced Vector Extensions; consider using the appropriate /arch AVX flag
C4837 trigraph detected: ‘??character’ replaced by ‘character’
C4986 ‘declaration’: exception specification does not match previous declaration
C4987 nonstandard extension used: ‘throw (. )’

Предупреждения, появившиеся в Visual Studio 2008 (версия компилятора 15.00.21022.08)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:14 компилятора .

Предупреждение Сообщение
C4396 ‘type’: the inline specifier cannot be used when a friend declaration refers to a specialization of a function template
C4413 ‘declaration’: reference member is initialized to a temporary that doesn’t persist after the constructor exits
C4491 ‘description’: has an illegal IDL version format
C4603 ‘name’: macro is not defined or definition is different after precompiled header use
C4627 ‘description’: skipped when looking for precompiled header use
C4750 ‘description’: function with _alloca() inlined into a loop
C4910 ‘type’: ‘__declspec(dllexport)’ and ‘extern’ are incompatible on an explicit instantiation
C4985 ‘declaration’: attributes not present on previous declaration.

Предупреждения, появившиеся в Visual Studio 2005 (версия компилятора 14.00.50727.762)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:13 компилятора .

Предупреждение Сообщение
C4000 UNKNOWN WARNING Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information
C4272 ‘type’: is marked __declspec(dllimport); must specify native calling convention when importing a function.
C4333 ‘expression’: right shift by too large amount, data loss
C4334 ‘expression’: result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
C4335 Mac file format detected: please convert the source file to either DOS or UNIX format
C4342 behavior change: ‘type’ called, but a member operator was called in previous versions
C4350 behavior change: ‘declaration’ called instead of ‘declaration’
C4357 param array argument found in formal argument list for delegate ‘declaration’ ignored when generating ‘type’
C4358 ‘expression’: return type of combined delegates is not ‘void’; returned value is undefined
C4359 ‘type’: Alignment specifier is less than actual alignment (number), and will be ignored.
C4362 ‘type’: alignment greater than 8 bytes is not supported by CLR
C4364 #using for assembly ‘name’ previously seen at description(number) without as_friend attribute; as_friend not applied
C4365 ‘expression’: conversion from ‘type’ to ‘type’, signed/unsigned mismatch
C4366 The result of the unary ‘operator’ operator may be unaligned
C4367 Conversion from ‘type’ to ‘type’ may cause datatype misalignment exception
C4368 cannot define ‘name’ as a member of managed ‘type’: mixed types are not supported
C4369 ‘type’: enumerator value ‘number’ cannot be represented as ‘type’, value is ‘number’
C4374 ‘declaration’: interface method will not be implemented by non-virtual method ‘declaration’
C4375 non-public method ‘declaration’ does not override ‘declaration’
C4376 access specifier ‘specifier:’ is no longer supported: please use ‘specifier:’ instead
C4377 native types are private by default; -d1PrivateNativeTypes is deprecated
C4378 Must obtain function pointers to run initializers; consider System::ModuleHandle::ResolveMethodHandle
C4379 Version version of the common language runtime is not supported by this compiler. Using this version may cause unexpected results
C4381 ‘declaration’: interface method will not be implemented by non-public method ‘declaration’
C4382 throwing ‘type’: a type with __clrcall destructor or copy constructor can only be caught in /clr:pure module
C4383 ‘type’: the meaning of dereferencing a handle can change, when a user-defined ‘operator’ operator exists; write the operator as a static function to be explicit about the operand
C4384 #pragma ‘directive’ should only be used at global scope
C4393 ‘type’: const has no effect on description data member; ignored
C4394 ‘type’: per-appdomain symbol should not be marked with __declspec(value)
C4395 ‘type’: member function will be invoked on a copy of the initonly data member ‘type’
C4397 DefaultCharSetAttribute is ignored
C4398 ‘type’: per-process global object might not work correctly with multiple appdomains; consider using __declspec(appdomain)
C4399 ‘type’: per-process symbol should not be marked with __declspec(value) when compiled with /clr:pure
C4400 ‘type’: const/volatile qualifiers on this type are not supported
C4412 ‘declaration’: function signature contains type ‘type’; C++ objects are unsafe to pass between pure code and mixed or native.
C4429 possible incomplete or improperly formed universal-character-name
C4430 missing type specifier — int assumed. Note: C++ does not support default-int
C4431 missing type specifier — int assumed. Note: C no longer supports default-int
C4434 a static constructor must have private accessibility; changing to private access
C4439 ‘type’: function definition with a managed type in the signature must have a __clrcall calling convention
C4441 calling convention of ‘convention’ ignored; ‘convention’ used instead
C4445 ‘declaration’: in a managed/WinRT type a virtual method cannot be private
C4460 CLR/WinRT operator ‘type’, has parameter passed by reference. CLR/WinRT operator ‘operator’ has different semantics from C++ operator ‘operator’, did you intend to pass by value?
C4461 ‘type’: this class has a finalizer ‘!type’ but no destructor ‘

type’

C4470 floating-point control pragmas ignored under /clr
C4480 nonstandard extension used: specifying underlying type for enum ‘type’
C4481 nonstandard extension used: override specifier ‘specifier’
C4482 nonstandard extension used: enum ‘type’ used in qualified name
C4483 syntax error: expected C++ keyword
C4484 ‘type’: matches base ref class method ‘type’, but is not marked ‘virtual’, ‘new’ or ‘override’; ‘new’ (and not ‘virtual’) is assumed
C4485 ‘type’: matches base ref class method ‘type’, but is not marked ‘new’ or ‘override’; ‘new’ (and ‘virtual’) is assumed
C4486 ‘type’: a private virtual method of a ref class or value class should be marked ‘sealed’
C4487 ‘type’: matches inherited non-virtual method ‘type’ but is not explicitly marked ‘new’
C4488 ‘type’: requires ‘keyword’ keyword to implement the interface method ‘type’
C4489 ‘keyword’: not allowed on interface method ‘name’; override specifiers are only allowed on ref class and value class methods
C4490 ‘keyword’: incorrect use of override specifier; ‘type’ does not match a base ref class method
C4538 ‘type’: const/volatile qualifiers on this type are not supported
C4559 ‘type’: redefinition; the function gains __declspec(value)
C4565 ‘type’: redefinition; the symbol was previously declared with __declspec(value)
C4566 character represented by universal-character-name ‘character’ cannot be represented in the current code page (number)
C4568 ‘type’: no members match the signature of the explicit override
C4569 ‘type’: no members match the signature of the explicit override
C4570 ‘type’: is not explicitly declared as abstract but has abstract functions
C4571 Informational: catch(. ) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
C4572 [ParamArray] attribute is deprecated under /clr, use ‘. ‘ instead
C4580 [attribute] is deprecated; instead specify specifiedAttribute as a base class
C4581 deprecated behavior: ‘»name»‘ replaced with ‘name’ to process attribute
C4606 #pragma warning: ‘number’ ignored; Code Analysis warnings are not associated with warning levels
C4631 MSXML or XPath unavailable, XML document comments will not be processed. description
C4632 XML document comment: description — access denied: description
C4633 XML document comment description: error: description
C4634 XML document comment description: cannot be applied: description
C4635 XML document comment description: badly-formed XML: description
C4636 XML document comment description: tag requires non-empty ‘description’ attribute.
C4637 XML document comment description: tag discarded. description
C4638 XML document comment description: reference to unknown symbol ‘description’.
C4639 MSXML error, XML document comments will not be processed. description
C4641 XML document comment has an ambiguous cross reference:
C4678 base class ‘declaration’ is less accessible than ‘name’
C4679 ‘description’: could not import member
C4687 ‘type’: a sealed abstract class cannot implement an interface ‘type’
C4688 ‘name’: constraint list contains assembly private type ‘declaration’
C4690 [ emitidl( pop ) ]: more pops than pushes
C4691 ‘type’: type referenced was expected in unreferenced module ‘description’, type defined in current translation unit used instead
C4692 ‘name’: signature of non-private member contains assembly private native type ‘declaration’
C4693 ‘type’: a sealed abstract class cannot have any instance members ‘name’
C4694 ‘type’: a sealed abstract class cannot have a base-class ‘type’
C4720 in-line assembler reports: ‘description’
C4721 ‘description’: not available as an intrinsic
C4722 ‘description’: destructor never returns, potential memory leak
C4726 ARM arch4/4T supports only ‘ or ‘ with immediate value
C4727 PCH named name with same timestamp found in name and name. Using first PCH.
C4729 function too big for flow graph based warnings
C4730 ‘description’: mixing _m64 and floating point expressions may result in incorrect code
C4731 ‘description’: frame pointer register ‘register’ modified by inline assembly code
C4732 intrinsic ‘intrinsic’ is not supported in this architecture
C4733 Inline asm assigning to ‘FS:0’: handler not registered as safe handler
C4734 More than 64k line numbers in a COFF debug info section; stop emitting COFF debug line numbers for module ‘module’
C4738 storing 32-bit float result in memory, possible loss of performance
C4739 reference to variable ‘variable’ exceeds its storage space
C4740 flow in or out of inline asm code suppresses global optimization
C4742 ‘variable’ has different alignment in ‘location’ and ‘location’: number and number
C4743 ‘name’ has different size in ‘location’ and ‘location’: number and number bytes
C4744 ‘name’ has different type in ‘location’ and ‘location’: ‘type’ and ‘type’
C4747 Calling managed ‘type’: Managed code may not be run under loader lock, including the DLL entrypoint and calls reached from the DLL entrypoint
C4761 integral size mismatch in argument; conversion supplied
C4764 Cannot align catch objects to greater than 16 bytes
C4788 ‘identifier’: identifier was truncated to ‘number’ characters
C4789 buffer ‘name’ of size number bytes will be overrun; number bytes will be written starting at offset number
C4801 Return by reference is not verifiable: description
C4819 The file contains a character that cannot be represented in the current code page (number). Save the file in Unicode format to prevent data loss
C4826 Conversion from ‘type’ to ‘type’ is sign-extended. This may cause unexpected runtime behavior.
C4829 Possibly incorrect parameters to function main. Consider ‘int main(Platform::Array

^ argv)’

C4835 ‘type’: the initializer for exported data will not be run until managed code is first executed in the host assembly
C4867 ‘type’: non-standard syntax; use ‘&’ to create a pointer to member
C4936 this __declspec is supported only when compiled with /clr or /clr:pure
C4937 ‘name’ and ‘name’ are indistinguishable as arguments to ‘option’
C4938 ‘type’: Floating point reduction variable may cause inconsistent results under /fp:strict or #pragma fenv_access
C4939 #pragma vtordisp is deprecated and will be removed in a future release of Visual C++
C4947 ‘type’: marked as obsolete
C4949 pragmas ‘managed’ and ‘unmanaged’ are meaningful only when compiled with ‘/clr[:option]’
C4950 ‘type’: marked as obsolete
C4955 ‘description’: import ignored; already imported from ‘source’
C4956 ‘type’: this type is not verifiable
C4957 ‘expression’: explicit cast from ‘type’ to ‘type’ is not verifiable
C4958 ‘expression’: pointer arithmetic is not verifiable
C4959 cannot define unmanaged class ‘type’ in /clr:safe because accessing its members yields unverifiable code
C4960 ‘description’ is too big to be profiled
C4961 No profile data was merged into ‘location’, profile-guided optimizations disabled
C4962 ‘description’: Profile-guided optimizations disabled because optimizations caused profile data to become inconsistent
C4963 ‘description’: no profile data found; different compiler options were used in instrumented build
C4964 No optimization options were specified; profile info will not be collected
C4965 implicit box of integer 0; use nullptr or explicit cast
C4970 delegate constructor: target object ignored since ‘declaration’ is static
C4971 Argument order: , for delegate constructor is deprecated, use ,
C4972 Directly modifying or treating the result of an unbox operation as an lvalue is unverifiable

Предупреждения, появившиеся в Visual Studio 2003 (версия компилятора 13.10.3077)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:13.00.9466 компилятора .

Предупреждение Сообщение
C4343 #pragma optimize(description,off) overrides /Og option
C4344 behavior change: use of explicit template arguments results in call to ‘declaration’
C4346 ‘type’: dependent name is not a type
C4348 ‘declaration’: redefinition of default parameter: parameter number
C4356 ‘type’: static data member cannot be initialized via derived class
C4408 anonymous struct did not declare any data members
C4544 ‘declaration’: default template argument ignored on this template declaration
C4545 expression before comma evaluates to a function which is missing an argument list
C4546 function call before comma missing argument list
C4547 ‘expression’: operator before comma has no effect; expected operator with side-effect
C4548 expression before comma has no effect; expected expression with side-effect
C4549 ‘expression’: operator before comma has no effect; did you intend ‘expression’?
C4628 digraphs not supported with -Ze. Character sequence ‘sequence’ not interpreted as alternate token for ‘token’
C4629 digraph used, character sequence ‘sequence’ interpreted as token ‘token’ (insert a space between the two characters if this is not what you intended)
C4671 ‘description’: the copy constructor is inaccessible
C4676 ‘description’: the destructor is inaccessible
C4677 ‘name’: signature of non-private member contains assembly private type ‘declaration’
C4686 ‘type’: possible change in behavior, change in UDT return calling convention
C4812 obsolete declaration style: please use ‘type::name’ instead
C4813 ‘type’: a friend function of a local class must have been previously declared
C4821 Unable to determine Unicode encoding type, please save the file with signature (BOM)
C4822 ‘type’: local class member function does not have a body
C4823 ‘type’: uses pinning pointers but unwind semantics are not enabled. Consider using /EHa
C4913 user defined binary operator ‘,’ exists but no overload could convert all operands, default built-in binary operator ‘,’ used
C4948 return type of ‘declaration’ does not match the last parameter type of the corresponding setter
C4951 ‘description’ has been edited since profile data was collected, function profile data not used
C4952 ‘description’: no profile data found in program database ‘description’
C4953 Inlinee ‘description’ has been edited since profile data was collected, profile data not used
C4954 ‘description’: not profiled (contains __int64 switch expression)

Предупреждения, появившиеся в Visual Studio 2002 (версия компилятора 13.00.9466)

Эти предупреждения и все предупреждения в более поздних версиях подавляются с помощью параметра /Wv:12 компилятора .

Источник

See more:

I am trying to run this program and keep getting the same errors. What does missing terminating character mean and how can I fix these issues in my code? Everything runs fine on Repl for me. I copied and pasted to Linux and now I got all of these errors.

RPS.c:162:10: warning: missing terminating » character
RPS.c: In function âprintResultsâ:
RPS.c:162: error: missing terminating » character
RPS.c:163: error: expected expression before â%â token
RPS.c:163:9: warning: missing terminating » character
RPS.c:163: error: missing terminating » character
RPS.c:164: error: expected â;â before â}â token

code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
        
    void flushScanf(void);
    
    
    int compareInputs(char);
    
    
    char getInput();
    
    
    void printResults(int, int, int);
    
    
    int main(void) {
        char userInput;
    int flag=1;
    int myWins= 0;
    int pcWins= 0;
    int ties= 0;
    int result;
    
    printf("Let’s play a game of Rock/Paper/Scissors n");
    
        do{
      userInput = getInput();
      if(userInput == 'Q' || userInput == 'q') {
        printResults(myWins, pcWins, ties);
        printf("nThank you for playing!");
        flag =0;
        }else if(userInput == 'R' || userInput == 'r'){
        userInput = 'r';
        }else if(userInput == 'P' || userInput == 'p'){
        userInput = 'p';
        }else if(userInput == 'S' || userInput == 's'){
        userInput = 's';
        }else{
          printf("Error, Please try againn ");
        }
    
        result = compareInputs(userInput);
    
        switch(result){
          case 1:
            myWins++;
            break;
    
            case 2:
            pcWins++;
            break;
    
            case 3:
            ties++;
            break;
        }
    }while(flag==1);
    
    
    
    
    
      return 0;
    
      
    }
    char getInput(void){
      char userInput;
      printf("nEnter R, P, S, or Q (for quit):");
      scanf("%c", &userInput);
      flushScanf();
    
     
      return userInput;
    }
    
    char check(char input){
    
    }
    
    int compareInputs(char userInput){
    srand(time(NULL));
    
    int pc = (rand()%3)+1;
                if (pc==1 && userInput == 'r'){
      printf("You picked Rock, the computer picked Rock.n");
      printf("It's a tie.n");
      return 3;
    } else if(pc==1 && userInput == 's'){
      printf("You picked Scissors, the computer picked Rock.n");
      printf("Rock breaks Scissors, you lose!n");
      return 2;
      }else if(pc==1 && userInput == 'p'){
        printf("You picked Paper, the computer picked Rock.n");
        printf("Paper covers rock, you win!n");
        return 1;
      }else if (pc==2 && userInput == 'r'){
        printf("You picked Rock, the computer picked Paper.n");
        printf("Paper covers rock, you lose.n");
        return 2;
      } else if (pc==2 && userInput == 's'){
        printf("You picked Scissors, the computer picked Paper.n");
        printf("Scissors cuts Paper, you win!n");
        return 1;
      } else if (pc==2 && userInput == 'p'){
        printf("You picked Paper, the computer picked Paper.n");
        printf("It's a tie.n");
        return 3;
      } else if (pc==3 && userInput == 'r') {
        printf("You picked Rock, the computer picked Scissors.n");
        printf("Rock breaks Scissors, you win!n");
        return 1;
      } else if (pc==3 && userInput =='s'){
        printf("You picked Scissors, the computer picked Scissors.n");
        printf("It's a tien");
        return 3;
      }  else if (pc==3 && userInput == 'p'){
      printf("You picked Paper, the computer picked Scissors.n");
      printf("Scissors cuts paper, You lose!n");
      return 2;
      }
      return 4;
    }
    
    void printResults(int myWins, int pcWins, int ties){
      printf("nYou won %d times, the computer won %d times, and it was a tie %d times", myWins, pcWins, ties);
    }
    
    void flushScanf(void) {
      char c = getchar();
    
      while (c != 'n' && c != EOF) {
        c = getchar();
        }
      }

What I have tried:

Retyped quotations and other punctuation marks in case its because the editor uses a different character system.


Configuration

Operating system:
MAC OSX
PlatformIO Version (platformio --version):
PlatformIO, version 2.11.2

Description of problem

not build it
on original Arduino IDE no problem

Steps to Reproduce

  1. just build
    2.
    3.

Actual Results

/Users/KOCMOHABT/Documents/Arduino/Scetches/Wi-Fi-Sensor-master/esp_sensor/src/esp_sensor.ino:268:1: warning: missing t
erminating » character [enabled by default]
«<SCRIPT>
^
/Users/KOCMOHABT/Documents/Arduino/Scetches/Wi-Fi-Sensor-master/esp_sensor/src/esp_sensor.ino:268:1: error: missing ter
minating » character

Expected Results

If problems with PlatformIO Build System:

The content of platformio.ini:
[env:esp8285]
platform = espressif
framework = arduino
board = esp8285

Source file to reproduce issue:

#include <ESP8266WiFi.h>
//#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>

extern "C" {
#include "user_interface.h"
}

#include <PubSubClient.h>
#include <Wire.h>
#include "SPI.h"
#include <BH1750.h>
#include <NTPClient.h>
#include "json_config.h"
#include <ArduinoJson.h>
#include <WiFiUdp.h>

#if defined(UART_ON)
#include "MY_ESP_UART.h"
Espuart Uart;
#endif

JsonConf JConf;

#if defined(DHT_ON)
#include "DHT.h"
#define DHTTYPE DHT22
DHT dht(atoi(JConf.dht_pin), DHTTYPE);
int errorDHTdata = 0;  // количество ошибок чтения датчика DHT
#endif

#if defined(BME280_ON)
#include "SparkFunBME280.h"
BME280 bmeSensor;
#endif

#if defined(SHT21_ON)
#include "HTU21D.h"
HTU21D myHTU21D;
#endif

ADC_MODE(ADC_VCC);
float voltage_float;

const char *ver                = "1.08"              ;

const char *lux                = "Lux"               ;
const char *lightType          = "LightType"         ;
const char *lightType2         = "LightType2"        ;
const char *temperature        = "Temp"              ;
const char *humidity           = "Humidity"          ;
const char *pressure           = "Pressure"          ;
const char *altitude           = "Altitude"          ;
const char *motionSensor       = "MotionSensor"      ;
const char *motionsensortimer  = "MotionSensorTimer" ;
const char *motionsensortimer2 = "MotionSensorTimer2";
const char *version            = "Version"           ;
const char *freeMemory         = "FreeMemory"        ;
const char *ip                 = "IP"                ;
const char *mac                = "MAC"               ;
const char *errorsDHT          = "ErrorsDHT"         ;
const char *uptime             = "Uptime"            ;

const char sec[] PROGMEM = "sec";


String temperatureString = "none";
String pressureString =    "none";
String humidityString =    "none";
String luxString =         "none";
String ipString =          "none";
String macString =         "none";
String uptimeString =      "none";
String ntpTimeString =     "none";
String freeMemoryString =  "none";
String lightState =        "AUTO";
String lightState2 =       "AUTO";

BH1750 lightSensor;
PubSubClient mqttClient;

long Day=0;
int Hour =0;
int Minute=0;
int Second=0;
int HighMillis=0;
int Rollover=0;

unsigned long getDataTimer = 0;
unsigned long publishTimer = 2000;
unsigned long motionTimer = 4000;
unsigned long rebootTimer = 6000;
unsigned long subscribeTimer = (atoi(JConf.subscribe_delay) *1000UL) - 5000UL;
unsigned long lightOffTimer = 0;
unsigned long lightOffTimer2 = 0;
unsigned long wifiSafeModeReconnectTimer = 0;

unsigned long wifiSafeModeReconnectDelay=600000;

bool motionDetect = false;

bool wifiSafeMode = false;

WiFiClient espClient;

WiFiUDP ntpUDP;

NTPClient timeClient(ntpUDP);

char topic_buff[120];
char value_buff[120];

String network_html;          // Список доступных Wi-Fi точек

ESP8266WebServer WebServer(80);


int cycleNow[ESP_PINS];
int cycleEnd[ESP_PINS];

unsigned long timerDigitalPin[ESP_PINS];
int delayDigitalPin = 10;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////         HTML SNIPPLETS

/*
String headerStart;           headerStart += FPSTR(headerStartP);
String headerRefreshStatus;   headerRefreshStatus += FPSTR(headerRefreshStatusP);
String headerEnd;             headerEnd += FPSTR(headerEndP);
String javaScript;            javaScript += FPSTR(javaScriptP);
String javaScriptEnd;         javaScriptEnd += FPSTR(javaScriptEndP);
String bodyAjax;              bodyAjax += FPSTR(bodyAjaxP);
String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
String navbarStart;           navbarStart += FPSTR(navbarStartP);
String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);
String navbarActive;          navbarActive += FPSTR(navbarActiveP);
String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
String containerStart;        containerStart += FPSTR(containerStartP);
String containerEnd;          containerEnd += FPSTR(containerEndP);
String siteEnd;               siteEnd += FPSTR(siteEndP);
String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);
String panelEnd;              panelEnd += FPSTR(panelEndP);
String panelBodySymbol;       panelBodySymbol += FPSTR(panelBodySymbolP);
String panelBodyName;         panelBodyName += FPSTR(panelBodyNameP);
String panelBodyValue;        panelBodyValue += FPSTR(panelBodyValueP);
String closingAngleBracket;   closingAngleBracket += FPSTR(closingAngleBracketP);

String panelBodyEnd;          panelBodyEnd += FPSTR(panelBodyEndP);

String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);

String sketchUploadForm;      sketchUploadForm += FPSTR(sketchUploadFormP);

String ClassInfo;       ClassInfo += FPSTR(ClassInfoP);
String ClassDanger;     ClassDanger += FPSTR(ClassDangerP);
String ClassDefault;    ClassDefault += FPSTR(ClassDefaultP);
String ClassSuccess;    ClassSuccess += FPSTR(ClassSuccessP);

String AUTO;       AUTO += FPSTR(AUTOP);
String ON;         ON += FPSTR(ONP);
String OFF;        OFF += FPSTR(OFFP);


*/

const char headerStartP[] PROGMEM = "<html lang='en'><head><title>";
//JConf.module_id
const char headerStart2P[] PROGMEM = "</title><meta charset='utf-8'>";

const char headerRefreshStatusP[] PROGMEM = "<META HTTP-EQUIV='Refresh' CONTENT='20; URL=/'>";

const char headerEndP[] PROGMEM =
"<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css'>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js'></script></head>";

const char javaScriptPinControlP[] PROGMEM =
"<div id='content'></div>
<div id='pin1'></div>
<script>
function show()
{
$.ajax({
url: 'controlstatus',
cache: false,
success: function(html){
$('#content').html(html);
}
});
}
function Pin1()
{
$.ajax({
type: 'POST',
url: 'control',
data: '1=1',
success: function(data){
show();
}
});
}
function Auto1()
{
$.ajax({
type: 'POST',
url: 'control',
data: '1=2',
success: function(data){
show();
}
});
}
function Pin2()
{
$.ajax({
type: 'POST',
url: 'control',
data: '2=1',
success: function(data){
show();
}
});
}
function Auto2()
{
$.ajax({
type: 'POST',
url: 'control',
data: '2=2',
success: function(data){
show();
}
});
}
$(document).ready(function(){
show();
setInterval('show()',5000);
});
</script>";

const char div1P[] PROGMEM =
"<div class='col-sm-8 col-md-6 col-lg-5'><h2>Control Pins</h2>
<table class='table table-hover'>
<tbody>
  <tr>
    <td class='active'><h4>Pins</h4></td>
    <td class='active'></td><td class='active'></td>
    <td class='active'><h4>Status</h4></td>
    <td class='active'><h4>Mode</h4></td>
    <td class='active'><h4>Timer</h4></td>
  </tr>
  <tr>
    <td class='active'><h4>Light1</h4></td>
    <td class='active'><div onclick='Pin1();'><input id='OnOff' type='submit' class='btn btn-";

const char javaScriptP[] PROGMEM =
"<SCRIPT>
var xmlHttp=createXmlHttpObject();
function createXmlHttpObject(){
  if(window.XMLHttpRequest){
    xmlHttp=new XMLHttpRequest();
  }else{
    xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
 }
 return xmlHttp;
}
function process(){
 if(xmlHttp.readyState==0 || xmlHttp.readyState==4){
   xmlHttp.open('PUT','xml',true);
   xmlHttp.onreadystatechange=handleServerResponse;
   xmlHttp.send(null);
 }
 setTimeout('process()',10000);
}
function handleServerResponse(){
 if(xmlHttp.readyState==4 && xmlHttp.status==200){
   xmlResponse=xmlHttp.responseXML;";

#if defined(UART_ON)
const char javaScript2P[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('apin0');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin0Id').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('apin1');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin1Id').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('apin2');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin2Id').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('apin3');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin3Id').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('apin4');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin4Id').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('apin5');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('apin5Id').innerHTML=message;
 }
}
</SCRIPT>";
#endif

const char jsTemperatureP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('temperature');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('temperatureId').innerHTML=message;";

const char jsHumidityP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('humidity');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('humidityId').innerHTML=message;";

const char jsIlluminanceP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('illuminance');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('illuminanceId').innerHTML=message;";

const char jsPressureP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('pressure');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('pressureId').innerHTML=message;";


const char jsNtpP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('ntpTime');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('ntpTimeId').innerHTML=message;";

// Длина строки не должна быть больше 1024 символов
const char javaScriptEndP[] PROGMEM =
"xmldoc = xmlResponse.getElementsByTagName('vcc');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('vccId').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('uptime');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('uptimeId').innerHTML=message;
xmldoc = xmlResponse.getElementsByTagName('freeMemory');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('freeMemoryId').innerHTML=message;
 }
}
</SCRIPT>";

const char bodyAjaxP[] PROGMEM = "<body onload='process()'>";
const char bodyNonAjaxP[] PROGMEM = "<body>";

const char navbarStartP[] PROGMEM =
"<nav class='navbar navbar-inverse'><div class='container-fluid'><div class='navbar-header'>
<a class='navbar-brand' href='/'>";
//JConf.module_id
const char navbarStart2P[] PROGMEM = "</a></div><div><ul class='nav navbar-nav'>";

const char navbarNonActiveP[] PROGMEM = "<li>";
const char navbarActiveP[] PROGMEM = "<li class='active'>";

const char navbarBeginP[] PROGMEM  =
"<a href='/'><span class='glyphicon glyphicon-dashboard'></span> Status</a></li>
<li><a href='/pincontrol'><span class='glyphicon glyphicon-tasks'></span> Control Pins</a></li>";

#if defined(UART_ON)
const char navbarUartP[] PROGMEM =
"<li><a href='/analog'><span class='glyphicon glyphicon-tasks'></span> Analog Pins UART</a></li>";
#endif

const char navbarEndP[] PROGMEM =
"<li class='dropdown'><a class='dropdown-toggle' data-toggle='dropdown' href='#'>
<span class='glyphicon glyphicon-cog'></span> Configure<span class='caret'></span></a><ul class='dropdown-menu'>
<li><a href='/wificonf'>Wi-Fi</a></li>
<li><a href='/sensorsconf'>Sensors</a></li>
<li><a href='/espconf'>ESP</a></li>
<li><a href='/mqttconf'>MQTT</a></li>
<li><a href='/ntpconf'>NTP time</a></li>
<li><a href='/update'>Update frimware</a></li>
<li><a href='/reboot'>Reboot ESP</a></li>
</ul></li></ul></div></div></nav>";

const char containerStartP[] PROGMEM    =  "<div class='container'><div class='row'>";
const char containerEndP[] PROGMEM      =  "<div class='clearfix visible-lg'></div></div></div>";
const char siteEndP[] PROGMEM         =  "</body></html>";

const char panelHeaderNameP[] PROGMEM     =  "<div class='col-sm-6 col-md-5 col-lg-4'><div class='page-header'><h2>";
const char panelHeaderEndP[] PROGMEM    =  "</h2></div>";
const char panelEndP[] PROGMEM        =  "</div>";

const char panelBodySymbolP[] PROGMEM     =
"<div class='panel panel-default'><div class='panel-body'><span class='glyphicon glyphicon-";

const char panelBodyNameP[] PROGMEM     =  "'></span> ";
const char panelBodyValueP[] PROGMEM    =  "<span class='pull-right'";
const char closingAngleBracketP[] PROGMEM    =  ">";

const char panelBodyEndP[] PROGMEM      =  "</span></div></div>";

const char inputBodyStartP[] PROGMEM    =
"<form action='' method='POST'><div class='panel panel-default'><div class='panel-body'>";

const char inputBodyNameP[] PROGMEM     =
"<div class='form-group'><div class='input-group'><span class='input-group-addon' id='basic-addon1'>";

const char inputBodyPOSTP[] PROGMEM     =  "</span><input type='text' name='";
const char inputPlaceHolderP[] PROGMEM  =  "' class='form-control' value='";

const char inputBodyCloseP[] PROGMEM    =  "' aria-describedby='basic-addon1'>";

const char inputBodyUnitStartP[] PROGMEM    =  "<span class='input-group-addon' id='basic-addon1'>";
const char inputBodyUnitEndP[] PROGMEM    =  "</span>";

const char inputBodyCloseDivP[] PROGMEM    =  "</div></div>";

const char inputBodyEndP[] PROGMEM      =
"</div><div class='panel-footer clearfix'><div class='pull-right'>
<button type='submit' class='btn btn-default' name='save_conf' value='1'>Save</button></div></div></div></form>";

const char sketchUploadFormP[] PROGMEM  =
"<div class='col-sm-6 col-md-5 col-lg-4'><div class='page-header'><h2>Update Frimware</h2></div>
<form method='POST' action='/upload_sketch' enctype='multipart/form-data'>
<p><input type='file' class='btn btn-primary' name='sketch'></p>
<h3><small>Выберите файл формата *.bin</small></h3>
<p><input type='submit' value='Upload' class='btn btn-danger'></p></form></div>";


const char ClassInfoP[] PROGMEM  = "info";
const char ClassDangerP[] PROGMEM  = "danger";
const char ClassDefaultP[] PROGMEM  = "default";
const char ClassSuccessP[] PROGMEM  = "success";

const char AUTOP[] PROGMEM  = "AUTO";
const char ONP[] PROGMEM  = "ON";
const char OFFP[] PROGMEM  = "OFF";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////         ROOT


static char* floatToChar(float charester)
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("floatToChar() Start"));
  #endif

 dtostrf(charester, 1, 0, value_buff);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("floatToChar() Load Time: ")); Serial.println(load_time);
  #endif

 return value_buff;
}


void GetFreeMemory () {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetFreeMemory() Start"));
  #endif

  freeMemoryString = String(ESP.getFreeHeap());

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetFreeMemory() Load Time: ")); Serial.println(load_time);
  #endif
}



String GetIpString (IPAddress ip) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetIpString() Start"));
  #endif

  String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetIpString() Load Time: ")); Serial.println(load_time);
  #endif

  return ipStr;
}



void GetMacString () {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetMacString() Start"));
  #endif

  uint8_t macData[6];
  WiFi.macAddress(macData);
  sprintf_P(value_buff, (const char *)F("%x:%x:%x:%x:%x:%x"), macData[0],  macData[1], macData[2], macData[3], macData[4], macData[5]);
  if (macString != String(value_buff)){
    macString = String(value_buff);
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetMacString() Load Time: ")); Serial.println(load_time);
  #endif
}



IPAddress stringToIp (String strIp) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("stringToIp() Start"));
  #endif

  String temp;
  IPAddress ip;

  int count = 0;
  for(int i=0; i <= strIp.length(); i++)
  {
    if(strIp[i] != '.')
    {
      temp += strIp[i];
    }
    else
    {
      if(count < 4)
      {
        ip[count] = atoi(temp.c_str());
        temp = "";
        count++;
      }
    }
    if(i==strIp.length())
    {
      ip[count] = atoi(temp.c_str());
    }
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("stringToIp() Load Time: ")); Serial.println(load_time);
  #endif

  return ip;
}



bool isIPValid(const char * IP){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("isIPValid() Start"));
  #endif

  //limited size
  int internalcount=0;
  int dotcount = 0;
  bool previouswasdot=false;
  char c;

  if (strlen(IP)>15 || strlen(IP)==0) {
      return false;
  }
  //cannot start with .
  if (IP[0]=='.') {
      return false;
  }
  //only letter and digit
  for (int i=0; i < strlen(IP); i++) {
      c = IP[i];
      if (isdigit(c)) {
          //only 3 digit at once
          internalcount++;
          previouswasdot=false;
          if (internalcount>3) {
              return false;
          }
      } else if(c=='.') {
          //cannot have 2 dots side by side
          if (previouswasdot) {
              return false;
          }
          previouswasdot=true;
          internalcount=0;
          dotcount++;
      }//if not a dot neither a digit it is wrong
      else {
          return false;
      }
  }
  //if not 3 dots then it is wrong
  if (dotcount!=3) {
      return false;
  }
  //cannot have the last dot as last char
  if (IP[strlen(IP)-1]=='.') {
      return false;
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("isIPValid() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



void PWMChange(int pin, int bright){
  cycleEnd[pin] = bright;

  if ( ( atoi(JConf.light_smooth) == 0 && pin == atoi(JConf.light_pin) )   ||   ( atoi(JConf.light2_smooth) == 0 && pin == atoi(JConf.light2_pin) ) ){
    if (cycleNow[pin] < cycleEnd[pin]){
      cycleNow[pin] = 1022;
    } else if (cycleNow[pin] > cycleEnd[pin]){
      cycleNow[pin] = 1;
    }
  }
}



void FadeSwitchDelay(int pin){
  if (millis() - timerDigitalPin[pin] >= delayDigitalPin && cycleNow[pin] != cycleEnd[pin]){
    timerDigitalPin[pin] = millis();
    if (cycleNow[pin] < cycleEnd[pin]){
      cycleNow[pin] = constrain(cycleNow[pin] + 10, 0, 1023);
    } else if (cycleNow[pin] > cycleEnd[pin]){
      cycleNow[pin] = constrain(cycleNow[pin] - 10, 0, 1023);
    }
    analogWrite(pin, cycleNow[pin]);

    #ifdef DEBUG
    Serial.print(F("PWM pin: ")); Serial.print(pin);
    Serial.print(F("   PWM Value: ")); Serial.println(cycleNow[pin]);
    #endif
  }
}



void FadeSwitchLoop(){
  for ( size_t i = 0; i < ESP_PINS; i++ ){
    FadeSwitchDelay(i);
  }
}



void LightControl() {

  #ifdef DEBUG11
    unsigned long start_time = millis();
    Serial.println(F("LightControl() Start"));
  #endif

  String AUTO;       AUTO += FPSTR(AUTOP);
  String ON;         ON += FPSTR(ONP);
  String OFF;        OFF += FPSTR(OFFP);

  if (lightState == ON && luxString.toInt() < atoi(JConf.lighton_lux)){
    PWMChange(atoi(JConf.light_pin), 1023);
  } else if (lightState == OFF){
    PWMChange(atoi(JConf.light_pin), 0);
  } else if (lightState == AUTO && motionDetect == true && luxString.toInt() < atoi(JConf.lighton_lux)){
    PWMChange(atoi(JConf.light_pin), 1023);
    lightOffTimer = millis();
  } else if (lightState == AUTO && motionDetect == false && cycleEnd[atoi(JConf.light_pin)] != 0){
    if (millis() - lightOffTimer >= atoi(JConf.lightoff_delay) * 60UL * 1000UL){
      PWMChange(atoi(JConf.light_pin), 0);
    }
  }

  if (lightState2 == ON && luxString.toInt() < atoi(JConf.light2on_lux)){
    PWMChange(atoi(JConf.light2_pin), 1023);
  } else if (lightState2 == OFF){
    PWMChange(atoi(JConf.light2_pin), 0);
  } else if (lightState2 == AUTO && motionDetect == true && luxString.toInt() < atoi(JConf.light2on_lux)){
    PWMChange(atoi(JConf.light2_pin), 1023);
    lightOffTimer2 = millis();
  } else if (lightState2 == AUTO && motionDetect == false && cycleEnd[atoi(JConf.light2_pin)] != 0){
    if (millis() - lightOffTimer2 >= atoi(JConf.light2off_delay) * 60UL * 1000UL){
      PWMChange(atoi(JConf.light2_pin), 0);
    }
  }

  #ifdef DEBUG11
    unsigned long load_time = millis() - start_time;
    Serial.print(F("LightControl() Load Time: ")); Serial.println(load_time);
  #endif
}



void scanWiFi(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("scanWiFi() Start"));
  #endif

  int founds = WiFi.scanNetworks();
  #ifdef DEBUG
  Serial.println();  Serial.println(F("scan done"));
  #endif
  if (founds == 0) {
    #ifdef DEBUG
    Serial.println(F("no networks found"));
    #endif
  } else {
    #ifdef DEBUG
    Serial.print(founds);  Serial.println(F(" networks found"));
    for (size_t i = 0; i < founds; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);  Serial.print(F(": "));  Serial.print(WiFi.SSID(i));  Serial.print(F(" ("));  Serial.print(WiFi.RSSI(i));  Serial.print(F(")"));
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? F(" ") : F("*"));
      delay(10);
    }
    #endif
  }
  network_html = String(F("<blockquote>"));
  for (size_t i = 0; i < founds; ++i)
  {
    // Print SSID and RSSI for each network found
    network_html += String(F("<p><kbd>"));
    network_html += WiFi.SSID(i);
    network_html += String(F(" ("));
    network_html += WiFi.RSSI(i);
    network_html += String(F(")"));
    network_html += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? F(" ") : F("*");
    network_html += String(F("</kbd></p>"));
  }
  network_html += String(F("</blockquote>"));

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("scanWiFi() Load Time: ")); Serial.println(load_time);
  #endif
}


bool WiFiSetup()
{
  wifi_set_sleep_type ((sleep_type_t)NONE_SLEEP_T);   // NONE_SLEEP_T,LIGHT_SLEEP_T,MODEM_SLEEP_T
  //disconnect if connected
  WiFi.disconnect();
  //this is AP mode
  if (atoi(JConf.wifi_mode) == AP) {
    //setup Soft AP
    WiFi.mode(WIFI_AP);

    if (atoi(JConf.wifi_auth) == OPEN){
      WiFi.softAP(JConf.module_id);
    } else {
      WiFi.softAP(JConf.module_id, JConf.ap_pwd);
    }

    //setup PHY_MODE
    if (atoi(JConf.wifi_phy_mode) == B){
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11B);    //PHY_MODE_11B,PHY_MODE_11G,PHY_MODE_11N
    } else if (atoi(JConf.wifi_phy_mode) == G){
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11G);
    } else {
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11N);
    }

    //get current config
    struct softap_config apconfig;
    wifi_softap_get_config(&apconfig);
    //set the chanel
    apconfig.channel=atoi(JConf.wifi_channel);

    //set Authentification type                      //AUTH_OPEN,AUTH_WPA_PSK,AUTH_WPA2_PSK,AUTH_WPA_WPA2_PSK
    if (atoi(JConf.wifi_auth) == OPEN){
      apconfig.authmode=(AUTH_MODE)AUTH_OPEN;
    } else if (atoi(JConf.wifi_auth) == WPA_PSK){
      apconfig.authmode=(AUTH_MODE)AUTH_WPA_PSK;
    } else if (atoi(JConf.wifi_auth) == WPA2_PSK){
      apconfig.authmode=(AUTH_MODE)AUTH_WPA2_PSK;
    } else {
      apconfig.authmode=(AUTH_MODE)AUTH_WPA_WPA2_PSK;
    }

    //set the visibility of SSID
    apconfig.ssid_hidden=0;
    //no need to add these settings to configuration just use default ones
    //apconfig.max_connection=2;
    //apconfig.beacon_interval=100;
    //apply settings to current and to default
    if (!wifi_softap_set_config(&apconfig) || !wifi_softap_set_config_current(&apconfig)) {
        Serial.println(F("Error Wifi AP!"));
        delay(1000);
    }

  } else if (atoi(JConf.wifi_mode) == STA) {
    //setup station mode
    WiFi.mode(WIFI_STA);
    WiFi.begin(JConf.sta_ssid, JConf.sta_pwd);
    delay(500);
    //setup PHY_MODE
    wifi_set_phy_mode((phy_mode_t)PHY_MODE_11N);
    delay(500);
    byte i=0;
    //try to connect
    while (WiFi.status() != WL_CONNECTED && i<40) {
        switch(WiFi.status()) {
        case 1:
            Serial.println(F("No SSID found!"));
            break;

        case 4:
            Serial.println(F("No Connection!"));
            break;

        default:
            Serial.println(F("Connecting..."));
            break;
        }
        delay(500);
        i++;
    }
    if (WiFi.status() != WL_CONNECTED) {
        return false;
    }
    WiFi.hostname(JConf.module_id);
  } else if (atoi(JConf.wifi_mode) == AP_STA) {
    WiFi.mode(WIFI_AP_STA);
    WiFi.begin(JConf.sta_ssid, JConf.sta_pwd);

    delay(500);
    byte i=0;
    //try to connect
    while (WiFi.status() != WL_CONNECTED && i<40) {
        switch(WiFi.status()) {
        case 1:
            Serial.println(F("No SSID found!"));
            break;

        case 4:
            Serial.println(F("No Connection!"));
            break;

        default:
            Serial.println(F("Connecting..."));
            break;
        }
        delay(500);
        i++;
    }
    if (WiFi.status() != WL_CONNECTED) {
        return false;
    }


    if (atoi(JConf.wifi_auth) == OPEN){
      WiFi.softAP(JConf.module_id);
    } else {
      WiFi.softAP(JConf.module_id, JConf.ap_pwd);
    }

    //setup PHY_MODE
    if (atoi(JConf.wifi_phy_mode) == B){
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11B);    //PHY_MODE_11B,PHY_MODE_11G,PHY_MODE_11N
    } else if (atoi(JConf.wifi_phy_mode) == G){
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11G);
    } else {
      wifi_set_phy_mode((phy_mode_t)PHY_MODE_11N);
    }

    //get current config
    struct softap_config apconfig;
    wifi_softap_get_config(&apconfig);
    //set the chanel
    apconfig.channel=atoi(JConf.wifi_channel);

    //set Authentification type                      //AUTH_OPEN,AUTH_WPA_PSK,AUTH_WPA2_PSK,AUTH_WPA_WPA2_PSK
    if (atoi(JConf.wifi_auth) == OPEN){
      apconfig.authmode=(AUTH_MODE)AUTH_OPEN;
    } else if (atoi(JConf.wifi_auth) == WPA_PSK){
      apconfig.authmode=(AUTH_MODE)AUTH_WPA_PSK;
    } else if (atoi(JConf.wifi_auth) == WPA2_PSK){
      apconfig.authmode=(AUTH_MODE)AUTH_WPA2_PSK;
    } else {
      apconfig.authmode=(AUTH_MODE)AUTH_WPA_WPA2_PSK;
    }

    //set the visibility of SSID
    apconfig.ssid_hidden=0;
    //no need to add these settings to configuration just use default ones
    //apconfig.max_connection=2;
    //apconfig.beacon_interval=100;
    //apply settings to current and to default
    if (!wifi_softap_set_config(&apconfig) || !wifi_softap_set_config_current(&apconfig)) {
        Serial.println(F("Error Wifi AP_STA!"));
        delay(1000);
    }
  }

  //DHCP or Static IP ?
  if (atoi(JConf.static_ip_enable) == 1) {

      IPAddress staticIP = stringToIp(JConf.static_ip);
      IPAddress staticGateway = stringToIp(JConf.static_gateway);
      IPAddress staticSubnet = stringToIp(JConf.static_subnet);

      //apply according active wifi mode
      if (wifi_get_opmode()==WIFI_STA || wifi_get_opmode()==WIFI_AP_STA) {
        WiFi.config(staticIP, staticGateway, staticSubnet);
      }
  }
  //Get IP
  IPAddress espIP;
  if (wifi_get_opmode()==WIFI_STA || wifi_get_opmode()==WIFI_AP_STA) {
      espIP=WiFi.localIP();
  } else {
      espIP=WiFi.softAPIP();
  }
  ipString = GetIpString(espIP);

  return true;
}


void  WiFiSafeSetup()
{
  WiFi.disconnect();
  //setup Soft AP
  WiFi.mode(WIFI_AP);
  WiFi.softAP(JConf.module_id, JConf.ap_pwd);
  delay(500);
  Serial.println(F("Safe mode started"));
  wifiSafeMode = true;
}


void GetLightSensorData()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetLightSensorData() Start"));
  #endif

  luxString = String(lightSensor.readLightLevel());

  #ifdef DEBUG
    Serial.print(F("Lux:   "));  Serial.print(luxString);  Serial.println();
  #endif

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetLightSensorData() Load Time: ")); Serial.println(load_time);
  #endif
}



#ifdef BME280_ON
void GetBmeSensorData()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetBmeSensorData() Start"));
  #endif

  temperatureString = String(bmeSensor.readTempC());
  #ifdef DEBUG
    Serial.print(F("Temperature: "));  Serial.print(temperatureString);  Serial.println(F(" C"));
  #endif

  pressureString = String(bmeSensor.readFloatPressure()/133.3F);
  #ifdef DEBUG
    Serial.print(F("Pressure: "));  Serial.print(pressureString);  Serial.println(F(" mm"));
  #endif

  humidityString = String(bmeSensor.readFloatHumidity());
  #ifdef DEBUG
    Serial.print(F("%RH: "));  Serial.print(humidityString);  Serial.println(F(" %"));
  #endif

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetBmeSensorData() Load Time: ")); Serial.println(load_time);
  #endif
}
#endif



#ifdef SHT21_ON
void GetSHT21SensorData(){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetSHT21SensorData() Start"));
  #endif

  myHTU21D.setResolution(HTU21D_RES_RH8_TEMP12);
  temperatureString = String(myHTU21D.readTemperature());
  humidityString = String(myHTU21D.readCompensatedHumidity());

  #ifdef DEBUG
    Serial.println(F(""));  Serial.println(F(""));  Serial.println(F("<<%RH: 8Bit, Temperature - 12Bit>>"));

    Serial.println(F(""));  Serial.print(F("Humidity: "));  Serial.println(myHTU21D.readHumidity());

    Serial.println(F(""));  Serial.print(F("Compensated Humidity: "));   Serial.println(humidityString);

    Serial.println(F(""));  Serial.print(F("Temperature: "));  Serial.print(temperatureString);  Serial.println(F(" C"));

    Serial.println(F(""));  Serial.println(F(""));  Serial.println(F("<<Battery Status>>"));

    if (myHTU21D.batteryStatus() == true)
    {
      Serial.println(F("Battery OK. Level > 2.25v"));
    }
    else
    {
      Serial.println(F("Battery LOW. Level < 2.25v"));
    }
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetSHT21SensorData() Load Time: ")); Serial.println(load_time);
  #endif
}
#endif



#ifdef DHT_ON
void DHT22Sensor()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("DHT22Sensor() Start"));
  #endif

  float temperatureData = dht.readTemperature();
  float humidityData = dht.readHumidity();
  #ifdef DEBUG
    Serial.print(F("Humidity "));  Serial.println(humidityData);
    Serial.print(F("Temperature "));  Serial.println(temperatureData);
  #endif
  if (isnan(humidityData) || isnan(temperatureData)) {
    errorDHTdata++;
    #ifdef DEBUG
      Serial.print(F("Failed to read from DHT. Number errors: "));  Serial.println(errorDHTdata);
    #endif
  } else {
    temperatureString = String(temperatureData);
    humidityString = String(humidityData);
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("DHT22Sensor() Load Time: ")); Serial.println(load_time);
  #endif
}
#endif



void MotionDetect(){

  #ifdef DEBUG11
    unsigned long start_time = millis();
    Serial.println(F("MotionDetect() Start"));
  #endif

  if (digitalRead(atoi(JConf.motion_pin)) == HIGH) {
    #ifdef DEBUG
      Serial.println(F("MotionSensor moove detected"));
    #endif
    motionDetect = true;
    LightControl();
    if (atoi(JConf.mqtt_enable) == 1) {
      if (mqttClient.connected()) {
        sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  motionSensor, JConf.mqtt_name);
        mqttClient.publish(topic_buff, "ON");
      }
    }
  }

  #ifdef DEBUG11
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MotionDetect() Load Time: ")); Serial.println(load_time);
  #endif
}



String GetUptimeData(){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("GetUptimeData() Start"));
  #endif

  //** Making Note of an expected rollover *****//
  if(millis()>=3000000000){
    HighMillis=1;
  }
  //** Making note of actual rollover **//
  if(millis()<=100000&&HighMillis==1){
    Rollover++;
    HighMillis=0;
  }

  long secsUp = millis()/1000;

  Second = secsUp%60;
  Minute = (secsUp/60)%60;
  Hour = (secsUp/(60*60))%24;
  Day = (Rollover*50)+(secsUp/(60*60*24));  //First portion takes care of a rollover [around 50 days]

  sprintf_P(value_buff, (const char *)F("%dd %02d:%02d"), Day, Hour, Minute);
  uptimeString = String(value_buff);
  #ifdef DEBUG
    Serial.print(F("Uptime: "));  Serial.print(value_buff);  Serial.print(F(":"));  Serial.print(Second/10);  Serial.println(Second%10);
    unsigned long load_time = millis() - start_time;
    Serial.print(F("GetUptimeData() Load Time: ")); Serial.println(load_time);
  #endif

  return value_buff;
}



void RebootESP()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("RebootESP() Start"));
  #endif

  if (millis() - rebootTimer >= atoi(JConf.reboot_delay) * 1000){
  ESP.restart();
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("RebootESP() Load Time: ")); Serial.println(load_time);
  #endif
}



// handles message arrived on subscribed topic(s)
void callback(char* topic, byte* payload, unsigned int length) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("callback() Start"));
  #endif

  subscribeTimer = millis();
  rebootTimer = millis();

  size_t i=0;
  // create character buffer with ending null terminator (string)
  for(i=0; i<length; i++) {
    value_buff[i] = payload[i];
  }
  value_buff[i] = '';

  #ifdef DEBUG
  Serial.print(F("callback: "));  Serial.print(topic);  Serial.print(F(" payload "));  Serial.println(value_buff);
  #endif

  // Обрабатываем данные о состоянии светодиодной ленты (AUTO, ON, OFF)
  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, lightType, JConf.mqtt_name);
  if (strcmp (topic,topic_buff) == 0){

    String AUTO;       AUTO += FPSTR(AUTOP);
    String ON;         ON += FPSTR(ONP);
    String OFF;        OFF += FPSTR(OFFP);

    #ifdef DEBUG
      Serial.print(F("topic: "));  Serial.print(topic);  Serial.print(F(" equals "));  Serial.println(topic_buff);
    #endif
    if (strncmp (value_buff,"1",1) == 0){
      lightState = ON;
    } else if (strncmp (value_buff,"0",1) == 0){
      lightState = OFF;
    } else if (strncmp (value_buff,"2",1) == 0){
      lightState = AUTO;
    }

    #ifdef DEBUG
      Serial.print(F("value_buff: "));  Serial.print(value_buff);  Serial.print(F(" contains "));   Serial.print(lightState);
    #endif

    LightControl();
  }


  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, motionsensortimer, JConf.mqtt_name);
    if (strcmp (topic,topic_buff) == 0){
      #ifdef DEBUG
        Serial.print(F("topic: "));  Serial.print(topic);  Serial.print(F(" equals "));  Serial.println(topic_buff);
      #endif
      sprintf_P(JConf.lightoff_delay, (const char *)F("%s"), value_buff);
      JConf.saveConfig();
    }

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, motionsensortimer2, JConf.mqtt_name);
    if (strcmp (topic,topic_buff) == 0){
      #ifdef DEBUG
        Serial.print(F("topic: "));  Serial.print(topic);  Serial.print(F(" equals "));  Serial.println(topic_buff);
      #endif
      sprintf_P(JConf.light2off_delay, (const char *)F("%s"), value_buff);
      JConf.saveConfig();
    }


  #ifdef DEBUG
    Serial.print(F("topic: "));  Serial.println(topic);  Serial.print(F("value_buff: "));  Serial.println(value_buff);
    Serial.println();
  #endif

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("callback() Load Time: ")); Serial.println(load_time);
  #endif
}



bool MqttPubLightState(){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("MqttPubLightState() Start"));
  #endif

  if (!mqttClient.connected()){
    #ifdef DEBUG
      Serial.print(F("MQTT server not connected"));  Serial.println();
      unsigned long load_time = millis() - start_time;
      Serial.print(F("MqttPubLightState() Load Time: ")); Serial.println(load_time);
    #endif
    return false;
  }

  String ON;         ON += FPSTR(ONP);
  String OFF;        OFF += FPSTR(OFFP);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  lightType, JConf.mqtt_name);
  String lightStateNum;
  if (lightState == ON){
    lightStateNum = String(F("1"));
  } else if (lightState == OFF){
    lightStateNum = String(F("0"));
  } else {
    lightStateNum = String(F("2"));
  }
  mqttClient.publish(topic_buff, lightStateNum.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  lightType2, JConf.mqtt_name);
  if (lightState2 == ON){
    lightStateNum = String(F("1"));
  } else if (lightState2 == OFF){
    lightStateNum = String(F("0"));
  } else {
    lightStateNum = String(F("2"));
  }
  mqttClient.publish(topic_buff, lightStateNum.c_str());

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MqttPubLightState() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



bool MqttPubLightOffDelay() {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("MqttPubLightOffDelay() Start"));
  #endif


  if (!mqttClient.connected()){
    #ifdef DEBUG
      Serial.print(F("MQTT server not connected"));  Serial.println();
      unsigned long load_time = millis() - start_time;
      Serial.print(F("MqttPubLightOffDelay() Load Time: ")); Serial.println(load_time);
    #endif

    return false;
  }

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  motionsensortimer, JConf.mqtt_name);
  mqttClient.publish(topic_buff, JConf.lightoff_delay);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  motionsensortimer2, JConf.mqtt_name);
  mqttClient.publish(topic_buff, JConf.light2off_delay);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MqttPubLightOffDelay() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



bool MqttPubData() {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("MqttPubData() Start"));
  #endif

  if (mqttClient.state() != 0){
    #ifdef DEBUG
      Serial.print(F("MQTT server not connected"));  Serial.println();
      unsigned long load_time = millis() - start_time;
      Serial.print(F("MqttPubData() Load Time: ")); Serial.println(load_time);
    #endif
    return false;
  }

  Serial.print(F("MQTT data send"));  Serial.println();

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  lux, JConf.mqtt_name);
  mqttClient.publish(topic_buff, luxString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic, temperature, JConf.mqtt_name);
  mqttClient.publish(topic_buff, temperatureString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic, pressure, JConf.mqtt_name);
  mqttClient.publish(topic_buff, pressureString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  humidity, JConf.mqtt_name);
  mqttClient.publish(topic_buff, humidityString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  freeMemory, JConf.mqtt_name);
  mqttClient.publish(topic_buff, freeMemoryString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic, uptime, JConf.mqtt_name);
  mqttClient.publish(topic_buff, uptimeString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  version, JConf.mqtt_name);
  mqttClient.publish(topic_buff, ver);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  ip, JConf.mqtt_name);
  mqttClient.publish(topic_buff, ipString.c_str());

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  mac, JConf.mqtt_name);
  mqttClient.publish(topic_buff, macString.c_str());


  #ifdef DHT_ON
    sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.publish_topic,  errorsDHT, JConf.mqtt_name);
    sprintf_P(value_buff, (const char *)F("%d"), errorDHTdata);
    mqttClient.publish(topic_buff, value_buff);
  #endif

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MqttPubData() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



bool MqttSubscribePrint(char *sub_buff)
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("MqttSubscribePrint() Start"));
  #endif

  delay(50);
  if (!mqttClient.connected()){
    #ifdef DEBUG
      Serial.print(F("MQTT server not connected"));  Serial.println();
    #endif
    return false;
  }

  if (mqttClient.subscribe(sub_buff)) {
    #ifdef DEBUG
      Serial.print(F("subscribe: "));  Serial.println(sub_buff);
    #endif
  } else {
    #ifdef DEBUG
      mqttClient.disconnect();
      Serial.print(F("ERROR subscribe: "));  Serial.println(sub_buff);
    #endif
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MqttSubscribePrint() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



bool MqttSubscribe(){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("MqttSubscribe() Start"));
  #endif

  if (!mqttClient.connected()){
    #ifdef DEBUG
      Serial.print(F("MQTT server not connected"));  Serial.println();
    #endif
    return false;
  }

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, motionsensortimer, JConf.mqtt_name);
  MqttSubscribePrint(topic_buff);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, lightType, JConf.mqtt_name);
  MqttSubscribePrint(topic_buff);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.command_pub_topic, lightType2, JConf.mqtt_name);
  MqttSubscribePrint(topic_buff);

  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.subscribe_topic, uptime, JConf.mqtt_name);
  MqttSubscribePrint(topic_buff);
/*
  sprintf_P(topic_buff, (const char *)F("%s%s%s"), JConf.subscribe_topic, version, JConf.mqtt_name);
  MqttSubscribePrint(topic_buff);
*/

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("MqttSubscribe() Load Time: ")); Serial.println(load_time);
  #endif

  return true;
}



void TestMQTTPrint()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("TestMQTTPrint() Start"));
  #endif

  int state = mqttClient.state();

  switch (state) {
    case -4:
      Serial.println(F("MQTT_CONNECTION_TIMEOUT - the server didn't respond within the keepalive time"));
      break;
    case -3:
      Serial.println(F("MQTT_CONNECTION_LOST - the network connection was broken"));
      break;
    case -2:
      Serial.println(F("MQTT_CONNECT_FAILED - the network connection failed"));
      break;
    case -1:
      Serial.println(F("MQTT_DISCONNECTED - the client is disconnected cleanly"));
      break;
    case 0:
      Serial.println(F("MQTT_CONNECTED - the cient is connected"));
      break;
    case 1:
      Serial.println(F("MQTT_CONNECT_BAD_PROTOCOL - the server doesn't support the requested version of MQTT"));
      break;
    case 2:
      Serial.println(F("MQTT_CONNECT_BAD_CLIENT_ID - the server rejected the client identifier"));
      break;
    case 3:
      Serial.println(F("MQTT_CONNECT_UNAVAILABLE - the server was unable to accept the connection"));
      break;
    case 4:
      Serial.println(F("MQTT_CONNECT_BAD_CREDENTIALS - the username/password were rejected"));
      break;
    case 5:
      Serial.println(F("MQTT_CONNECT_UNAUTHORIZED - the client was not authorized to connect"));
      break;
  }

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("TestMQTTPrint() Load Time: ")); Serial.println(load_time);
  #endif
}



void TestSystemPrint()
{
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("TestSystemPrint() Start"));
  #endif

  Serial.println(F("----------------"));

  if (atoi(JConf.mqtt_enable) == 1){
    TestMQTTPrint();
  }

  Serial.println(__TIMESTAMP__);

  Serial.print(F("Version "));  Serial.println(ver);

  Serial.print(F("IP address: "));  Serial.println(ipString);

  Serial.print(F("Sketch size: "));  Serial.println(ESP.getSketchSize());

  Serial.print(F("Free size: "));  Serial.println(ESP.getFreeSketchSpace());

  Serial.print(F("Free memory: "));  Serial.println(freeMemoryString);

  Serial.print(F("WiFi status: "));  Serial.println(WiFi.status());

  Serial.print(F("Chip Id: "));  Serial.println(ESP.getChipId());

  Serial.print(F("Flash Chip Id: "));  Serial.println(ESP.getFlashChipId());

  Serial.print(F("Flash Chip Size: ")); Serial.println(ESP.getFlashChipSize());

  Serial.print(F("Flash Chip Speed: "));  Serial.println(ESP.getFlashChipSpeed());

  Serial.println(F("----------------"));

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("TestSystemPrint() Load Time: ")); Serial.println(load_time);
  #endif
}




//////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////   WEB PAGES  Start  //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////



void WebRoot(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebRoot() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String javaScript;            javaScript += FPSTR(javaScriptP);
  String jsTemperature;         jsTemperature += FPSTR(jsTemperatureP);
  String jsHumidity;            jsHumidity += FPSTR(jsHumidityP);
  String jsPressure;            jsPressure += FPSTR(jsPressureP);
  String jsIlluminance;         jsIlluminance += FPSTR(jsIlluminanceP);
  String jsNtp;                 jsNtp += FPSTR(jsNtpP);
  String javaScriptEnd;         javaScriptEnd += FPSTR(javaScriptEndP);
  String bodyAjax;              bodyAjax += FPSTR(bodyAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarActive;          navbarActive += FPSTR(navbarActiveP);

  navbarActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);
  String panelEnd;              panelEnd += FPSTR(panelEndP);
  String panelBodySymbol;       panelBodySymbol += FPSTR(panelBodySymbolP);
  String panelBodyName;         panelBodyName += FPSTR(panelBodyNameP);
  String panelBodyValue;        panelBodyValue += FPSTR(panelBodyValueP);
  String closingAngleBracket; closingAngleBracket += FPSTR(closingAngleBracketP);
  String panelBodyEnd;          panelBodyEnd += FPSTR(panelBodyEndP);

  String title1       = panelHeaderName + String(F("Sensor Data"))   + panelHeaderEnd;

  if (atoi(JConf.bme280_enable) == 1 || atoi(JConf.sht21_enable) == 1){
    title1           += panelBodySymbol + String(F("fire"))          + panelBodyName + String(F("Temperature")) + panelBodyValue + String(F(" id='temperatureId'")) + closingAngleBracket   + panelBodyEnd;
    title1           += panelBodySymbol + String(F("tint"))          + panelBodyName + String(F("Humidity"))    + panelBodyValue + String(F(" id='humidityId'")) + closingAngleBracket      + panelBodyEnd;
  }

  #ifdef BME280_ON
    if (atoi(JConf.bme280_enable) == 1){
      title1         += panelBodySymbol + String(F("cloud"))         + panelBodyName + String(F("Pressure"))    + panelBodyValue + String(F(" id='pressureId'")) + closingAngleBracket      + panelBodyEnd;
    }
  #endif

  if (atoi(JConf.bh1750_enable) == 1){
    title1           += panelBodySymbol + String(F("asterisk"))      + panelBodyName + String(F("illuminance")) + panelBodyValue + String(F(" id='illuminanceId'")) + closingAngleBracket   + panelBodyEnd;
  }

  String title2       = panelHeaderName + String(F("Settings"))      + panelHeaderEnd;
  //title2             += panelBodySymbol + String(F("signal"))        + panelBodyName + String(F("Wi-Fi SSID"))  + panelBodyValue + closingAngleBracket + JConf.sta_ssid    + panelBodyEnd;
  title2             += panelBodySymbol + String(F("globe"))         + panelBodyName + String(F("IP Address"))  + panelBodyValue + closingAngleBracket + ipString          + panelBodyEnd;
  //title2             += panelBodySymbol + String(F("scale"))         + panelBodyName + String(F("MAC Address")) + panelBodyValue + closingAngleBracket + macString         + panelBodyEnd;
  //title2             += panelBodySymbol + String(F("tag"))           + panelBodyName + String(F("MQTT Prefix")) + panelBodyValue + closingAngleBracket + JConf.mqtt_name   + panelBodyEnd;

  title2             += panelBodySymbol + String(F("time"))          + panelBodyName + String(F("Uptime"))      + panelBodyValue + String(F(" id='uptimeId'"))     + closingAngleBracket  + panelBodyEnd;

  if (atoi(JConf.ntp_enable) == 1) {
    title2           += panelBodySymbol + String(F("time"))          + panelBodyName + String(F("NTP time"))    + panelBodyValue + String(F(" id='ntpTimeId'"))    + closingAngleBracket  + panelBodyEnd;
  }

  title2             += panelBodySymbol + String(F("flash"))         + panelBodyName + String(F("Voltage"))     + panelBodyValue + String(F(" id='vccId'"))        + closingAngleBracket  + panelBodyEnd;
  title2             += panelBodySymbol + String(F("flash"))         + panelBodyName + String(F("Free Memory")) + panelBodyValue + String(F(" id='freeMemoryId'")) + closingAngleBracket  + panelBodyEnd;
  //title2             += panelBodySymbol + String(F("flag"))          + panelBodyName + String(F("Version"))     + panelBodyValue + closingAngleBracket + String(ver)                      + panelBodyEnd;

  String data = headerStart + JConf.module_id + headerStart2 + headerEnd + javaScript;

  if (atoi(JConf.bme280_enable) == 1 || atoi(JConf.sht21_enable) == 1) {
    data += jsTemperature + jsHumidity;
  }
  if (atoi(JConf.bme280_enable) == 1) {
    data += jsPressure;
  }
  if (atoi(JConf.bh1750_enable) == 1) {
    data += jsIlluminance;
  }
  if (atoi(JConf.ntp_enable) == 1) {
    data += jsNtp;
  }
  data += javaScriptEnd + bodyAjax + navbarStart + JConf.module_id + navbarStart2 +navbarActive + navbarEnd + containerStart + title1 + panelEnd + title2 + panelEnd +  containerEnd + siteEnd;

  WebServer.send ( 200, "text/html", data);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebRoot() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebReboot(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebReboot() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerRefreshStatus;   headerRefreshStatus += FPSTR(headerRefreshStatusP);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);

  String data = String(F("<div class='col-sm-6 col-md-5 col-lg-4'><div class='page-header'><h2>Reboot ESP</h2></div><div class='alert alert-info' role='alert'><a href='#' class='alert-link'>Rebooting...</a></div></div>"));
  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerRefreshStatus + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebReboot() Load Time: ")); Serial.println(load_time);
  #endif

  ESP.restart();
}



void WebUpdate(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebUpdate() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String sketchUploadForm;      sketchUploadForm += FPSTR(sketchUploadFormP);

  WebServer.send(200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + sketchUploadForm + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebUpdate() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebFileUpload(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebFileUpload() Start"));
  #endif

  if (WebServer.uri() != "/upload_sketch") return;
  HTTPUpload& upload = WebServer.upload();
  if (upload.status == UPLOAD_FILE_START) {
    Serial.setDebugOutput(true);
    WiFiUDP::stopAll();
    #ifdef DEBUG
    Serial.printf("Sketch: %sn", upload.filename.c_str());
    #endif
    uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
    if (!Update.begin(maxSketchSpace)) { //start with max available size
      Update.printError(Serial);
    }
  } else if (upload.status == UPLOAD_FILE_WRITE) {
    if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
      Update.printError(Serial);
    }
  } else if (upload.status == UPLOAD_FILE_END) {
    if (Update.end(true)) { //true to set the size to the current progress
      #ifdef DEBUG
      Serial.printf("Update Success: %unRebooting...n", upload.totalSize);
      #endif
    } else {
      Update.printError(Serial);
    }
    Serial.setDebugOutput(false);
  }
  yield();

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebFileUpload() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebUploadSketch(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebUploadSketch() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerRefreshStatus;   headerRefreshStatus += FPSTR(headerRefreshStatusP);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);

  String varDataString = String(F("<div class='col-sm-6 col-md-5 col-lg-4'><div class='page-header'><h2>Update Frimware</h2></div><div class='alert alert-success'>")) + ((Update.hasError()) ? String(F("FAIL")) : String(F("Update Frimware: OK"))) + String(F("</div></div>"));


  WebServer.send(200, "text/html", headerStart + JConf.module_id + headerStart2 + headerRefreshStatus + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + varDataString + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebUploadSketch() Load Time: ")); Serial.println(load_time);
  #endif

  ESP.restart();
}



void WebWiFiConf(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebWiFiConf() Start"));
  #endif


  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);
  String panelEnd;              panelEnd += FPSTR(panelEndP);
  String panelBodySymbol;       panelBodySymbol += FPSTR(panelBodySymbolP);
  String panelBodyName;         panelBodyName += FPSTR(panelBodyNameP);
  String panelBodyValue;        panelBodyValue += FPSTR(panelBodyValueP);
  String panelBodyEnd;          panelBodyEnd += FPSTR(panelBodyEndP);
  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);


  bool config_changed = false;
  bool enable = false;
  String payload = "";

  payload=WebServer.arg("module_id");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.module_id, sizeof(JConf.module_id));
    config_changed = true;
  }

  payload=WebServer.arg("wifi_mode");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.wifi_mode, sizeof(JConf.wifi_mode));
    config_changed = true;
  }

  payload=WebServer.arg("wifi_phy_mode");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.wifi_phy_mode, sizeof(JConf.wifi_phy_mode));
    config_changed = true;
  }
  payload=WebServer.arg("wifi_channel");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.wifi_channel, sizeof(JConf.wifi_channel));
    config_changed = true;
  }
  payload=WebServer.arg("wifi_auth");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.wifi_auth, sizeof(JConf.wifi_auth));
    config_changed = true;
  }

  payload=WebServer.arg("sta_ssid");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.sta_ssid, sizeof(JConf.sta_ssid));
    config_changed = true;
  }

  payload=WebServer.arg("sta_pwd");
  if (payload.length() > 7 &&  payload != String(F("********"))) {
    payload.toCharArray(JConf.sta_pwd, sizeof(JConf.sta_pwd));
    config_changed = true;
  }

  payload=WebServer.arg("ap_pwd");
  if (payload.length() > 7 &&  payload != String(F("********"))) {
    payload.toCharArray(JConf.ap_pwd, sizeof(JConf.ap_pwd));
    config_changed = true;
  }

  payload=WebServer.arg("static_ip_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.static_ip_enable, sizeof(JConf.static_ip_enable));
    config_changed = true;
    enable = true;
  }

  payload=WebServer.arg("static_ip");
  if (payload.length() > 6 ) {
    payload.toCharArray(JConf.static_ip, sizeof(JConf.static_ip));
    config_changed = true;
  }

  payload=WebServer.arg("static_gateway");
  if (payload.length() > 6 ) {
    payload.toCharArray(JConf.static_gateway, sizeof(JConf.static_gateway));
    config_changed = true;
  }

  payload=WebServer.arg("static_subnet");
  if (payload.length() > 6 ) {
    payload.toCharArray(JConf.static_subnet, sizeof(JConf.static_subnet));
    config_changed = true;
  }

  if (config_changed){
    if (!enable){
      JConf.static_ip_enable[0] = '0';
      JConf.static_ip_enable[1] = '';
    }
    JConf.saveConfig();
  }

  String data = panelHeaderName + String(F("Wi-Fi Configuration")) + panelHeaderEnd;
  data += inputBodyStart;


  data += inputBodyName + String(F("Module ID")) + inputBodyPOST + String(F("module_id"))  + inputPlaceHolder + JConf.module_id + inputBodyClose + inputBodyCloseDiv;

  data += String(F("<div class='form-group'><div class='input-group'><span class='input-group-addon'>AP type</span>"));
  if (atoi(JConf.wifi_mode) == STA){
    data += String(F("<select class='form-control' name='wifi_mode'><option value='0'>AP</option><option value='1' selected>STA</option><option value='2'>AP_STA</option></select></div></div>"));
  } else if (atoi(JConf.wifi_mode) == AP_STA){
    data += String(F("<select class='form-control' name='wifi_mode'><option value='0'>AP</option><option value='1'>STA</option><option value='2' selected>AP_STA</option></select></div></div>"));
  } else {
    data += String(F("<select class='form-control' name='wifi_mode'><option value='0' selected>AP</option><option value='1'>STA</option><option value='2'>AP_STA</option></select></div></div>"));
  }

  if ( atoi(JConf.wifi_mode) != STA){
    data += String(F("<div class='form-group'><div class='input-group'><span class='input-group-addon'>AP mode</span>"));
    if (atoi(JConf.wifi_phy_mode) == G){
      data += String(F("<select class='form-control' name='wifi_phy_mode'><option value='0'>11B</option><option value='1' selected>11G</option><option value='2'>11N</option></select></div></div>"));
    } else if (atoi(JConf.wifi_phy_mode) == N){
      data += String(F("<select class='form-control' name='wifi_phy_mode'><option value='0'>11B</option><option value='1'>11G</option><option value='2' selected>11N</option></select></div></div>"));
    } else {
      data += String(F("<select class='form-control' name='wifi_phy_mode'><option value='0' selected>11B</option><option value='1'>11G</option><option value='2'>11N</option></select></div></div>"));
    }

    data += inputBodyName + String(F("AP Channel")) + inputBodyPOST + String(F("wifi_channel"))  + inputPlaceHolder + JConf.wifi_channel + inputBodyClose + inputBodyCloseDiv;

    data += String(F("<div class='form-group'><div class='input-group'><span class='input-group-addon'>AP auth</span>"));
    if (atoi(JConf.wifi_auth) == WPA_PSK){
      data += String(F("<select class='form-control' name='wifi_auth'><option value='0'>OPEN</option><option value='1' selected>WPA_PSK</option><option value='2'>WPA2_PSK</option><option value='3'>WPA_WPA2_PSK</option></select></div></div>"));
    } else if (atoi(JConf.wifi_auth) == WPA2_PSK){
      data += String(F("<select class='form-control' name='wifi_auth'><option value='0'>OPEN</option><option value='1'>WPA_PSK</option><option value='2' selected>WPA2_PSK</option><option value='3'>WPA_WPA2_PSK</option></select></div></div>"));
    } else if (atoi(JConf.wifi_auth) == WPA_WPA2_PSK){
      data += String(F("<select class='form-control' name='wifi_auth'><option value='0'>OPEN</option><option value='1'>WPA_PSK</option><option value='2'>WPA2_PSK</option><option value='3' selected>WPA_WPA2_PSK</option></select></div></div>"));
    } else {
      data += String(F("<select class='form-control' name='wifi_auth'><option value='0' selected>OPEN</option><option value='1'>WPA_PSK</option><option value='2'>WPA2_PSK</option><option value='3'>WPA_WPA2_PSK</option></select></div></div>"));
    }

    if (atoi(JConf.wifi_auth) != OPEN){
      data += inputBodyName + String(F("AP Password")) + String(F("</span><input type='password' name='")) + String(F("ap_pwd")) + inputPlaceHolder + String(F("********")) + inputBodyClose + inputBodyCloseDiv;
    }
  }

  if ( atoi(JConf.wifi_mode) != AP){
    data += inputBodyName + String(F("STA SSID")) + inputBodyPOST + String(F("sta_ssid"))  + inputPlaceHolder + JConf.sta_ssid + inputBodyClose + inputBodyCloseDiv;
    data += inputBodyName + String(F("STA Password")) + String(F("</span><input type='password' name='")) + String(F("sta_pwd")) + inputPlaceHolder + String(F("********")) + inputBodyClose + inputBodyCloseDiv;

    if (atoi(JConf.static_ip_enable) == 1){
      data += String(F("<div class='checkbox'><label><input type='checkbox' name='static_ip_enable' value='1' checked='true'>Static IP Mode</label></div>"));
      data += inputBodyName + String(F("Static IP"))      + inputBodyPOST + String(F("static_ip"))      + inputPlaceHolder + JConf.static_ip      + inputBodyClose + inputBodyCloseDiv;
      data += inputBodyName + String(F("Static Gateway")) + inputBodyPOST + String(F("static_gateway")) + inputPlaceHolder + JConf.static_gateway + inputBodyClose + inputBodyCloseDiv;
      data += inputBodyName + String(F("Static Subnet"))  + inputBodyPOST + String(F("static_subnet"))  + inputPlaceHolder + JConf.static_subnet  + inputBodyClose + inputBodyCloseDiv;
    } else {
      data += String(F("<div class='checkbox'><label><input type='checkbox' name='static_ip_enable' value='1'>Static IP Mode</label></div>"));
    }
  }

  data += inputBodyEnd;
  data += String(F("</div>"));

  data += panelHeaderName + String(F("Scan AP")) + panelHeaderEnd;
  data += network_html;

  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebWiFiConf() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebSensorsConf(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebSensorsConf() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);

  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);

  String data;
  data += panelHeaderName;
  data += String(F("Sensors Configuration"));
  data += panelHeaderEnd;
  data += inputBodyStart;

  bool config_changed = false;

  bool bme280_enable = false;
  bool sht21_enable = false;
  bool bh1750_enable = false;
  bool motion_sensor_enable = false;

  String payload = "";

  payload=WebServer.arg("save_conf");
  if (payload.length() > 0) {
    config_changed = true;
  }

  payload=WebServer.arg("bme280_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.bme280_enable, sizeof(JConf.bme280_enable));
    bme280_enable = true;
  }

  payload=WebServer.arg("sht21_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.sht21_enable, sizeof(JConf.sht21_enable));
    sht21_enable = true;
  }

  payload=WebServer.arg("bh1750_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.bh1750_enable, sizeof(JConf.bh1750_enable));
    bh1750_enable = true;
  }

  payload=WebServer.arg("motion_sensor_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.motion_sensor_enable, sizeof(JConf.motion_sensor_enable));
    motion_sensor_enable = true;
  }

  if (config_changed){
    if (!bme280_enable){
      JConf.bme280_enable[0] = '0';
      JConf.bme280_enable[1] = '';
    }
    if (!sht21_enable){
      JConf.sht21_enable[0] = '0';
      JConf.sht21_enable[1] = '';
    }
    if (!bh1750_enable){
      JConf.bh1750_enable[0] = '0';
      JConf.bh1750_enable[1] = '';
    }
    if (!motion_sensor_enable){
      JConf.motion_sensor_enable[0] = '0';
      JConf.motion_sensor_enable[1] = '';
    }
    JConf.saveConfig();
  }

  if (atoi(JConf.bme280_enable) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='bme280_enable' value='1' checked='true'>BME280 Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='bme280_enable' value='1'>BME280 Enable</label></div>"));
  }

  if (atoi(JConf.sht21_enable) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='sht21_enable' value='1' checked='true'>SHT21 Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='sht21_enable' value='1'>SHT21 Enable</label></div>"));
  }

  if (atoi(JConf.bh1750_enable) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='bh1750_enable' value='1' checked='true'>BH1750 Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='bh1750_enable' value='1'>BH1750 Enable</label></div>"));
  }

  if (atoi(JConf.motion_sensor_enable) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='motion_sensor_enable' value='1' checked='true'>Motion Sensor Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='motion_sensor_enable' value='1'>Motion Sensor Enable</label></div>"));
  }

  data += inputBodyEnd;

  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebSensorsConf() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebEspConf(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebEspConf() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);
  String panelEnd;              panelEnd += FPSTR(panelEndP);
  String panelBodySymbol;       panelBodySymbol += FPSTR(panelBodySymbolP);
  String panelBodyName;         panelBodyName += FPSTR(panelBodyNameP);
  String panelBodyValue;        panelBodyValue += FPSTR(panelBodyValueP);
  String panelBodyEnd;          panelBodyEnd += FPSTR(panelBodyEndP);
  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);


  bool config_changed = false;
  bool enable_light_smooth = false;
  bool enable_light2_smooth = false;
  String payload = "";


  payload=WebServer.arg("light_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light_pin, sizeof(JConf.light_pin));
    config_changed = true;
  }

  payload=WebServer.arg("lightoff_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.lightoff_delay, sizeof(JConf.lightoff_delay));
    if (atoi(JConf.mqtt_enable) == 1){
      MqttPubLightOffDelay();
    }
    config_changed = true;
  }

  payload=WebServer.arg("lighton_lux");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.lighton_lux, sizeof(JConf.lighton_lux));
    config_changed = true;
  }

  payload=WebServer.arg("light_smooth");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light_smooth, sizeof(JConf.light_smooth));
    config_changed = true;
    enable_light_smooth = true;
  }

  payload=WebServer.arg("light2_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light2_pin, sizeof(JConf.light2_pin));
    config_changed = true;
  }

  payload=WebServer.arg("light2off_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light2off_delay, sizeof(JConf.light2off_delay));
    if (atoi(JConf.mqtt_enable) == 1){
      MqttPubLightOffDelay();
    }
    config_changed = true;
  }

  payload=WebServer.arg("light2on_lux");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light2on_lux, sizeof(JConf.light2on_lux));
    config_changed = true;
  }

  payload=WebServer.arg("light2_smooth");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.light2_smooth, sizeof(JConf.light2_smooth));
    config_changed = true;
    enable_light2_smooth = true;
  }

  payload=WebServer.arg("motion_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.motion_pin, sizeof(JConf.motion_pin));
    config_changed = true;
  }

  payload=WebServer.arg("dht_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.dht_pin, sizeof(JConf.dht_pin));
    config_changed = true;
  }

  payload=WebServer.arg("get_data_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.get_data_delay, sizeof(JConf.get_data_delay));
    config_changed = true;
  }

  payload=WebServer.arg("motion_read_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.motion_read_delay, sizeof(JConf.motion_read_delay));
    config_changed = true;
  }

  payload=WebServer.arg("reboot_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.reboot_delay, sizeof(JConf.reboot_delay));
    config_changed = true;
  }


  if (config_changed){
    if (!enable_light_smooth){
      JConf.light_smooth[0] = '0';
      JConf.light_smooth[1] = '';
    }
    if (!enable_light2_smooth){
      JConf.light2_smooth[0] = '0';
      JConf.light2_smooth[1] = '';
    }
    JConf.saveConfig();
  }


  String data = panelHeaderName + String(F("ESP Configuration")) + panelHeaderEnd;
  data += inputBodyStart;


  data += String(F("<h4>Light 1</h4>"));
  data += inputBodyName + String(F("Pin")) + inputBodyPOST + String(F("light_pin")) + inputPlaceHolder + JConf.light_pin + inputBodyClose + inputBodyCloseDiv;
  data += inputBodyName + String(F("Off Delay")) + inputBodyPOST + String(F("lightoff_delay")) + inputPlaceHolder + JConf.lightoff_delay + inputBodyClose + inputBodyUnitStart + String(F("min")) + inputBodyUnitEnd + inputBodyCloseDiv;
  data += inputBodyName + String(F("On Lux")) + inputBodyPOST + String(F("lighton_lux")) + inputPlaceHolder + JConf.lighton_lux + inputBodyClose + inputBodyUnitStart + String(F("Lux")) + inputBodyUnitEnd + inputBodyCloseDiv;

  if (atoi(JConf.light_smooth) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='light_smooth' value='1' checked='true'>Smooth Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='light_smooth' value='1'>Smooth Enable</label></div>"));
  }
  data += String(F("<hr>"));

  data += String(F("<h4>Light 2</h4>"));
  data += inputBodyName + String(F("Pin")) + inputBodyPOST + String(F("light2_pin")) + inputPlaceHolder + JConf.light2_pin + inputBodyClose + inputBodyCloseDiv;
  data += inputBodyName + String(F("Off Delay")) + inputBodyPOST + String(F("light2off_delay")) + inputPlaceHolder + JConf.light2off_delay + inputBodyClose + inputBodyUnitStart + String(F("min")) + inputBodyUnitEnd + inputBodyCloseDiv;
  data += inputBodyName + String(F("On Lux")) + inputBodyPOST + String(F("light2on_lux")) + inputPlaceHolder + JConf.light2on_lux + inputBodyClose + inputBodyUnitStart + String(F("Lux")) + inputBodyUnitEnd + inputBodyCloseDiv;

  if (atoi(JConf.light2_smooth) == 1){
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='light2_smooth' value='1' checked='true'>Smooth Enable</label></div>"));
  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='light2_smooth' value='1'>Smooth Enable</label></div>"));
  }
  data += String(F("<hr>"));

  data += inputBodyName + String(F("Motion Pin")) + inputBodyPOST + String(F("motion_pin")) + inputPlaceHolder + JConf.motion_pin + inputBodyClose + inputBodyCloseDiv;
  data += inputBodyName + String(F("DHT Pin")) + inputBodyPOST + String(F("dht_pin")) + inputPlaceHolder + JConf.dht_pin + inputBodyClose + inputBodyCloseDiv;
  data += String(F("<br>"));

  data += inputBodyName + String(F("Update Data Delay")) + inputBodyPOST + String(F("get_data_delay")) + inputPlaceHolder + JConf.get_data_delay + inputBodyClose + inputBodyUnitStart + String(FPSTR(sec)) + inputBodyUnitEnd + inputBodyCloseDiv;
  data += inputBodyName + String(F("Motion Read Delay")) + inputBodyPOST + String(F("motion_read_delay")) + inputPlaceHolder + JConf.motion_read_delay + inputBodyClose + inputBodyUnitStart + String(FPSTR(sec)) + inputBodyUnitEnd + inputBodyCloseDiv;
  data += inputBodyName + String(F("Reboot Delay")) + inputBodyPOST + String(F("reboot_delay")) + inputPlaceHolder + JConf.reboot_delay + inputBodyClose + inputBodyUnitStart + String(FPSTR(sec)) + inputBodyUnitEnd + inputBodyCloseDiv;

  data += inputBodyEnd;

  WebServer.send( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebEspConf() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebMqttConf(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebMqttConf() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);

  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);

  String data;
  data += panelHeaderName;
  data += String(F("MQTT Configuration"));
  data += panelHeaderEnd;
  data += inputBodyStart;

  bool config_changed = false;
  bool enable = false;
  String payload = "";


  payload=WebServer.arg("mqtt_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.mqtt_enable, sizeof(JConf.mqtt_enable));
    config_changed = true;
    enable = true;
  }

  payload=WebServer.arg("mqtt_server");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.mqtt_server, sizeof(JConf.mqtt_server));
    config_changed = true;
  }

  payload=WebServer.arg("mqtt_port");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.mqtt_port, sizeof(JConf.mqtt_port));
    config_changed = true;
  }

  payload=WebServer.arg("mqtt_user");
  if (payload.length() > 0 ) {
    if (payload == "0"){
      String data = "";
      data.toCharArray(JConf.mqtt_user, sizeof(JConf.mqtt_user));
      data.toCharArray(JConf.mqtt_pwd, sizeof(JConf.mqtt_pwd));
    } else {
      payload.toCharArray(JConf.mqtt_user, sizeof(JConf.mqtt_user));
    }
    config_changed = true;
  }

  payload=WebServer.arg("mqtt_pwd");
  if (payload.length() > 0 ) {
    if (payload == "0"){
      String data = "";
      data.toCharArray(JConf.mqtt_user, sizeof(JConf.mqtt_user));
      data.toCharArray(JConf.mqtt_pwd, sizeof(JConf.mqtt_pwd));
    } else {
      payload.toCharArray(JConf.mqtt_pwd, sizeof(JConf.mqtt_pwd));
    }
    config_changed = true;
  }

  payload=WebServer.arg("mqtt_name");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.mqtt_name, sizeof(JConf.mqtt_name));
    config_changed = true;
  }

  payload=WebServer.arg("publish_topic");
  if (payload.length() > 0 ) {
    payload.replace("%2F", String(F("/")));
    payload.toCharArray(JConf.publish_topic, sizeof(JConf.publish_topic));
    config_changed = true;
  }

  payload=WebServer.arg("subscribe_topic");
  if (payload.length() > 0 ) {
    payload.replace("%2F", String(F("/")));
    payload.toCharArray(JConf.subscribe_topic, sizeof(JConf.subscribe_topic));
    config_changed = true;
  }

  payload=WebServer.arg("publish_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.publish_delay, sizeof(JConf.publish_delay));
    config_changed = true;
  }

  payload=WebServer.arg("subscribe_delay");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.subscribe_delay, sizeof(JConf.subscribe_delay));
    config_changed = true;
  }


  if (config_changed){
    if (!enable){
      JConf.mqtt_enable[0] = '0';
      JConf.mqtt_enable[1] = '';
    }
    JConf.saveConfig();
  }


  if (atoi(JConf.mqtt_enable) == 1){

    data += String(F("<div class='checkbox'><label><input type='checkbox' name='mqtt_enable' value='1' checked='true'>MQTT Enable</label></div>"));
    data += inputBodyName + String(F("Server MQTT")) + inputBodyPOST + String(F("mqtt_server")) + inputPlaceHolder + JConf.mqtt_server + inputBodyClose + inputBodyCloseDiv;
    data += inputBodyName + String(F("Port MQTT")) + inputBodyPOST + String(F("mqtt_port")) + inputPlaceHolder + JConf.mqtt_port + inputBodyClose + inputBodyCloseDiv;

    if (strlen(JConf.mqtt_user) != 0){
      data += String(F("<div><input type='hidden' name='mqtt_user' value='0'></div>"));
    }
    data += inputBodyName + String(F("MQTT User")) + inputBodyPOST + String(F("mqtt_user")) + inputPlaceHolder + JConf.mqtt_user + inputBodyClose + inputBodyCloseDiv;

    if (strlen(JConf.mqtt_pwd) != 0){
      data += String(F("<div><input type='hidden' name='mqtt_pwd' value='0'></div>"));
    }
    data += inputBodyName + String(F("MQTT Password")) + inputBodyPOST + String(F("mqtt_pwd")) + inputPlaceHolder + JConf.mqtt_pwd + inputBodyClose + inputBodyCloseDiv;

    data += inputBodyName + String(F("MQTT Prefix")) + inputBodyPOST + String(F("mqtt_name")) + inputPlaceHolder + JConf.mqtt_name + inputBodyClose + inputBodyCloseDiv;
    data += inputBodyName + String(F("Publish Topic")) + inputBodyPOST + String(F("publish_topic")) + inputPlaceHolder + JConf.publish_topic + inputBodyClose + inputBodyCloseDiv;
    data += inputBodyName + String(F("Subscribe Topic")) + inputBodyPOST + String(F("subscribe_topic")) + inputPlaceHolder + JConf.subscribe_topic + inputBodyClose + inputBodyCloseDiv;
    data += inputBodyName + String(F("Publish Delay")) + inputBodyPOST + String(F("publish_delay")) + inputPlaceHolder + JConf.publish_delay + inputBodyClose + inputBodyUnitStart + String(FPSTR(sec)) + inputBodyUnitEnd + inputBodyCloseDiv;
    data += inputBodyName + String(F("Subscribe Delay")) + inputBodyPOST + String(F("subscribe_delay")) + inputPlaceHolder + JConf.subscribe_delay + inputBodyClose + inputBodyUnitStart + String(FPSTR(sec)) + inputBodyUnitEnd + inputBodyCloseDiv;

  } else {
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='mqtt_enable' value='1'>MQTT Enable</label></div>"));
  }

  data += inputBodyEnd;

  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebMqttConf() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebNTPConf(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebNTPConf() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);

  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);

  String data;
  data += panelHeaderName;
  data += String(F("NTP Configuration"));
  data += panelHeaderEnd;
  data += inputBodyStart;

  bool config_changed = false;
  bool enable = false;
  String payload = "";


  payload=WebServer.arg("ntp_enable");
  if (payload.length() > 0) {
    payload.toCharArray(JConf.ntp_enable, sizeof(JConf.ntp_enable));
    config_changed = true;
    enable = true;
  }

  payload=WebServer.arg("ntp_server");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.ntp_server, sizeof(JConf.ntp_server));
    config_changed = true;
  }

  payload=WebServer.arg("my_time_zone");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.my_time_zone, sizeof(JConf.my_time_zone));
    config_changed = true;
  }

  if (config_changed){
    if (!enable){
      JConf.ntp_enable[0] = '0';
      JConf.ntp_enable[1] = '';
    }
    JConf.saveConfig();
  }

  if (atoi(JConf.ntp_enable) == 1){
    //data += String(F("<div><input type='hidden' name='ntp_enable' value='0'></div>"));
    data += String(F("<div class='checkbox'><label><input type='checkbox' name='ntp_enable' value='1' checked='true'>NTP Enable</label></div>"));

    data += inputBodyName + String(F("Server NTP")) + inputBodyPOST + String(F("ntp_server")) + inputPlaceHolder + JConf.ntp_server + inputBodyClose + inputBodyCloseDiv;

    data += inputBodyName + String(F("Time Zone")) + inputBodyPOST + String(F("my_time_zone")) + inputPlaceHolder + JConf.my_time_zone + inputBodyClose + inputBodyCloseDiv;

  } else {

    data += String(F("<div class='checkbox'><label><input type='checkbox' name='ntp_enable' value='1'>NTP Enable</label></div>"));
  }

  data += inputBodyEnd;


  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebNTPConf() Load Time: ")); Serial.println(load_time);
  #endif
}



void handleControl(){

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("handleControl() Start"));
  #endif

  String AUTO;       AUTO += FPSTR(AUTOP);
  String ON;         ON += FPSTR(ONP);
  String OFF;        OFF += FPSTR(OFFP);

  String last_light_state = lightState;
  String last_light_state2 = lightState2;

  if (WebServer.args() > 0 ) {
    for ( size_t i = 0; i < WebServer.args(); i++ ) {
      if (WebServer.argName(i) == "1" && WebServer.arg(i) == "1") {
        if (cycleEnd[atoi(JConf.light_pin)] != 0){
          lightState = OFF;
        } else {
          lightState = ON;
        }
      }
      if (WebServer.argName(i) == "1" && WebServer.arg(i) == "2") {
        lightState = AUTO;
      }

      if (WebServer.argName(i) == "2" && WebServer.arg(i) == "1") {
        if (cycleEnd[atoi(JConf.light2_pin)] != 0){
          lightState2 = OFF;
        } else {
          lightState2 = ON;
        }
      }
      if (WebServer.argName(i) == "2" && WebServer.arg(i) == "2") {
        lightState2 = AUTO;
      }
      #ifdef DEBUG
      Serial.println(WebServer.argName(i));
      Serial.println(WebServer.arg(i));
      #endif
      if (last_light_state != lightState || last_light_state2 != lightState2){
        LightControl();
        if (atoi(JConf.mqtt_enable) == 1) {
          MqttPubLightState();
        }
      }
    }
  }

  WebServer.send ( 200, "text/html", "OK");

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("handleControl() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebPinControl(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebPinControl() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);

  String javaScriptPinControl;               javaScriptPinControl += FPSTR(javaScriptPinControlP);

  String pinControl = headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + javaScriptPinControl + containerEnd + siteEnd;

  WebServer.send ( 200, "text/html", pinControl);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebPinControl() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebPinControlStatus(void) {

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebPinControlStatus() Start"));
  #endif

  LightControl();

  bool pinState;
  bool pinState2;

  String ClassInfo;       ClassInfo += FPSTR(ClassInfoP);
  String ClassDanger;     ClassDanger += FPSTR(ClassDangerP);
  String ClassDefault;    ClassDefault += FPSTR(ClassDefaultP);
  String ClassSuccess;    ClassSuccess += FPSTR(ClassSuccessP);
  String AUTO;            AUTO += FPSTR(AUTOP);
  String ON;              ON += FPSTR(ONP);
  String OFF;             OFF += FPSTR(OFFP);




  if (cycleEnd[atoi(JConf.light_pin)] != 0){
    pinState = true;
  } else {
    pinState = false;
  }


  if (cycleEnd[atoi(JConf.light2_pin)] != 0){
    pinState2 = true;
  } else {
    pinState2 = false;
  }


  String mode;
  if (lightState == AUTO){
    mode = ClassSuccess;
  } else if (lightState == ON) {
    mode = ClassInfo;
  } else {
    mode = ClassDanger;
  }

  String mode2;
  if (lightState2 == AUTO){
    mode2 = ClassSuccess;
  } else if (lightState2 == ON) {
    mode2 = ClassInfo;
  } else {
    mode2 = ClassDanger;
  }


  unsigned long timeOff = 0;
  if (millis() - lightOffTimer < atoi(JConf.lightoff_delay) * 60 * 1000){
    timeOff = atoi(JConf.lightoff_delay) * 60 * 1000 - (millis() - lightOffTimer);
    timeOff = timeOff/1000;
  }

  unsigned long timeOff2 = 0;
  if (millis() - lightOffTimer2 < atoi(JConf.light2off_delay) * 60 * 1000){
    timeOff2 = atoi(JConf.light2off_delay) * 60 * 1000 - (millis() - lightOffTimer2);
    timeOff2 = timeOff2/1000;
  }

  String data;    data += FPSTR(div1P);


  if (lightState == AUTO) { data+=ClassDefault; } else if (pinState) { data+=ClassDanger; } else { data+=ClassInfo; }
  data+=String(F("' value='"));
  if (pinState) { data+=String(F("Turn Off")); } else { data+=String(F("Turn On")); }
  data+=String(F("'></div></td><td class='active'><div onclick='Auto1();'><input id='Auto' type='submit' class='btn btn-"));
  if (lightState == AUTO) { data+=ClassDanger; } else { data+=ClassDefault; }
  data+=String(F("' value='Auto'></div></td><td class='"));
  if (pinState) { data+=ClassInfo; } else { data+=ClassDanger; }
  data+=String(F("'><h4>"));
  if (pinState) { data+=ON; } else { data+=OFF; }
  data+=String(F("</h4></td><td class='"));
  data+=mode;
  data+=String(F("'><h4>"));
  data+=lightState;
  data+=String(F("</h4></td><td class='"));
  data+=String(F("active"));
  data+=String(F("'><h4>"));
  data+=String(timeOff);
  data+=String(F("</h4></td></tr>"));


  data+=String(F("<tr><td class='active'><h4>Light2</h4></td><td class='active'><div onclick='Pin2();'><input id='OnOff2' type='submit' class='btn btn-"));
  if (lightState2 == AUTO) { data+=ClassDefault; } else if (pinState2) { data+=ClassDanger; } else { data+=ClassInfo; }
  data+=String(F("' value='"));
  if (pinState2) { data+=String(F("Turn Off")); } else { data+=String(F("Turn On")); }
  data+=String(F("'></div></td><td class='active'><div onclick='Auto2();'><input id='Auto2' type='submit' class='btn btn-"));
  if (lightState2 == AUTO) { data+=ClassDanger; } else { data+=ClassDefault; }
  data+=String(F("' value='Auto'></div></td><td class='"));
  if (pinState2) { data+=ClassInfo; } else { data+=ClassDanger; }
  data+=String(F("'><h4>"));
  if (pinState2) { data+=ON; } else { data+=OFF; }
  data+=String(F("</h4></td><td class='"));
  data+=mode2;
  data+=String(F("'><h4>"));
  data+=lightState2;
  data+=String(F("</h4></td><td class='"));
  data+=String(F("active"));
  data+=String(F("'><h4>"));
  data+=String(timeOff2);
  data+=String(F("</h4></td></tr>"));
  data+=String(F("</tbody></table></div>"));


  WebServer.send ( 200, "text/html", data);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebPinControlStatus() Load Time: ")); Serial.println(load_time);
  #endif
}



#if defined(UART_ON)
void WebAnalogUart(void) {
  #ifdef DEBUG
    Serial.print(F("WebAnalogUart()"));  Serial.println();
  #endif

    String headerStart;           headerStart += FPSTR(headerStartP);
    String headerStart2;          headerStart2 += FPSTR(headerStart2P);
    String headerEnd;             headerEnd += FPSTR(headerEndP);
    String javaScript;            javaScript += FPSTR(javaScriptP);
    String javaScript2;           javaScript2 += FPSTR(javaScript2P);
    String bodyAjax;              bodyAjax += FPSTR(bodyAjaxP);
    String navbarStart;           navbarStart += FPSTR(navbarStartP);
    String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
    String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

    navbarNonActive += FPSTR(navbarBeginP);
    navbarNonActive += FPSTR(navbarUartP);

    String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
    String containerStart;        containerStart += FPSTR(containerStartP);
    String containerEnd;          containerEnd += FPSTR(containerEndP);
    String siteEnd;               siteEnd += FPSTR(siteEndP);
    String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
    String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);
    String panelEnd;              panelEnd += FPSTR(panelEndP);
    String panelBodySymbol;       panelBodySymbol += FPSTR(panelBodySymbolP);
    String panelBodyName;         panelBodyName += FPSTR(panelBodyNameP);
    String panelBodyValue;        panelBodyValue += FPSTR(panelBodyValueP);
    String closingAngleBracket;   closingAngleBracket += FPSTR(closingAngleBracketP);
    String panelBodyEnd;          panelBodyEnd += FPSTR(panelBodyEndP);

    String title1  = panelHeaderName + String(F("Analog Pins value"))   + panelHeaderEnd;

    String ApinValue = panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 0")) + panelBodyValue + String(F(" id='apin0Id'")) + closingAngleBracket + panelBodyEnd;
    ApinValue       += panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 1")) + panelBodyValue + String(F(" id='apin1Id'")) + closingAngleBracket + panelBodyEnd;
    ApinValue       += panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 2")) + panelBodyValue + String(F(" id='apin2Id'")) + closingAngleBracket + panelBodyEnd;
    ApinValue       += panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 3")) + panelBodyValue + String(F(" id='apin3Id'")) + closingAngleBracket + panelBodyEnd;
    ApinValue       += panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 4")) + panelBodyValue + String(F(" id='apin4Id'")) + closingAngleBracket + panelBodyEnd;
    ApinValue       += panelBodySymbol + String(F("fire")) + panelBodyName + String(F("Analog pin 5")) + panelBodyValue + String(F(" id='apin5Id'")) + closingAngleBracket + panelBodyEnd;


    String title2 = panelHeaderName + String(F("Analog Pins delay"))  + panelHeaderEnd;

    String ApinDelay = panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 0")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin0 + panelBodyEnd;
    ApinDelay       += panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 1")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin1 + panelBodyEnd;
    ApinDelay       += panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 2")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin2 + panelBodyEnd;
    ApinDelay       += panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 3")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin3 + panelBodyEnd;
    ApinDelay       += panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 4")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin4 + panelBodyEnd;
    ApinDelay       += panelBodySymbol + String(F("time")) + panelBodyName + String(F("Analog pin 5")) + panelBodyValue + closingAngleBracket + JConf.uart_delay_analog_pin5 + panelBodyEnd;

    WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + javaScript + javaScript2 + bodyAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + title1 + ApinValue + panelEnd + title2 + ApinDelay + panelEnd + containerEnd + siteEnd);
}
#endif



void WebGreenhouse(void) {
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebGreenhouse() Start"));
  #endif

  String headerStart;           headerStart += FPSTR(headerStartP);
  String headerStart2;          headerStart2 += FPSTR(headerStart2P);
  String headerEnd;             headerEnd += FPSTR(headerEndP);
  String bodyNonAjax;           bodyNonAjax += FPSTR(bodyNonAjaxP);
  String navbarStart;           navbarStart += FPSTR(navbarStartP);
  String navbarStart2;          navbarStart2 += FPSTR(navbarStart2P);
  String navbarNonActive;       navbarNonActive += FPSTR(navbarNonActiveP);

  navbarNonActive += FPSTR(navbarBeginP);
  #ifdef UART_ON
    navbarNonActive += FPSTR(navbarUartP);
  #endif

  String navbarEnd;             navbarEnd += FPSTR(navbarEndP);
  String containerStart;        containerStart += FPSTR(containerStartP);
  String containerEnd;          containerEnd += FPSTR(containerEndP);
  String siteEnd;               siteEnd += FPSTR(siteEndP);
  String panelHeaderName;       panelHeaderName += FPSTR(panelHeaderNameP);
  String panelHeaderEnd;        panelHeaderEnd += FPSTR(panelHeaderEndP);

  String inputBodyStart;        inputBodyStart += FPSTR(inputBodyStartP);
  String inputBodyName;         inputBodyName += FPSTR(inputBodyNameP);
  String inputBodyPOST;         inputBodyPOST += FPSTR(inputBodyPOSTP);
  String inputPlaceHolder;      inputPlaceHolder += FPSTR(inputPlaceHolderP);
  String inputBodyClose;        inputBodyClose += FPSTR(inputBodyCloseP);
  String inputBodyCloseDiv;     inputBodyCloseDiv += FPSTR(inputBodyCloseDivP);
  String inputBodyUnitStart;    inputBodyUnitStart += FPSTR(inputBodyUnitStartP);
  String inputBodyUnitEnd;      inputBodyUnitEnd += FPSTR(inputBodyUnitEndP);
  String inputBodyEnd;          inputBodyEnd += FPSTR(inputBodyEndP);

  String data;
  data += panelHeaderName;
  data += String(F("Подсветка"));
  data += panelHeaderEnd;
  data += inputBodyStart;

  String payload=WebServer.arg("green_light_on");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_light_on, sizeof(JConf.green_light_on));
  }
  data += inputBodyName + String(F("Время включения")) + inputBodyPOST + String(F("green_light_on")) + inputPlaceHolder + JConf.green_light_on + inputBodyClose + inputBodyCloseDiv;

  payload=WebServer.arg("green_light_off");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_light_off, sizeof(JConf.green_light_off));
  }
  data += inputBodyName + String(F("Время выключения")) + inputBodyPOST + String(F("green_light_off")) + inputPlaceHolder + JConf.green_light_off + inputBodyClose + inputBodyCloseDiv;

  payload=WebServer.arg("green_light_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_light_pin, sizeof(JConf.green_light_pin));
  }
  data += inputBodyName + String(F("Пин лампы")) + inputBodyPOST + String(F("green_light_pin")) + inputPlaceHolder + JConf.green_light_pin + inputBodyClose + inputBodyCloseDiv;

  data += inputBodyEnd;

  data += String(F("<div class='page-header'><h2>"));
  data += String(F("Влажность почвы"));
  data += panelHeaderEnd;
  data += inputBodyStart;

  payload=WebServer.arg("green_humidity_threshold_up");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_humidity_threshold_up, sizeof(JConf.green_humidity_threshold_up));
  }
  data += inputBodyName + String(F("Верхний порог")) + inputBodyPOST + String(F("green_humidity_threshold_up")) + inputPlaceHolder + JConf.green_humidity_threshold_up + inputBodyClose + inputBodyCloseDiv;

  payload=WebServer.arg("green_humidity_threshold_down");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_humidity_threshold_down, sizeof(JConf.green_humidity_threshold_down));
  }
  data += inputBodyName + String(F("Нижний порог")) + inputBodyPOST + String(F("green_humidity_threshold_down")) + inputPlaceHolder + JConf.green_humidity_threshold_down + inputBodyClose + inputBodyCloseDiv;

  payload=WebServer.arg("green_humidity_sensor_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_humidity_sensor_pin, sizeof(JConf.green_humidity_sensor_pin));
  }
  data += inputBodyName + String(F("Пин датчика")) + inputBodyPOST + String(F("green_humidity_sensor_pin")) + inputPlaceHolder + JConf.green_humidity_sensor_pin + inputBodyClose + inputBodyCloseDiv;

  payload=WebServer.arg("green_pump_pin");
  if (payload.length() > 0 ) {
    payload.toCharArray(JConf.green_pump_pin, sizeof(JConf.green_pump_pin));
  }
  data += inputBodyName + String(F("Пин насоса")) + inputBodyPOST + String(F("green_pump_pin")) + inputPlaceHolder + JConf.green_pump_pin + inputBodyClose + inputBodyCloseDiv;

  data += inputBodyEnd;


  JConf.saveConfig();

  WebServer.send ( 200, "text/html", headerStart + JConf.module_id + headerStart2 + headerEnd + bodyNonAjax + navbarStart + JConf.module_id + navbarStart2 +navbarNonActive + navbarEnd + containerStart + data + containerEnd + siteEnd);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebGreenhouse() Load Time: ")); Serial.println(load_time);
  #endif
}
///////////////////////////////////   WEB PAGES  End  //////////////////////////////////////////////



void handleXML(){
  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("handleXML() Start"));
  #endif
  String XML;
  XML=String(F("<?xml version='1.0'?>"));
  XML+=String(F("<Donnees>"));
  XML+=String(F("<temperature>"));
  XML+=temperatureString;
  XML+=String(F(" °C"));
  XML+=String(F("</temperature>"));
  XML+=String(F("<humidity>"));
  XML+=humidityString;
  XML+=String(F(" %"));
  XML+=String(F("</humidity>"));
  XML+=String(F("<pressure>"));
  XML+=pressureString;
  XML+=String(F(" mm"));
  XML+=String(F("</pressure>"));
  XML+=String(F("<illuminance>"));
  XML+=luxString;
  XML+=String(F(" lux"));
  XML+=String(F("</illuminance>"));
  XML+=String(F("<uptime>"));
  XML+=uptimeString;
  XML+=String(F("</uptime>"));

  if (atoi(JConf.ntp_enable) == 1) {
    XML+=String(F("<ntpTime>"));
    XML+=ntpTimeString;
    XML+=String(F("</ntpTime>"));
  }

  XML+=String(F("<vcc>"));
  XML+=String(voltage_float);
  XML+=String(F(" V"));
  XML+=String(F("</vcc>"));
  XML+=String(F("<freeMemory>"));
  XML+=freeMemoryString;
  XML+=String(F("</freeMemory>"));

  #ifdef UART_ON
  for (int i = 0; i < ANALOG_PINS; i++){
    XML+=String(F("<apin"));  XML+=String(i);  XML+=String(F(">"));
    XML+=String(Uart.valueAnalogPin[i]);
    XML+=String(F("</apin")); XML+=String(i);  XML+=String(F(">"));
  }
  #endif

  XML+=String(F("</Donnees>"));

  WebServer.send(200,"text/xml",XML);

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("handleXML() Load Time: ")); Serial.println(load_time);
  #endif
}



void WebServerInit()
{

  #ifdef DEBUG
    unsigned long start_time = millis();
    Serial.println(F("WebServerInit() Start"));
  #endif

  // Prepare webserver pages
  WebServer.on("/", WebRoot);
  WebServer.on("/reboot", WebReboot);
  WebServer.on("/update", WebUpdate);
  WebServer.onFileUpload(WebFileUpload);
  WebServer.on("/upload_sketch", WebUploadSketch);
  //WebServer.on("/upload_sketch", HTTP_POST, WebFileUpload);


  WebServer.on("/wificonf", WebWiFiConf);

  WebServer.on("/sensorsconf", WebSensorsConf);
  WebServer.on("/espconf", WebEspConf);
  WebServer.on("/mqttconf", WebMqttConf);
  WebServer.on("/ntpconf", WebNTPConf);

  WebServer.on("/control", handleControl);

  WebServer.on("/pincontrol", WebPinControl);
  WebServer.on("/controlstatus", WebPinControlStatus);

#ifdef UART_ON
  WebServer.on("/analog", WebAnalogUart);
#endif

  WebServer.on("/greenhouse", WebGreenhouse);

  WebServer.on("/xml",handleXML);

/*
  WebServer.on("/upload", HTTP_GET, handle_upload);
  WebServer.on("/upload", HTTP_POST, handle_upload_post, handleFileUpload);
  WebServer.onNotFound(handleNotFound);

  if (ESP.getFlashChipRealSize() > 524288)
    httpUpdater.setup(&WebServer);
*/
  WebServer.begin();

  #ifdef DEBUG
    unsigned long load_time = millis() - start_time;
    Serial.print(F("WebServerInit() Load Time: ")); Serial.println(load_time);
  #endif
}



void setup() {

  // Setup console
  #ifdef DEBUG
    Serial.begin(115200);
    delay(10);
    Serial.println();
  #endif

  if (!SPIFFS.begin()) {
    #ifdef DEBUG
    Serial.println(F("Failed to mount file system"));
    #endif
    return;
  }
/*
  if (!JConf.saveConfig()) {
    Serial.println("Failed to save config");
  } else {
    Serial.println("Config saved");
  }
*/
  if (!JConf.loadConfig()) {
    #ifdef DEBUG
    Serial.println(F("Failed to load config"));
    #endif
  } else {
    #ifdef DEBUG
    Serial.println(F("Config loaded"));
    #endif
  }
  JConf.printConfig();

  pinMode(atoi(JConf.light_pin), OUTPUT);
  pinMode(atoi(JConf.light2_pin), OUTPUT);
  pinMode(atoi(JConf.motion_pin), INPUT);           // set pin to input

  digitalWrite(atoi(JConf.light_pin), LOW);
  digitalWrite(atoi(JConf.light2_pin), LOW);

  #ifdef SHT21_ON
    myHTU21D.begin();
  #endif

  #ifdef DHT_ON
    dht.begin();
  #endif

  if (atoi(JConf.bme280_enable) == 1) {
    #ifdef BME280_ON
      bmeSensor.settings.commInterface = I2C_MODE;
      bmeSensor.settings.I2CAddress = 0x76;
      bmeSensor.settings.runMode = 3;
      bmeSensor.settings.tStandby = 0;
      bmeSensor.settings.filter = 4;
      bmeSensor.settings.tempOverSample = 5;
      bmeSensor.settings.pressOverSample = 5;
      bmeSensor.settings.humidOverSample = 5;
      bmeSensor.begin();
    #endif
  }

  //Wire.begin(4,5); //SDA=4, SCL=5

  if (atoi(JConf.bh1750_enable) == 1) {
    lightSensor.begin();
  }

  if (atoi(JConf.bme280_enable) == 1 || atoi(JConf.bh1750_enable) == 1 || atoi(JConf.sht21_enable) == 1) {
    Wire.setClock(100000);
  }

  // scan Access Points
  scanWiFi();


  if (!WiFiSetup()) {
    WiFiSafeSetup();
  }
  delay(1000);


  if (atoi(JConf.mqtt_enable) == 1) {
    mqttClient.setClient(espClient);

    if (isIPValid(JConf.mqtt_server)){
      IPAddress mqtt_ip = stringToIp(JConf.mqtt_server);
      mqttClient.setServer(mqtt_ip, atoi(JConf.mqtt_port));
    } else {
      mqttClient.setServer(JConf.mqtt_server, atoi(JConf.mqtt_port));
    }

    mqttClient.setCallback (callback);
  }


  WebServerInit();


  #ifdef DEBUG
  Serial.println();  Serial.println(F("Server started"));
  #endif

/*
  // start mDNS responder
  if (!MDNS.begin(JConf.module_id)) {
    #ifdef DEBUG
    Serial.println();  Serial.println(F("Error setting up MDNS responder!"));
    #endif
    while (1) {
      delay(1000);
      yield();
    }
  }
  #ifdef DEBUG
  Serial.println();  Serial.println(F("mDNS responder started"));
  #endif

  // Add service to MDNS-SD
  MDNS.addService("http", "tcp", 80);

*/

  if (atoi(JConf.ntp_enable) == 1) {
    timeClient.reconfigure(JConf.ntp_server, atoi(JConf.my_time_zone) * 60 * 60, 60000);
  }
}



void loop() {

  #ifdef DEBUG
    unsigned long start_time = millis();
  #endif

  // handle web server
  WebServer.handleClient();

  #ifdef DEBUG
    unsigned long load_time1 = millis() - start_time;
    if (load_time1 > 100){
      Serial.print(F("WebServer.handleClient() Load Time:             ")); Serial.println(load_time1);
    }
  #endif

  if (millis() - getDataTimer >= atoi(JConf.get_data_delay) * 1000){
    getDataTimer = millis();

    if (atoi(JConf.ntp_enable) == 1) {
      timeClient.update();
      ntpTimeString = timeClient.getFormattedTime();
    }

    int voltage = ESP.getVcc();
    voltage_float = voltage / 1000.0;
    #ifdef REBOOT_ON
      RebootESP();
    #endif

    if (atoi(JConf.bh1750_enable) == 1){
      GetLightSensorData();
    }

    #ifdef BME280_ON
      if (atoi(JConf.bme280_enable) == 1){
        GetBmeSensorData();
      }
    #endif

    #ifdef SHT21_ON
      if (atoi(JConf.sht21_enable) == 1){
        GetSHT21SensorData();
      }
    #endif

    #ifdef DEBUG
      unsigned long load_time4 = millis() - start_time;
      if (load_time4 > 100){
        Serial.print(F("Get Sensors Load Time:                          ")); Serial.println(load_time4);
      }
    #endif


    GetUptimeData();
    GetFreeMemory();

    GetMacString();

    #ifdef DHT_ON
      DHT22Sensor();
    #endif

    #ifdef DEBUG
      TestSystemPrint();
    #endif

    #ifdef UART_ON
    for (int i = 0; i < ANALOG_PINS; i++){
      if (millis() - Uart.timerAnalogPin[i] >= 60000){
        Uart.valueAnalogPin[i] = 0;
        Uart.SetAnalogReadCycle(i, 10, "s");
      } else {

      }
    }
    #endif
  }

  #ifdef DEBUG
    unsigned long load_time2 = millis() - start_time;
    if (load_time2 > 100){
      Serial.print(F("Get Data Load Time:                             ")); Serial.println(load_time2);
    }
  #endif


  if (atoi(JConf.motion_sensor_enable) == 1){
    if (motionDetect == false){
      MotionDetect();
    }

    if (millis() - motionTimer >= atoi(JConf.motion_read_delay) * 1000){
      motionTimer = millis();
      motionDetect = false;
      MotionDetect();
    }
  }

  String AUTO;   AUTO += FPSTR(AUTOP);
  if (lightState == AUTO){
    LightControl();
  }


  if (WiFi.status() != WL_CONNECTED && atoi(JConf.wifi_mode) != AP && wifiSafeMode == false) {
    #ifdef DEBUG
    Serial.print(F("Connecting "));
    Serial.println(F("..."));
    #endif

    WiFiSetup();

/*
    if (WiFi.waitForConnectResult() != WL_CONNECTED)
      return;
*/
  }

  if (wifiSafeMode == true && millis() - wifiSafeModeReconnectTimer >= wifiSafeModeReconnectDelay ) {
    wifiSafeModeReconnectTimer = millis();
    if ( WiFiSetup() ) {
      wifiSafeMode = false;
    }
  }




/*
  if (WiFi.status() != WL_CONNECTED) {
    #ifdef DEBUG
    Serial.print(F("Connecting to "));
    Serial.print(JConf.sta_ssid);
    Serial.println(F("..."));
    #endif
    WiFi.mode(WIFI_AP_STA);
    WiFi.begin(JConf.sta_ssid, JConf.sta_pwd);
    delay(100);

    if (WiFi.waitForConnectResult() != WL_CONNECTED)
      return;
    #ifdef DEBUG
    Serial.println(F("WiFi connected"));
    #endif
  }
*/

  if (WiFi.status() == WL_CONNECTED) {

    if (atoi(JConf.mqtt_enable) == 1) {

      if (!mqttClient.connected()) {
        if (JConf.mqtt_user != "" && JConf.mqtt_pwd != ""){
          mqttClient.connect(JConf.mqtt_name, JConf.mqtt_user, JConf.mqtt_pwd);
        } else {
          mqttClient.connect(JConf.mqtt_name);
        }
      } else {
        mqttClient.loop();
        if (millis() - subscribeTimer >= atoi(JConf.subscribe_delay) * 1000) {
          subscribeTimer = millis();
          MqttSubscribe();
        }
      }

      if (millis() - publishTimer >= atoi(JConf.publish_delay) * 1000){
        publishTimer = millis();
        MqttPubData();
      }
    }
  }

  #ifdef UART_ON
  Uart.serialEvent();
  #endif

  FadeSwitchLoop();

  #ifdef DEBUG
    unsigned long load_time3 = millis() - start_time;
    if (load_time3 > 100){
      Serial.print(F("loop() Load Time:                               ")); Serial.println(load_time3);
    }
  #endif
}

Additional info

Home »
C programs »
C common errors programs

Here, we are going to learn why an error missing terminating double quote («) character occurs and how to fix it in C programming language?

Submitted by IncludeHelp, on September 08, 2018

This Error: missing terminating («) character is occurred, when a constant string or text is not closed in double quotes either you missed closing quotes or using singe quote instead of double quote while closing the string/text.

If string/text is not closed in double quotes, compiler throws this error.

Example 1:

#include <stdio.h>

int main(void) {
    
	//closing double quote is missing 
	printf("Hello world);

	return 0;
}

Output

prog.c: In function ‘main’:
prog.c:6:9: warning: missing terminating " character
  printf("Hello world);
         ^
prog.c:6:9: error: missing terminating " character
  printf("Hello world);
         ^~~~~~~~~~~~~~
prog.c:8:2: error: expected expression before ‘return’
  return 0;
  ^~~~~~
prog.c:9:1: error: expected ‘;’ before ‘}’ token
 }
 ^

Example 2:

#include <stdio.h>

int main(void) {
    
	//closing double quote is missing 
	printf("Hello world');

	return 0;
}

Output

prog.c: In function ‘main’:
prog.c:6:9: warning: missing terminating " character
  printf("Hello world');
         ^
prog.c:6:9: error: missing terminating " character
  printf("Hello world');
         ^~~~~~~~~~~~~~~
prog.c:8:2: error: expected expression before ‘return’
  return 0;
  ^~~~~~
prog.c:9:1: error: expected ‘;’ before ‘}’ token
 }
 ^

How to fix?

In the first program, closing double quote is missing, and in the second program, text is closing by single quote instead of double quote.

To fix this error, use double quote to close the string/text.

Correct code:

#include <stdio.h>

int main(void) {
    
	//closing double quote is missing 
	printf("Hello world");

	return 0;
}

Output

Hello world

C Common Errors Programs »


Помогите исправить ошибки пожалуйста, если можно с объяснением.Только учусь.

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <math.h>
 
 
 
double f(real x);
{
f:=1.32-1.43*x+1.32*sin(x)-0.8*ln(1+x);
}
 main ()
float a,b,x,c,eps;
 int n;
 {
 printf ("Введите левую границуn");
 scanf ("%f%f%f",&a);
 
 printf ("Введите правую границуn");
 scanf ("%f%f%f",&b)    
 
 printf ("Введите Эпсилонn");
 scanf ("%f%f%f",&eps);
 
 n=0;
 
 while abs(a-b)>eps do
 
{
    c=(a+b)/2;
    if f(a)*f(c)<=0 then b=c;
    else a=c;
    x=(a+b)/2;
    n=n+1;
}
 printf ("x=%5.2f, f(x)%0.3, Кол-во итераций=%,n");
}

___
34 10 missing terminating » character [enabled by default]
34 10 missing terminating » character [enabled by default]
34 2 missing terminating » character
6 10 ‘real’ was not declared in this scope
7 1 expected unqualified-id before ‘{‘ token
11 1 expected constructor, destructor, or type conversion before ‘float’
13 2expected unqualified-id before ‘{‘ token

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь

So, when trying to compile a TEENY WEENY program, it gives a massive error, please help, I am near helpless.

Here is the message…

minitech.cpp:18:9: warning: missing terminating » character [enabled by default]
minitech.cpp:18:1: error: missing terminating » character
minitech.cpp: In function ‘int main()’:
minitech.cpp:19:8: error: no match for ‘operator>>’ in ‘std::cout.std::basic_ostream<_CharT, _Traits>::operator<< <char, std::char_traits<char> >(((const void*)std::cin.std::basic_istream<char>::<anonymous>.std::basic_ios<_CharT, _Traits>::operator void*<char, std::char_traits<char> >())) >> leader_human’
minitech.cpp:19:8: note: candidates are:
In file included from /usr/include/c++/4.7/string:55:0,
from /usr/include/c++/4.7/bits/locale_classes.h:42,
from /usr/include/c++/4.7/bits/ios_base.h:43,
from /usr/include/c++/4.7/ios:43,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from minitech.cpp:4:
/usr/include/c++/4.7/bits/basic_string.tcc:998:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.7/bits/basic_string.tcc:998:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
In file included from /usr/include/c++/4.7/istream:873:0,
from /usr/include/c++/4.7/iostream:41,
from minitech.cpp:4:
/usr/include/c++/4.7/bits/istream.tcc:957:5: note: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
/usr/include/c++/4.7/bits/istream.tcc:957:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
In file included from /usr/include/c++/4.7/istream:873:0,
from /usr/include/c++/4.7/iostream:41,
from minitech.cpp:4:
/usr/include/c++/4.7/bits/istream.tcc:925:5: note: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
/usr/include/c++/4.7/bits/istream.tcc:925:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<_CharT, _Traits>’
In file included from /usr/include/c++/4.7/iostream:41:0,
from minitech.cpp:4:
/usr/include/c++/4.7/istream:725:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
/usr/include/c++/4.7/istream:725:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<char, _Traits>’
In file included from /usr/include/c++/4.7/iostream:41:0,
from minitech.cpp:4:
/usr/include/c++/4.7/istream:730:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
/usr/include/c++/4.7/istream:730:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<char, _Traits>’
In file included from /usr/include/c++/4.7/iostream:41:0,
from minitech.cpp:4:
/usr/include/c++/4.7/istream:772:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
/usr/include/c++/4.7/istream:772:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<char, _Traits>’
In file included from /usr/include/c++/4.7/iostream:41:0,
from minitech.cpp:4:
/usr/include/c++/4.7/istream:777:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
/usr/include/c++/4.7/istream:777:5: note: template argument deduction/substitution failed:
minitech.cpp:19:8: note: ‘std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>}’ is not derived from ‘std::basic_istream<char, _Traits>’

And this is the code…

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error missing server jvm at minecraft
  • Error missing server jvm at c java bin server jvm dll
  • Error missing semicolon semi
  • Error missing return statement mypy
  • Error missing return statement java

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии