@@ -96,14 +96,14 @@ static void _ppp_error_cb(esp_modem_terminal_error_t err){
96
96
// PPP Arduino Events Callback
97
97
void PPPClass::_onPppArduinoEvent (arduino_event_id_t event, arduino_event_info_t info){
98
98
log_v (" PPP Arduino Event %ld: %s" , event, Network.eventName (event));
99
- if (event == ARDUINO_EVENT_PPP_GOT_IP){
100
- if ((getStatusBits () & ESP_NETIF_CONNECTED_BIT) == 0 ){
101
- setStatusBits (ESP_NETIF_CONNECTED_BIT);
102
- arduino_event_t arduino_event;
103
- arduino_event.event_id = ARDUINO_EVENT_PPP_CONNECTED;
104
- Network.postEvent (&arduino_event);
105
- }
106
- } else
99
+ // if(event == ARDUINO_EVENT_PPP_GOT_IP){
100
+ // if((getStatusBits() & ESP_NETIF_CONNECTED_BIT) == 0){
101
+ // setStatusBits(ESP_NETIF_CONNECTED_BIT);
102
+ // arduino_event_t arduino_event;
103
+ // arduino_event.event_id = ARDUINO_EVENT_PPP_CONNECTED;
104
+ // Network.postEvent(&arduino_event);
105
+ // }
106
+ // } else
107
107
if (event == ARDUINO_EVENT_PPP_LOST_IP){
108
108
if ((getStatusBits () & ESP_NETIF_CONNECTED_BIT) != 0 ){
109
109
clearStatusBits (ESP_NETIF_CONNECTED_BIT);
@@ -115,15 +115,24 @@ void PPPClass::_onPppArduinoEvent(arduino_event_id_t event, arduino_event_info_t
115
115
}
116
116
117
117
// PPP Driver Events Callback
118
- void PPPClass::_onPppEvent (int32_t event_id , void * event_data){
119
- // arduino_event_t arduino_event;
120
- // arduino_event.event_id = ARDUINO_EVENT_MAX;
118
+ void PPPClass::_onPppEvent (int32_t event , void * event_data){
119
+ arduino_event_t arduino_event;
120
+ arduino_event.event_id = ARDUINO_EVENT_MAX;
121
121
122
- log_v (" PPP Driver Event %ld: %s" , event_id, _ppp_event_name (event_id));
122
+ log_v (" PPP Driver Event %ld: %s" , event, _ppp_event_name (event));
123
+
124
+ if (event == NETIF_PPP_ERRORNONE){
125
+ if ((getStatusBits () & ESP_NETIF_CONNECTED_BIT) == 0 ){
126
+ setStatusBits (ESP_NETIF_CONNECTED_BIT);
127
+ arduino_event_t arduino_event;
128
+ arduino_event.event_id = ARDUINO_EVENT_PPP_CONNECTED;
129
+ Network.postEvent (&arduino_event);
130
+ }
131
+ }
123
132
124
- // if(arduino_event.event_id < ARDUINO_EVENT_MAX){
125
- // Network.postEvent(&arduino_event);
126
- // }
133
+ if (arduino_event.event_id < ARDUINO_EVENT_MAX){
134
+ Network.postEvent (&arduino_event);
135
+ }
127
136
}
128
137
129
138
esp_modem_dce_t * PPPClass::handle () const {
@@ -291,11 +300,11 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate){
291
300
if (_pin_rst >= 0 ){
292
301
// wait to be able to talk to the modem
293
302
log_v (" Waiting for response from the modem" );
294
- while (esp_modem_sync (_dce) != ESP_OK && trys < 50 ){
303
+ while (esp_modem_sync (_dce) != ESP_OK && trys < 100 ){
295
304
trys++;
296
305
delay (500 );
297
306
}
298
- if (trys >= 50 ){
307
+ if (trys >= 100 ){
299
308
log_e (" Failed to wait for communication" );
300
309
goto err;
301
310
}
@@ -375,21 +384,26 @@ void PPPClass::end(void)
375
384
_dce = NULL ;
376
385
}
377
386
387
+ int8_t pin = -1 ;
378
388
if (_pin_tx != -1 ){
379
- perimanClearPinBus ( _pin_tx) ;
389
+ pin = _pin_tx;
380
390
_pin_tx = -1 ;
391
+ perimanClearPinBus (pin);
381
392
}
382
393
if (_pin_rx != -1 ){
383
- perimanClearPinBus ( _pin_rx) ;
394
+ pin = _pin_rx;
384
395
_pin_rx = -1 ;
396
+ perimanClearPinBus (pin);
385
397
}
386
398
if (_pin_rts != -1 ){
387
- perimanClearPinBus ( _pin_rts) ;
399
+ pin = _pin_rts;
388
400
_pin_rts = -1 ;
401
+ perimanClearPinBus (pin);
389
402
}
390
403
if (_pin_cts != -1 ){
391
- perimanClearPinBus ( _pin_cts) ;
404
+ pin = _pin_cts;
392
405
_pin_cts = -1 ;
406
+ perimanClearPinBus (pin);
393
407
}
394
408
395
409
_mode = ESP_MODEM_MODE_COMMAND;
0 commit comments