ESP32 and PPP not working
I am trying to raise a PPP connection with a modem (two different ones actually, an EG91 and a BG95)
Once the modem is registered into the network, I start the data call with AT commands, and after the "CONNECT" string is received, do the following code in MicroPython:
my_log.info("Starting Data Call", fn="main")
modem.startDataCall()
my_log.info("Creating PPP object", fn="main")
sleep(5)
ppp = network.PPP(modem.getSerialPort())
ppp.active(True)
ppp.connect(authmode=ppp.AUTH_CHAP,username ="", password="")
I am monitoring the PPP frames in the serial line, and I can see the following:
- the ESP32 sends the first ConfRequest
- the moddem replies with the ACK and its own ConfRequest
- but the ESP32 does not reply anything for about 6 seconds, and in the meantime the modem sends new ConfRequests
- after 6 seconds, the ESP32 seems to process all the requests and ACK them, but this causes abnormal transitions from the PPP FSM.
- The modem replies the ConfRequest, but again nothing happens for another 6 seconds.
- The modem times out every second, and sends a new ConfRequest that causes the same problem again and again, until one or both of the parts give up
I enabled LWIP and PPP logs. It seems to me the problem is the UART object is not passing the data received in the serial port to the PPP object straight away, but only after a timeout. I played a bit with some of the hardcoded values (like FSMTIMEOUT), that seems to confirm the guess.
Unfortunately I am unable to find what mechanism will pass the data from the UART object ot the PPP object - all I can see is there is a task created that waits to be notified, but cannot find what's sending such notification.
I am using latest micropython version (master branch, commit 2111ca0b8fdcbef6177a8d37fde53085de2a798a) , and building with ESP-IDF 4.4
any help would be appreciated, I can supply the logs (or enable more segments and capture more if it helps)
ESP32: network.PPP on UART not working, interrupt-issue?
Hello,
I'm trying to use network.PPP with a GSM modem, but it does not work.
My code:
[.... initalization, APN setup etc.]
modem_uart.write('AT+CGDATA="PPP",1\r\n')
time.sleep(1)
print(modem_uart.readline()) => b'\r\n'
print(modem_uart.readline()) => b'CONNECT\r\n'
ppp = network.PPP(modem_uart)
ppp.active(True)
[waiting a few minutes, checking in the meantime
>>> ppp.ifconfig()
('0.0.0.0', '0.0.0.0', '255.255.255.255', '0.0.0.0')
>>> ppp.status()
>>> ppp.isconnected()
False
Then I checked if data is received from the modem, still in the rx buffer:
>>> modem_uart.any()
215
>>> modem_uart.read()
b'~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~~\xff}#\xc0!}!}!} }2}"}&} }*} } }#}$\xc0#}\'}"}(}"U\x83~\r\nNO CARRIER\r\n'
It seems the modem tries to establish connection, sending handshakes every few seconds, but network.PPP does not even pick up data from the UART. How is that supposed to work, I assumed it would be interrupt-driven in the background?
But I'm also not able to figure out how to get interrupts for received data on the UART manually, is it a feature missing on the ESP32, is that maybe causing the PPP issue?
>>> UART.irq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'UART' has no attribute 'irq'
>>> modem_uart.irq
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'UART' object has no attribute 'irq'
I'm using esp32-idf4-20210202-v1.14.bin with a SIM800L GPRS modem.
According to https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/uart.html#uart-api-using-interrupts the ESP32 should support interrupts on the UART.
If interrupts are not supported and that is the issue, is there a way to manually feed the received data from the UART into ppp, from my main loop with select()?
Thanks
Sebastian