Skip to content

Commit 9e55ccd

Browse files
PPP: Make modem reset delay configurable (#9910)
* fix(ppp): Make modem reset delay configurable The delay required to reset Simcom modem modules varies significantly across different models, even where they have otherwise identical AT command sets. Simcom A7672 was failing to reset with the default 200ms delay. Make the reset delay configurable to allow customising this for a specific modem. Default delay, if not specified is kept at 200ms. * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 47298ff commit 9e55ccd

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Diff for: libraries/PPP/examples/PPP_Basic/PPP_Basic.ino

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
#define PPP_MODEM_PIN "0000" // or NULL
55

66
// WaveShare SIM7600 HW Flow Control
7-
#define PPP_MODEM_RST 25
8-
#define PPP_MODEM_RST_LOW false //active HIGH
9-
#define PPP_MODEM_TX 21
10-
#define PPP_MODEM_RX 22
11-
#define PPP_MODEM_RTS 26
12-
#define PPP_MODEM_CTS 27
13-
#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
14-
#define PPP_MODEM_MODEL PPP_MODEM_SIM7600
7+
#define PPP_MODEM_RST 25
8+
#define PPP_MODEM_RST_LOW false //active HIGH
9+
#define PPP_MODEM_RST_DELAY 200
10+
#define PPP_MODEM_TX 21
11+
#define PPP_MODEM_RX 22
12+
#define PPP_MODEM_RTS 26
13+
#define PPP_MODEM_CTS 27
14+
#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
15+
#define PPP_MODEM_MODEL PPP_MODEM_SIM7600
1516

1617
// SIM800 basic module with just TX,RX and RST
1718
// #define PPP_MODEM_RST 0
@@ -60,7 +61,7 @@ void setup() {
6061
// Configure the modem
6162
PPP.setApn(PPP_MODEM_APN);
6263
PPP.setPin(PPP_MODEM_PIN);
63-
PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW);
64+
PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY);
6465
PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC);
6566

6667
Serial.println("Starting the modem. It might take a while!");

Diff for: libraries/PPP/src/PPP.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ esp_modem_dce_t *PPPClass::handle() const {
141141
}
142142

143143
PPPClass::PPPClass()
144-
: _dce(NULL), _pin_tx(-1), _pin_rx(-1), _pin_rts(-1), _pin_cts(-1), _flow_ctrl(ESP_MODEM_FLOW_CONTROL_NONE), _pin_rst(-1), _pin_rst_act_low(true), _pin(NULL),
145-
_apn(NULL), _rx_buffer_size(4096), _tx_buffer_size(512), _mode(ESP_MODEM_MODE_COMMAND), _uart_num(UART_NUM_1) {}
144+
: _dce(NULL), _pin_tx(-1), _pin_rx(-1), _pin_rts(-1), _pin_cts(-1), _flow_ctrl(ESP_MODEM_FLOW_CONTROL_NONE), _pin_rst(-1), _pin_rst_act_low(true),
145+
_pin_rst_delay(200), _pin(NULL), _apn(NULL), _rx_buffer_size(4096), _tx_buffer_size(512), _mode(ESP_MODEM_MODE_COMMAND), _uart_num(UART_NUM_1) {}
146146

147147
PPPClass::~PPPClass() {}
148148

@@ -152,9 +152,10 @@ bool PPPClass::pppDetachBus(void *bus_pointer) {
152152
return true;
153153
}
154154

155-
void PPPClass::setResetPin(int8_t rst, bool active_low) {
155+
void PPPClass::setResetPin(int8_t rst, bool active_low, uint32_t reset_delay) {
156156
_pin_rst = digitalPinToGPIONumber(rst);
157157
_pin_rst_act_low = active_low;
158+
_pin_rst_delay = reset_delay;
158159
}
159160

160161
bool PPPClass::setPins(int8_t tx, int8_t rx, int8_t rts, int8_t cts, esp_modem_flow_ctrl_t flow_ctrl) {
@@ -285,7 +286,7 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate) {
285286
}
286287
perimanSetPinBusExtraType(_pin_rst, "PPP_MODEM_RST");
287288
digitalWrite(_pin_rst, !_pin_rst_act_low);
288-
delay(200);
289+
delay(_pin_rst_delay);
289290
digitalWrite(_pin_rst, _pin_rst_act_low);
290291
delay(100);
291292
}

Diff for: libraries/PPP/src/PPP.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PPPClass : public NetworkInterface {
3636
bool setPins(int8_t tx, int8_t rx, int8_t rts = -1, int8_t cts = -1, esp_modem_flow_ctrl_t flow_ctrl = ESP_MODEM_FLOW_CONTROL_NONE);
3737

3838
// Using the reset pin of the module ensures that proper communication can be achieved
39-
void setResetPin(int8_t rst, bool active_low = true);
39+
void setResetPin(int8_t rst, bool active_low = true, uint32_t reset_delay = 200);
4040

4141
// Modem DCE APIs
4242
int RSSI() const;
@@ -94,6 +94,7 @@ class PPPClass : public NetworkInterface {
9494
esp_modem_flow_ctrl_t _flow_ctrl;
9595
int8_t _pin_rst;
9696
bool _pin_rst_act_low;
97+
uint32_t _pin_rst_delay;
9798
const char *_pin;
9899
const char *_apn;
99100
int _rx_buffer_size;

0 commit comments

Comments
 (0)