Skip to content

Commit

Permalink
[PIO build] Build issues caused by incorrect precompile processing
Browse files Browse the repository at this point in the history
It looks like `ESP32` is not defined anymore, which leads to various issues when building.
  • Loading branch information
TD-er committed Jul 7, 2018
1 parent 8957805 commit e7764ca
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 357 deletions.
3 changes: 2 additions & 1 deletion lib/ESPEasySoftwareSerial/ESPeasySoftwareSerial.cpp
Expand Up @@ -18,7 +18,7 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifdef ESP8266 // Needed for precompile issues.
#include <Arduino.h>

// The Arduino standard GPIO routines are not enough,
Expand Down Expand Up @@ -239,3 +239,4 @@ void ICACHE_RAM_ATTR ESPeasySoftwareSerial::rxRead() {
// it gets set even when interrupts are disabled
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rxPin);
}
#endif
3 changes: 2 additions & 1 deletion lib/ESPEasySoftwareSerial/ESPeasySoftwareSerial.h
Expand Up @@ -19,7 +19,7 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifdef ESP8266 // Needed for precompile issues.
#ifndef ESPeasySoftwareSerial_h
#define ESPeasySoftwareSerial_h

Expand Down Expand Up @@ -76,3 +76,4 @@ class ESPeasySoftwareSerial : public Stream


#endif
#endif
3 changes: 2 additions & 1 deletion lib/SerialDevices/jkSDS011.cpp
Expand Up @@ -22,7 +22,7 @@
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/

#ifdef ESP8266 // Needed for precompile issues.
#include "jkSDS011.h"

CjkSDS011::CjkSDS011(int16_t pinRX, int16_t pinTX)
Expand Down Expand Up @@ -186,3 +186,4 @@ boolean CjkSDS011::ReadAverage(float &pm25, float &pm10)
pm10 = NAN;
return false;
}
#endif
3 changes: 2 additions & 1 deletion lib/SerialDevices/jkSDS011.h
Expand Up @@ -22,7 +22,7 @@
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/

#ifdef ESP8266 // Needed for precompile issues.
#ifndef _jkSDS011_H_
#define _jkSDS011_H_

Expand Down Expand Up @@ -79,3 +79,4 @@ class CjkSDS011
};

#endif
#endif
648 changes: 342 additions & 306 deletions platformio.ini

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/ESPEasy-Globals.h
Expand Up @@ -188,7 +188,7 @@
#endif

#define MAX_FLASHWRITES_PER_DAY 100 // per 24 hour window
#define INPUT_COMMAND_SIZE 80
#define INPUT_COMMAND_SIZE 80

#define NODE_TYPE_ID_ESP_EASY_STD 1
#define NODE_TYPE_ID_ESP_EASYM_STD 17
Expand Down Expand Up @@ -392,7 +392,7 @@
#include <lwip/tcp_impl.h>
#endif
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
//#include <ESP8266Ping.h>
#include <ESP8266WebServer.h>
ESP8266WebServer WebServer(80);
#include <DNSServer.h>
Expand Down
16 changes: 12 additions & 4 deletions src/ESPEasy.ino
Expand Up @@ -5,6 +5,14 @@
#pragma GCC diagnostic warning "-Wall"
#endif

// Needed due to preprocessor issues.
#ifdef PLUGIN_SET_GENERIC_ESP32
#ifndef ESP32
#define ESP32
#endif
#endif


/****************************************************************************************************************************\
* Arduino project "ESP Easy" © Copyright www.letscontrolit.com
*
Expand Down Expand Up @@ -377,7 +385,7 @@ void updateLoopStats() {
const long usecSince = usecPassedSince(lastLoopStart);
loop_usec_duration_total += usecSince;
lastLoopStart = micros();
if (usecSince <= 0 || usecSince > 10000000)
if (usecSince <= 0 || usecSince > 10000000)
return; // No loop should take > 10 sec.
if (shortestLoop > static_cast<unsigned long>(usecSince)) {
shortestLoop = usecSince;
Expand Down Expand Up @@ -918,8 +926,8 @@ void checkSystemTimers()
TempEvent.Par4 = systemTimers[x].Par4;
TempEvent.Par5 = systemTimers[x].Par5;
systemTimers[x].timer = 0;
const int y = getPluginId(systemTimers[x].TaskIndex);
if (y >= 0) {
const int y = getPluginId(systemTimers[x].TaskIndex);
if (y >= 0) {
Plugin_ptr[y](PLUGIN_TIMER_IN, &TempEvent, dummyString);
}
}
Expand Down Expand Up @@ -995,4 +1003,4 @@ void backgroundtasks()
statusLED(false);

runningBackgroundTasks=false;
}
}
13 changes: 7 additions & 6 deletions src/Misc.ino
Expand Up @@ -1421,13 +1421,14 @@ String getLWIPversion() {
}
#endif

#ifdef ESP32

/********************************************************************************************\
Get partition table information
\*********************************************************************************************/

String getPartitionType(esp_partition_type_t partitionType, esp_partition_subtype_t partitionSubType) {
#ifdef ESP32
String getPartitionType(byte pType, byte pSubType) {
esp_partition_type_t partitionType = static_cast<esp_partition_type_t>(pType);
esp_partition_subtype_t partitionSubType = static_cast<esp_partition_subtype_t>(pSubType);
if (partitionType == ESP_PARTITION_TYPE_APP) {
if (partitionSubType >= ESP_PARTITION_SUBTYPE_APP_OTA_MIN &&
partitionSubType < ESP_PARTITION_SUBTYPE_APP_OTA_MAX) {
Expand Down Expand Up @@ -1475,7 +1476,8 @@ String getPartitionTableHeader(const String& itemSep, const String& lineEnd) {
return result;
}

String getPartitionTable(esp_partition_type_t partitionType, const String& itemSep, const String& lineEnd) {
String getPartitionTable(byte pType, const String& itemSep, const String& lineEnd) {
esp_partition_type_t partitionType = static_cast<esp_partition_type_t>(pType);
String result;
const esp_partition_t * _mypart;
esp_partition_iterator_t _mypartiterator = esp_partition_find(partitionType, ESP_PARTITION_SUBTYPE_ANY, NULL);
Expand All @@ -1492,12 +1494,11 @@ String getPartitionTable(esp_partition_type_t partitionType, const String& itemS
result += itemSep;
result += (_mypart->encrypted ? F("Yes") : F("-"));
result += lineEnd;
} while (_mypartiterator = esp_partition_next(_mypartiterator));
} while ((_mypartiterator = esp_partition_next(_mypartiterator)) != NULL);
}
esp_partition_iterator_release(_mypartiterator);
return result;
}

#endif


Expand Down
5 changes: 3 additions & 2 deletions src/_P010_BH1750.ino
Expand Up @@ -2,8 +2,9 @@
//#######################################################################################################
//#################################### Plugin-010: LuxRead ############################################
//#######################################################################################################

#include <AS_BH1750.h>
#ifdef ESP8266 // Needed for precompile issues.
#include "AS_BH1750.h"
#endif

#define PLUGIN_010
#define PLUGIN_ID_010 10
Expand Down
4 changes: 3 additions & 1 deletion src/_P016_IR.ino
Expand Up @@ -4,8 +4,10 @@
//#######################################################################################################



#ifdef ESP8266 // Needed for precompile issues.
#include <IRremoteESP8266.h>
#endif

IRrecv *irReceiver;
decode_results results;

Expand Down
2 changes: 2 additions & 0 deletions src/_P035_IRTX.ino
Expand Up @@ -3,7 +3,9 @@
//#################################### Plugin 035: Output IR ############################################
//#######################################################################################################

#ifdef ESP8266 // Needed for precompile issues.
#include <IRremoteESP8266.h>
#endif
IRsend *Plugin_035_irSender;

#define PLUGIN_035
Expand Down
62 changes: 31 additions & 31 deletions src/_P044_P1WifiGateway.ino
Expand Up @@ -14,14 +14,14 @@
#define PLUGIN_NAME_044 "Communication - P1 Wifi Gateway"
#define PLUGIN_VALUENAME1_044 "P1WifiGateway"

#define STATUS_LED 12
#define P044_STATUS_LED 12
#define P044_BUFFER_SIZE 1024
#define NETBUF_SIZE 600
#define DISABLED 0
#define WAITING 1
#define READING 2
#define CHECKSUM 3
#define DONE 4
#define P044_NETBUF_SIZE 600
#define P044_DISABLED 0
#define P044_WAITING 1
#define P044_READING 2
#define P044_CHECKSUM 3
#define P044_DONE 4

boolean Plugin_044_init = false;
boolean serialdebug = false;
Expand All @@ -38,7 +38,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
static byte connectionState = 0;
static int state = DISABLED;
static int state = P044_DISABLED;

switch (function)
{
Expand Down Expand Up @@ -103,8 +103,8 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)

case PLUGIN_INIT:
{
pinMode(STATUS_LED, OUTPUT);
digitalWrite(STATUS_LED, 0);
pinMode(P044_STATUS_LED, OUTPUT);
digitalWrite(P044_STATUS_LED, 0);

LoadTaskSettings(event->TaskIndex);
if ((ExtraTaskSettings.TaskDevicePluginConfigLong[0] != 0) && (ExtraTaskSettings.TaskDevicePluginConfigLong[1] != 0))
Expand Down Expand Up @@ -155,7 +155,7 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
}


state = WAITING;
state = P044_WAITING;
success = true;
break;
}
Expand Down Expand Up @@ -237,26 +237,26 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
int timeOut = RXWait;
while (timeOut > 0)
{
while (Serial.available() && state != DONE) {
while (Serial.available() && state != P044_DONE) {
if (bytes_read < P044_BUFFER_SIZE - 5) {
char ch = Serial.read();
digitalWrite(STATUS_LED, 1);
digitalWrite(P044_STATUS_LED, 1);
switch (state) {
case DISABLED: //ignore incoming data
case P044_DISABLED: //ignore incoming data
break;
case WAITING:
case P044_WAITING:
if (ch == '/') {
Plugin_044_serial_buf[0] = ch;
bytes_read=1;
state = READING;
state = P044_READING;
} // else ignore data
break;
case READING:
case P044_READING:
if (ch == '!') {
if (CRCcheck) {
state = CHECKSUM;
state = P044_CHECKSUM;
} else {
state = DONE;
state = P044_DONE;
}
}
if (validP1char(ch)) {
Expand All @@ -270,19 +270,19 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
addLog(LOG_LEVEL_DEBUG, F("P1 : Error: DATA corrupt, discarded input."));
Serial.flush();
bytes_read = 0;
state = WAITING;
state = P044_WAITING;
}
break;
case CHECKSUM:
case P044_CHECKSUM:
checkI ++;
if (checkI == 4) {
checkI = 0;
state = DONE;
state = P044_DONE;
}
Plugin_044_serial_buf[bytes_read] = ch;
bytes_read++;
break;
case DONE:
case P044_DONE:
// Plugin_044_serial_buf[bytes_read]= '\n';
// bytes_read++;
// Plugin_044_serial_buf[bytes_read] = 0;
Expand All @@ -293,16 +293,16 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
{
Serial.read(); // when the buffer is full, just read remaining input, but do not store...
bytes_read = 0;
state = WAITING; // reset
state = P044_WAITING; // reset
}
digitalWrite(STATUS_LED, 0);
digitalWrite(P044_STATUS_LED, 0);
timeOut = RXWait; // if serial received, reset timeout counter
}
delay(1);
timeOut--;
}

if (state == DONE) {
if (state == P044_DONE) {
if (checkDatagram(bytes_read)) {
Plugin_044_serial_buf[bytes_read] = '\r';
bytes_read++;
Expand All @@ -327,8 +327,8 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
}

bytes_read = 0;
state = WAITING;
} // state == DONE
state = P044_WAITING;
} // state == P044_DONE
}
success = true;
}
Expand All @@ -339,9 +339,9 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
return success;
}
void blinkLED() {
digitalWrite(STATUS_LED, 1);
digitalWrite(P044_STATUS_LED, 1);
delay(500);
digitalWrite(STATUS_LED, 0);
digitalWrite(P044_STATUS_LED, 0);
}
/*
validP1char
Expand Down Expand Up @@ -396,7 +396,7 @@ unsigned int CRC16(unsigned int crc, unsigned char *buf, int len)
}

/* checkDatagram
checks whether the checksum of the data received from P1 matches the checksum attached to the
checks whether the P044_CHECKSUM of the data received from P1 matches the P044_CHECKSUM attached to the
telegram
based on code written by Jan ten Hove
https://github.com/jantenhove/P1-Meter-ESP8266
Expand Down
3 changes: 2 additions & 1 deletion src/_P056_SDS011-Dust.ino
Expand Up @@ -9,7 +9,7 @@
This plugin reads the particle concentration from SDS011 Sensor
DevicePin1 - RX on ESP, TX on SDS
*/

#ifdef ESP8266 // Needed for precompile issues.

#define PLUGIN_056
#define PLUGIN_ID_056 56
Expand Down Expand Up @@ -204,3 +204,4 @@ void Plugin_056_setWorkingPeriod(int minutes) {
}

#endif // USES_P056
#endif

0 comments on commit e7764ca

Please sign in to comment.