Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPP: Make modem reset delay configurable #9910

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions libraries/PPP/examples/PPP_Basic/PPP_Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#define PPP_MODEM_PIN "0000" // or NULL

// WaveShare SIM7600 HW Flow Control
#define PPP_MODEM_RST 25
#define PPP_MODEM_RST_LOW false //active HIGH
#define PPP_MODEM_TX 21
#define PPP_MODEM_RX 22
#define PPP_MODEM_RTS 26
#define PPP_MODEM_CTS 27
#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
#define PPP_MODEM_MODEL PPP_MODEM_SIM7600
#define PPP_MODEM_RST 25
#define PPP_MODEM_RST_LOW false //active HIGH
#define PPP_MODEM_RST_DELAY 200
#define PPP_MODEM_TX 21
#define PPP_MODEM_RX 22
#define PPP_MODEM_RTS 26
#define PPP_MODEM_CTS 27
#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
#define PPP_MODEM_MODEL PPP_MODEM_SIM7600

// SIM800 basic module with just TX,RX and RST
// #define PPP_MODEM_RST 0
Expand Down Expand Up @@ -60,7 +61,7 @@ void setup() {
// Configure the modem
PPP.setApn(PPP_MODEM_APN);
PPP.setPin(PPP_MODEM_PIN);
PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW);
PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY);
PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC);

Serial.println("Starting the modem. It might take a while!");
Expand Down
9 changes: 5 additions & 4 deletions libraries/PPP/src/PPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ esp_modem_dce_t *PPPClass::handle() const {
}

PPPClass::PPPClass()
: _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),
_apn(NULL), _rx_buffer_size(4096), _tx_buffer_size(512), _mode(ESP_MODEM_MODE_COMMAND), _uart_num(UART_NUM_1) {}
: _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_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) {}

PPPClass::~PPPClass() {}

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

void PPPClass::setResetPin(int8_t rst, bool active_low) {
void PPPClass::setResetPin(int8_t rst, bool active_low, uint32_t reset_delay) {
_pin_rst = digitalPinToGPIONumber(rst);
_pin_rst_act_low = active_low;
_pin_rst_delay = reset_delay;
}

bool PPPClass::setPins(int8_t tx, int8_t rx, int8_t rts, int8_t cts, esp_modem_flow_ctrl_t flow_ctrl) {
Expand Down Expand Up @@ -285,7 +286,7 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate) {
}
perimanSetPinBusExtraType(_pin_rst, "PPP_MODEM_RST");
digitalWrite(_pin_rst, !_pin_rst_act_low);
delay(200);
delay(_pin_rst_delay);
digitalWrite(_pin_rst, _pin_rst_act_low);
delay(100);
}
Expand Down
3 changes: 2 additions & 1 deletion libraries/PPP/src/PPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PPPClass : public NetworkInterface {
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);

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

// Modem DCE APIs
int RSSI() const;
Expand Down Expand Up @@ -94,6 +94,7 @@ class PPPClass : public NetworkInterface {
esp_modem_flow_ctrl_t _flow_ctrl;
int8_t _pin_rst;
bool _pin_rst_act_low;
uint32_t _pin_rst_delay;
const char *_pin;
const char *_apn;
int _rx_buffer_size;
Expand Down
Loading