Skip to content

Commit 8231863

Browse files
committed
Create ESP32 as typedef to ESP8266
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
1 parent a5b5936 commit 8231863

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

src/modems/EspressifESP32.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @file EspressifESP32.h
3+
* @copyright 2017-2022 Stroud Water Research Center
4+
* Part of the EnviroDIY ModularSensors library for Arduino
5+
* @author Sara Geleskie Damiano <sdamiano@stroudcenter.org>
6+
*
7+
* @brief Contains the EspressifESP32 subclass of loggerModem which is merely a
8+
* typedef for the EspressifESP8266 class.
9+
*/
10+
/* clang-format off */
11+
#endif // SRC_MODEMS_ESPRESSIFESP8266_H_
12+
// Header Guards
13+
#ifndef SRC_MODEMS_ESPRESSIFESP8266_H_
14+
#define SRC_MODEMS_ESPRESSIFESP8266_H_
15+
16+
// Included the ESP8266
17+
#include "EspressifESP8266.h"
18+
19+
#endif // SRC_MODEMS_ESPRESSIFESP8266_H_

src/modems/EspressifESP8266.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file EspressifESP8266.cpp
3-
* @copyright 2020 Stroud Water Research Center
3+
* @copyright 2017-2022 Stroud Water Research Center
44
* Part of the EnviroDIY ModularSensors library for Arduino
55
* @author Sara Geleskie Damiano <sdamiano@stroudcenter.org>
66
*
@@ -11,7 +11,7 @@
1111
#include "EspressifESP8266.h"
1212
#include "LoggerModemMacros.h"
1313

14-
// Constructor
14+
// Constructors
1515
EspressifESP8266::EspressifESP8266(Stream* modemStream, int8_t powerPin,
1616
int8_t statusPin, int8_t modemResetPin,
1717
int8_t modemSleepRqPin, const char* ssid,
@@ -37,6 +37,31 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, int8_t powerPin,
3737

3838
_modemStream = modemStream;
3939
}
40+
EspressifESP8266::EspressifESP8266(Stream* modemStream, int8_t powerPin,
41+
int8_t statusPin, int8_t modemResetPin,
42+
const char* ssid, const char* pwd,
43+
int8_t modemSleepRqPin, int8_t espSleepRqPin,
44+
int8_t espStatusPin)
45+
: loggerModem(powerPin, statusPin, ESP8266_STATUS_LEVEL, modemResetPin,
46+
ESP8266_RESET_LEVEL, ESP8266_RESET_PULSE_MS, modemSleepRqPin,
47+
ESP8266_WAKE_LEVEL, ESP8266_WAKE_PULSE_MS,
48+
ESP8266_STATUS_TIME_MS, ESP8266_DISCONNECT_TIME_MS,
49+
ESP8266_WAKE_DELAY_MS, ESP8266_ATRESPONSE_TIME_MS),
50+
#ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP
51+
_modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT),
52+
gsmModem(_modemATDebugger),
53+
#else
54+
gsmModem(*modemStream),
55+
#endif
56+
gsmClient(gsmModem) {
57+
_ssid = ssid;
58+
_pwd = pwd;
59+
60+
_espSleepRqPin = espSleepRqPin;
61+
_espStatusPin = espStatusPin;
62+
63+
_modemStream = modemStream;
64+
}
4065

4166
// Destructor
4267
EspressifESP8266::~EspressifESP8266() {}

src/modems/EspressifESP8266.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @file EspressifESP8266.h
3-
* @copyright 2020 Stroud Water Research Center
3+
* @copyright 2017-2022 Stroud Water Research Center
44
* Part of the EnviroDIY ModularSensors library for Arduino
55
* @author Sara Geleskie Damiano <sdamiano@stroudcenter.org>
66
*
@@ -193,7 +193,7 @@
193193
*/
194194
class EspressifESP8266 : public loggerModem {
195195
public:
196-
// Constructor/Destructor
196+
// Constructors/Destructor
197197
/**
198198
* @brief Construct a new Espressif ESP8266 object.
199199
*
@@ -223,6 +223,35 @@ class EspressifESP8266 : public loggerModem {
223223
int8_t modemResetPin, int8_t modemSleepRqPin,
224224
const char* ssid, const char* pwd,
225225
int8_t espSleepRqPin = -1, int8_t espStatusPin = -1);
226+
/**
227+
* @brief Construct a new Espressif ESP8266 object.
228+
*
229+
* The constuctor initializes all of the provided member variables,
230+
* constructs a loggerModem parent class with the appropriate timing for the
231+
* module, calls the constructor for a TinyGSM modem on the provided
232+
* modemStream, and creates a TinyGSM Client linked to the modem.
233+
*
234+
* @param modemStream The Arduino stream instance for serial communication.
235+
* @param powerPin @copydoc loggerModem::_powerPin
236+
* @param statusPin @copydoc loggerModem::_statusPin
237+
* This can be any DIO pin on the esp. It is only used in light sleep.
238+
* @param modemResetPin @copydoc loggerModem::_modemResetPin
239+
* This is the ESP's `RSTB/DIO16` pin.
240+
* @param ssid The wifi network ID.
241+
* @param pwd The wifi network password, **assuming WPA2**.
242+
* @param modemSleepRqPin @copydoc loggerModem::_modemSleepRqPin
243+
* This can be any DIO pin on the esp. It is only used in light sleep.
244+
* @param espSleepRqPin The DIO pin on the ESP8266 assigned to light sleep
245+
* wake. This can be any DIO pin on the esp.
246+
* @param espStatusPin The DIO pin on the ESP8566 assigned to status
247+
* indication. This can be any DIO pin on the esp.
248+
*
249+
* @see loggerModem::loggerModem
250+
*/
251+
EspressifESP8266(Stream* modemStream, int8_t powerPin, int8_t statusPin,
252+
int8_t modemResetPin, const char* ssid, const char* pwd,
253+
int8_t modemSleepRqPin = -1, int8_t espSleepRqPin = -1,
254+
int8_t espStatusPin = -1);
226255
/**
227256
* @brief Destroy the Espressif ESP8266 object - no action taken
228257
*/
@@ -276,5 +305,11 @@ class EspressifESP8266 : public loggerModem {
276305
int8_t _espSleepRqPin;
277306
int8_t _espStatusPin;
278307
};
308+
309+
/**
310+
* @brief typedef to avoid confusion for users
311+
*/
312+
typedef EspressifESP8266 EspressifESP32;
313+
279314
/**@}*/
280315
#endif // SRC_MODEMS_ESPRESSIFESP8266_H_

0 commit comments

Comments
 (0)