Skip to content

Commit

Permalink
Fix compilation errors in PZEM004TSensor class (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoseperez committed May 8, 2018
1 parent 9a41252 commit edcc6a7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions code/espurna/sensors/PZEM004TSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class PZEM004TSensor : public BaseSensor {
// Public
// ---------------------------------------------------------------------

PZEM004TSensor(): BaseSensor(), _data() {
PZEM004TSensor(): BaseSensor() {
_count = 4;
_sensor_id = SENSOR_PZEM004T_ID;
_ip = IPAddress(192,168,1,1);
}

~PZEM004TSensor() {
Expand All @@ -43,7 +44,7 @@ class PZEM004TSensor : public BaseSensor {
_dirty = true;
}

void setSerial(Stream & serial) {
void setSerial(HardwareSerial * serial) {
_serial = serial;
_dirty = true;
}
Expand All @@ -58,10 +59,6 @@ class PZEM004TSensor : public BaseSensor {
return _pin_tx;
}

Stream & getSerial() {
return _serial;
}

// ---------------------------------------------------------------------
// Sensor API
// ---------------------------------------------------------------------
Expand All @@ -72,10 +69,10 @@ class PZEM004TSensor : public BaseSensor {
if (!_dirty) return;

if (_pzem) delete _pzem;
if (_serial == NULL) {
_pzem = PZEM004T(_pin_rx, _pin_tx);
if (_serial) {
_pzem = new PZEM004T(_serial);
} else {
_pzem = PZEM004T(_serial);
_pzem = new PZEM004T(_pin_rx, _pin_tx);
}
_pzem->setAddress(_ip);

Expand Down Expand Up @@ -127,8 +124,8 @@ class PZEM004TSensor : public BaseSensor {

unsigned int _pin_rx = PZEM004T_RX_PIN;
unsigned int _pin_tx = PZEM004T_TX_PIN;
Stream & _serial = NULL;
IPAddress _ip(192,168,1,1);
IPAddress _ip;
HardwareSerial * _serial = NULL;
PZEM004T * _pzem = NULL;

};
Expand Down

0 comments on commit edcc6a7

Please sign in to comment.