jonathandreyer / esp32-sim7000

2 stars 1 forks source link

can this work with sim7020? #1

Open terryding77 opened 2 years ago

terryding77 commented 2 years ago

By searching pppos support, I find your issue in esp-idf project, and I meet some similar problem in my code.

With the code in official pppos example

I got the output like this.

D (1495) sim800: get module name ok
D (1505) sim800: get imei number ok
D (1515) sim800: get imsi number ok
D (1525) sim800: get network operator ok
D (1535) dce_service: set flow control ok
D (1555) dce_service: save settings ok
I (1555) pppos_example: Module: SIM7020G
I (1555) pppos_example: Operator: "46000"
I (1555) pppos_example: IMEI: 861518040203498
I (1555) pppos_example: IMSI: 460044812403174
D (1575) sim800: inquire signal quality ok
I (1575) pppos_example: rssi: 20, ber: 0
D (1585) sim800: inquire battery status ok
I (1585) pppos_example: Battery voltage: 0 mV
D (1605) sim800: enter ppp mode ok
D (1705) event: running post ESP_MODEM_EVENT:0 with handler 0x400d9d6c and context 0x3ffbd990 on loop 0x3ffbc91c
0x400d9d6c: modem_event_handler at /home/terry/esp/demo/pppos/main/pppos_client_main.c:113

I (1705) pppos_example: Modem PPP Started
D (1705) event: running post ESP_MODEM_EVENT:0 with handler 0x400e0940 and context 0x3ffbef88 on loop 0x3ffbc91c
0x400e0940: esp_netif_action_start at /home/terry/esp/esp-idf/components/esp_netif/esp_netif_handlers.c:32

D (1715) esp_netif_handlers: esp_netif action has started with netif0x3ffbd9b0 from event_id=0
D (1725) esp-netif_lwip-ppp: esp_netif_start_ppp: Starting PPP connection: 0x3ffbdce0
D (1735) esp-netif_lwip-ppp: Phase Start
D (1745) event: running post NETIF_PPP_STATUS:259 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

D (1745) esp-netif_lwip-ppp: Phase Establish
I (1755) pppos_example: PPP state changed event 259
D (1765) event: running post NETIF_PPP_STATUS:259 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (1765) esp_netif_lwip: check: remote, if=0x3ffbd9b0 fn=0x400e1d20
0x400e1d20: esp_netif_update_default_netif_lwip at /home/terry/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:189

D (1775) event: running post NETIF_PPP_STATUS:262 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

D (1785) esp_netif_lwip: esp_netif_update_default_netif_lwip 0x3ffbd9b0
I (1795) pppos_example: PPP state changed event 262
V (1795) esp_netif_objects: esp_netif_next_unsafe 0x0
D (1805) event: running post NETIF_PPP_STATUS:262 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

V (1815) esp_netif_objects: esp_netif_next_unsafe 0x3ffbd9b0
V (1825) esp_netif_lwip: esp_netif_is_netif_up esp_netif:0x3ffbd9b0
D (1835) esp_netif_lwip: call api in lwip: ret=0x0, give sem
D (1845) esp-netif_lwip-ppp: Phase Authenticate
D (1845) event: running post NETIF_PPP_STATUS:263 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

D (1855) esp-netif_lwip-ppp: Phase Network
I (1855) pppos_example: PPP state changed event 263
D (1865) event: running post NETIF_PPP_STATUS:263 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (1885) event: running post NETIF_PPP_STATUS:265 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

I (1895) pppos_example: PPP state changed event 265
D (1905) event: running post NETIF_PPP_STATUS:265 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (61875) esp-netif_lwip-ppp: Phase Terminate
D (61875) event: running post NETIF_PPP_STATUS:267 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

D (61875) esp-netif_lwip-ppp: Phase Establish
I (61875) pppos_example: PPP state changed event 267
D (61885) event: running post NETIF_PPP_STATUS:267 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (61905) event: running post NETIF_PPP_STATUS:262 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

I (61915) pppos_example: PPP state changed event 262
D (61925) event: running post NETIF_PPP_STATUS:262 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (73895) esp-netif_lwip-ppp: Phase Disconnect
D (73895) event: running post NETIF_PPP_STATUS:268 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

D (73895) esp-netif_lwip-ppp: Phase Dead
I (73895) pppos_example: PPP state changed event 268
D (73905) event: running post NETIF_PPP_STATUS:268 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

I (73915) esp-netif_lwip-ppp: Connection lost
D (73925) event: running post NETIF_PPP_STATUS:256 with handler 0x400d9bf0 and context 0x3ffbba1c on loop 0x3ffbaa98
0x400d9bf0: on_ppp_changed at /home/terry/esp/demo/pppos/main/pppos_client_main.c:172

I (73945) pppos_example: PPP state changed event 256
D (73945) event: running post NETIF_PPP_STATUS:256 with handler 0x400dded4 and context 0x3ffb5fa8 on loop 0x3ffbaa98
0x400dded4: on_ppp_changed at /home/terry/esp/demo/pppos/components/modem/src/esp_modem_netif.c:31

D (73955) event: running post IP_EVENT:6 with handler 0x400d9dc8 and context 0x3ffbb9e8 on loop 0x3ffbaa98
0x400d9dc8: on_ip_event at /home/terry/esp/demo/pppos/main/pppos_client_main.c:184

D (73965) pppos_example: IP event! 6
I (73975) pppos_example: Modem Disconnect from PPP Server
D (73975) event: running post IP_EVENT:6 with handler 0x400e0ac4 and context 0x3ffbf018 on loop 0x3ffbaa98
0x400e0ac4: esp_netif_action_disconnected at /home/terry/esp/esp-idf/components/esp_netif/esp_netif_handlers.c:91

D (73985) esp_netif_handlers: esp_netif action disconnected with netif0x3ffbd9b0 from event_id=6
D (73995) esp_netif_lwip: check: remote, if=0x3ffbd9b0 fn=0x400e16a8
0x400e16a8: esp_netif_down_api at /home/terry/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:1278

D (74005) esp_netif_lwip: esp_netif_down_api esp_netif:0x3ffbd9b0
D (74005) esp_netif_lwip: check: local, if=0x3ffbd9b0 fn=0x400e1d20
0x400e1d20: esp_netif_update_default_netif_lwip at /home/terry/esp/esp-idf/components/esp_netif/lwip/esp_netif_lwip.c:189

D (74015) esp_netif_lwip: esp_netif_update_default_netif_lwip 0x3ffbd9b0
V (74025) esp_netif_objects: esp_netif_next_unsafe 0x0
V (74025) esp_netif_lwip: esp_netif_is_netif_up esp_netif:0x3ffbd9b0
V (74035) esp_netif_objects: esp_netif_next_unsafe 0x3ffbd9b0
D (74035) esp_netif_lwip: call api in lwip: ret=0x0, give sem

with your project code (I try to reformat code with idf project structure)

I got the output like this

D (468) esp-modem: flow control is DISABLE
D (478) pppos-example: Device SIM800 is init()
D (478) sim800: start power-up SIM800 module
D (488) sim800: launch STATUS reading
D (988) sim800: .
D (1018) sim800: STATUS is 1, inc is 1
D (1018) sim800: End of loop!
D (3018) sim800: STATUS of module is OK
D (3018) pppos-example: Device SIM800 is power_up()
D (3018) sim800: start opening of SIM800 module
D (3018) sim800: try to sync with the module
D (4018) sim800: .
D (4018) esp-modem: modem<<: AT
D (4068) esp-modem: modem>>: OK

D (4068) dce-service: Default handling: OK

D (4068) dce-service: 0x3ffbceb4   4f 4b 0d 0a                                       |OK..|
D (4068) dce-service: sync ok
D (4068) sim800: SYNC is 1, inc is 1
D (4078) sim800: SYNC test is OK
D (4078) esp-modem: modem<<: AT
D (4168) esp-modem: modem>>: OK

D (4168) dce-service: Default handling: OK

D (4168) dce-service: 0x3ffbceb4   4f 4b 0d 0a                                       |OK..|
D (4168) dce-service: sync ok
D (4168) esp-modem: modem<<: ATE0
D (4268) esp-modem: modem>>: OK

D (4268) dce-service: Default handling: OK

D (4268) dce-service: 0x3ffbceb4   4f 4b 0d 0a                                       |OK..|
D (4268) dce-service: disable echo ok
D (4268) esp-modem: modem<<: AT+CGMM
D (4368) esp-modem: modem>>: SIM7020C

D (4468) esp-modem: modem>>: OK

D (4468) sim800: get module name ok
D (4468) esp-modem: modem<<: AT+CGSN
D (4568) esp-modem: modem>>: 868334038986067

D (4668) esp-modem: modem>>: OK

D (4668) sim800: get imei number ok
D (4668) esp-modem: modem<<: AT+CIMI
D (4768) esp-modem: modem>>: 460081087908212

D (4868) esp-modem: modem>>: OK

D (4868) sim800: get imsi number ok
D (4868) esp-modem: modem<<: AT+COPS?
D (4968) esp-modem: modem>>: +COPS: 0,2,"46000",9

D (4968) sim800: Handling sim800_handle_cops: +COPS: 0,2,"46000",9

D (4968) sim800: Handling sim800_handle_cops #3: +COPS: 0,2,"46000",9

D (4968) sim800: Handling sim800_handle_cops #4: line has been free
D (4978) sim800: Handling sim800_handle_cops #5: 0
D (5078) esp-modem: modem>>: OK

D (5078) sim800: Handling sim800_handle_cops: OK

D (5078) sim800: Handling sim800_handle_cops #1: OK

D (5078) sim800: get network operator ok
D (5078) pppos-example: Device SIM800 is open()
D (5088) esp-modem: modem<<: AT+IFC=0,0
D (5178) esp-modem: modem>>: OK

D (5178) dce-service: Default handling: OK

D (5178) dce-service: 0x3ffbceb4   4f 4b 0d 0a                                       |OK..|
D (5178) dce-service: set flow control ok
D (5178) esp-modem: modem<<: AT&W
D (5278) esp-modem: modem>>: OK

D (5278) dce-service: Default handling: OK

D (5278) dce-service: 0x3ffbceb4   4f 4b 0d 0a                                       |OK..|
D (5278) dce-service: save settings ok
I (5278) pppos-example: Module: SIM7020C
I (5288) pppos-example: Operator: "46000"
I (5288) pppos-example: IMEI: 868334038986067
I (5298) pppos-example: IMSI: 460081087908212
D (5298) esp-modem: modem<<: AT+CSQ
D (5378) esp-modem: modem>>: +CSQ: 21,0

D (5478) esp-modem: modem>>: OK

D (5478) sim800: inquire signal quality ok
I (5478) pppos-example: rssi: 21, ber: 0
D (5478) esp-modem: modem<<: AT+CBC
D (5578) esp-modem: modem>>: +CBC: 84,3372

D (5678) esp-modem: modem>>: OK

D (5678) sim800: inquire battery status ok
I (5678) pppos-example: Battery voltage: 0 mV
D (5678) esp-modem-netif: esp_modem_set_rx_cb set
D (5678) esp-modem: callback receive_cb set
D (5688) esp-modem: modem<<: ATD*99#
D (5778) esp-modem: modem>>: CONNECT

D (5778) sim800: enter ppp mode ok
I (5778) pppos-example: Modem PPP Started
D (5828) esp-modem: handle_uart_data #1, len 99
I (5828) esp-modem: 0x3ffbceb4   7e ff 7d 23 c0 21 7d 21  7d 21 7d 20 7d 38 7d 21  |~.}#.!}!}!} }8}!|
I (5828) esp-modem: 0x3ffbcec4   7d 24 7d 26 40 7d 25 7d  26 7d 2f e7 6a b0 7d 22  |}$}&@}%}&}/.j.}"|
I (5838) esp-modem: 0x3ffbced4   7d 26 7d 20 7d 20 7d 20  7d 20 7d 27 7d 22 7d 28  |}&} } } } }'}"}(|
I (5848) esp-modem: 0x3ffbcee4   7d 22 9a 7d 35 7e 7e ff  7d 23 c0 21 7d 22 7d 21  |}".}5~~.}#.!}"}!|
I (5858) esp-modem: 0x3ffbcef4   7d 20 7d 34 7d 22 7d 26  7d 20 7d 20 7d 20 7d 20  |} }4}"}&} } } } |
I (5868) esp-modem: 0x3ffbcf04   7d 25 7d 26 f8 a4 c8 bb  7d 27 7d 22 7d 28 7d 22  |}%}&....}'}"}(}"|
I (5878) esp-modem: 0x3ffbcf14   48 a3 7e                                          |H.~|
D (5888) esp-modem-netif: modem_netif_receive_cb called
D (5888) esp-modem-netif: modem_netif_receive_cb context setup
D (5898) esp-modem-netif: modem_netif_receive_cb call esp_netif_receive
D (5898) esp-modem: handle_uart_data #3
D (5908) esp-modem: handle_uart_data #4
D (5958) esp-modem: handle_uart_data #1, len 9
I (5958) esp-modem: 0x3ffbceb4   0d 0a 45 52 52 4f 52 0d  0a                       |..ERROR..|
D (5958) esp-modem-netif: modem_netif_receive_cb called
D (5958) esp-modem-netif: modem_netif_receive_cb context setup
D (5968) esp-modem-netif: modem_netif_receive_cb call esp_netif_receive
D (5978) esp-modem: handle_uart_data #3
D (5978) esp-modem: handle_uart_data #4
I (77898) esp-netif_lwip-ppp: Connection lost
D (77898) pppos-example: IP event! 6
I (77898) pppos-example: Modem Disconnect from PPP Server
terryding77 commented 2 years ago

I never get the ip from ppp dialog, and I find write PDP_CONTEXT s command not work for my sim7020; MODEM_CHECK(dce->define_pdp_context(dce, 1, "IP", CONFIG_EXAMPLE_COMPONENT_MODEM_APN) == ESP_OK, "set MODEM APN failed", err); but it works if I read the CONTEXT:

command
AT+CGDCONT?

got answer
+CGDCONT: 1,"IP","CMNBIOT","100.121.10.100",0,0,0,,,,0,,0,,0

so I comment the PDP_CONTEXT function in above code.