Начало работы
Этот вопрос скорее Автору программы нужно задавать.....
День добрый пробую данные платы пришла с Китая пачка модулей , заказывал вемосы , киты потошибке положили три платы с названием wemos d1 r 32 , подключение к точки доступа не проходит при помощи блоков для есп , не могли бы вы уточнить какие " костыли " использовали. Делаю в данный момент проэкт автоматизации теплиц со всеми вытекающими последствиями( использую датчики дс 18 б20 дхт 22 , мхз 19 люкс метры , tds ,ec , ph ,кислородные углекислотные контролееры , помпы высокого давления ,перестальтические насосы , iot ,мониторинг, планирую добавить дачик окислительно восстановительного потенциала и будет фарш полный !!,код не маленткий вышел , и хотелось бы задействовать чип помощнее .в данный момент использую плату меги с распаяным модулем есп и внешней антенной
#include <WiFi.h> extern "C" { #include "user_interface.h"; } extern "C" { #include "user_interface.h" } os_timer_t watchDogTimer; int _PWDC = 0; bool ESP8266ControllerWifiClient_HRD = 0; bool ESP8266ControllerWifiClient_status = 1; bool ESP8266ControllerWifiClient_isDHCP = 1; bool ESP8266ControllerWifiClient_IsNeedReconect = 0; bool ESP8266ControllerWifiClient_workStatus = 1; char ESP8266ControllerWifiClient_SSID[40] = ""; char ESP8266ControllerWifiClient_password[40] = ""; IPAddress ESP8266ControllerWifiClient_ip(0, 0, 0, 0); IPAddress ESP8266ControllerWifiClient_dns (0, 0, 0, 1); IPAddress ESP8266ControllerWifiClient_gateway (0, 0, 0, 1); IPAddress ESP8266ControllerWifiClient_subnet (255, 255, 255, 0); uint8_t ESP8266ControllerWifiClient_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; bool _gen1I = 0; bool _gen1O = 0; unsigned long _gen1P = 0UL; void setup() { WiFi.mode(WIFI_STA); _esp8266WifiModuleClientReconnect(); satrtWachDogTimer(); pinMode(2, OUTPUT); } void loop() {_PWDC = 0; if(ESP8266ControllerWifiClient_IsNeedReconect) {_esp8266WifiModuleClientReconnect(); ESP8266ControllerWifiClient_IsNeedReconect = 0; } ESP8266ControllerWifiClient_status = WiFi.status() == WL_CONNECTED; if (ESP8266ControllerWifiClient_status) { if ( ! ESP8266ControllerWifiClient_HRD) { ESP8266ControllerWifiClient_ip = WiFi.localIP(); ESP8266ControllerWifiClient_subnet = WiFi.subnetMask(); ESP8266ControllerWifiClient_gateway = WiFi.gatewayIP(); ESP8266ControllerWifiClient_dns = WiFi.dnsIP(); WiFi.macAddress(ESP8266ControllerWifiClient_mac); ESP8266ControllerWifiClient_HRD = 1; }} else {ESP8266ControllerWifiClient_HRD = 0;} //Плата:1 if (1) { if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0;} if (_gen1I) { if ( _isTimer ( _gen1P , 500 )) { _gen1P = millis(); _gen1O = ! _gen1O;}} digitalWrite(2, _gen1O); } bool _isTimer(unsigned long startTime, unsigned long period ) { unsigned long currentTime; currentTime = millis(); if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));} } void wachDogTimerTick(void *pArg) { if (_PWDC >= 100){ ESP.reset(); }else{_PWDC = _PWDC+1;} } void satrtWachDogTimer(void ) { os_timer_setfn(&watchDogTimer, wachDogTimerTick, NULL); os_timer_arm(&watchDogTimer, 100, true); } int hexStrToInt(String instring) { byte len = instring.length(); if (len == 0) return 0; int result = 0; for (byte i = 0; i < 8; i++) // только первые 8 цыфар влезуть в uint32 { char ch = instring; if (ch == 0) break; result <<= 4; if (isdigit(ch)) result = result | (ch - '0'); else result = result | (ch - 'A' + 10); } return result; } void _esp8266WifiModuleClientReconnect() { if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) { wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));} if( ESP8266ControllerWifiClient_isDHCP) { WiFi.config(0U, 0U, 0U, 0U, 0U); } else { WiFi.config(ESP8266ControllerWifiClient_ip, ESP8266ControllerWifiClient_gateway, ESP8266ControllerWifiClient_subnet, ESP8266ControllerWifiClient_dns , ESP8266ControllerWifiClient_dns ); } WiFi.begin(ESP8266ControllerWifiClient_SSID, ESP8266ControllerWifiClient_password); } bool _checkMacAddres(byte array[]) { bool result = 0; for (byte i = 0; i < 6; i++) { if (array == 255) { return 0; } if (array > 0 ) { result = 1; } } return result; }
пока не помогает:
#include <WiFi.h> bool ESP8266ControllerWifiClient_HRD = 0; bool ESP8266ControllerWifiClient_status = 1; bool ESP8266ControllerWifiClient_isDHCP = 1; bool ESP8266ControllerWifiClient_IsNeedReconect = 0; bool ESP8266ControllerWifiClient_workStatus = 0; char ESP8266ControllerWifiClient_SSID[40] = ""; char ESP8266ControllerWifiClient_password[40] = ""; IPAddress ESP8266ControllerWifiClient_ip(0, 0, 0, 0); IPAddress ESP8266ControllerWifiClient_dns (0, 0, 0, 1); IPAddress ESP8266ControllerWifiClient_gateway (0, 0, 0, 1); IPAddress ESP8266ControllerWifiClient_subnet (255, 255, 255, 0); uint8_t ESP8266ControllerWifiClient_mac[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; bool _gen1I = 0; bool _gen1O = 0; unsigned long _gen1P = 0UL; void setup() { WiFi.mode(WIFI_STA); _esp8266WifiModuleClientReconnect(); pinMode(2, OUTPUT); } void loop() {if(ESP8266ControllerWifiClient_IsNeedReconect) {_esp8266WifiModuleClientReconnect(); ESP8266ControllerWifiClient_IsNeedReconect = 0; } ESP8266ControllerWifiClient_status = WiFi.status() == WL_CONNECTED; if (ESP8266ControllerWifiClient_status) { if ( ! ESP8266ControllerWifiClient_HRD) { ESP8266ControllerWifiClient_ip = WiFi.localIP(); ESP8266ControllerWifiClient_subnet = WiFi.subnetMask(); ESP8266ControllerWifiClient_gateway = WiFi.gatewayIP(); ESP8266ControllerWifiClient_dns = WiFi.dnsIP(); WiFi.macAddress(ESP8266ControllerWifiClient_mac); ESP8266ControllerWifiClient_HRD = 1; }} else {ESP8266ControllerWifiClient_HRD = 0;} //Плата:1 if (1) { if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0;} if (_gen1I) { if ( _isTimer ( _gen1P , 500 )) { _gen1P = millis(); _gen1O = ! _gen1O;}} digitalWrite(2, _gen1O); } bool _isTimer(unsigned long startTime, unsigned long period ) { unsigned long currentTime; currentTime = millis(); if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));} } int hexStrToInt(String instring) { byte len = instring.length(); if (len == 0) return 0; int result = 0; for (byte i = 0; i < 8; i++) // только первые 8 цыфар влезуть в uint32 { char ch = instring; if (ch == 0) break; result <<= 4; if (isdigit(ch)) result = result | (ch - '0'); else result = result | (ch - 'A' + 10); } return result; } void _esp8266WifiModuleClientReconnect() { if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) { wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));} if( ESP8266ControllerWifiClient_isDHCP) { WiFi.config(0U, 0U, 0U, 0U, 0U); } else { WiFi.config(ESP8266ControllerWifiClient_ip, ESP8266ControllerWifiClient_gateway, ESP8266ControllerWifiClient_subnet, ESP8266ControllerWifiClient_dns , ESP8266ControllerWifiClient_dns ); } WiFi.begin(ESP8266ControllerWifiClient_SSID, ESP8266ControllerWifiClient_password); } bool _checkMacAddres(byte array[]) { bool result = 0; for (byte i = 0; i < 6; i++) { if (array == 255) { return 0; } if (array > 0 ) { result = 1; } } return result; }
Arduino: 1.8.9 (Windows 10), Плата:"ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None" "C:\\Users\\dimon\\AppData\\Local\\Temp\\arduino_build_932192\\sketch\\pr8.ino.cpp" -o "C:\\Users\\dimon\\AppData\\Local\\Temp\\arduino_build_932192\\sketch\\pr8.ino.cpp.o" C:\Users\dimon\AppData\Local\Temp\flprog\pr8\pr8.ino: In function 'void _esp8266WifiModuleClientReconnect()': pr8:72:90: error: 'uint8' does not name a type if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) { wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));} ^ pr8:72:95: error: expected '>' before '*' token if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) { wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));} ^ pr8:72:95: error: expected '(' before '*' token pr8:72:96: error: expected primary-expression before '>' token if( _checkMacAddres(ESP8266ControllerWifiClient_mac)) { wifi_set_macaddr(0, const_cast<uint8*>(ESP8266ControllerWifiClient_mac));} ^ Несколько библиотек найдено для "WiFi.h" Используется: c:\FLProg_5-3_Win64\ideV3\portable\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi Не используется: c:\FLProg_5-3_Win64\ideV3\libraries\WiFi Используем библиотеку WiFi версии 1.0 из папки: c:\FLProg_5-3_Win64\ideV3\portable\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi exit status 1 'uint8' does not name a type
Чего там секретного? в соседней теме же размещал! viewtopic.php?f=156&t=5723&start=40#p91930