Hi, I am trying to set up a working Internet access via a SIM7000e GSM/LTE module. The LTE connection itself I got working using the GSM sample application. A ping for example is working perfectly (as long as I am addressing an IP directly).
Now I wanted to get the HTTP GET example working. For this however, I need a working DNS. I tried to use the DNS resolve example to figure out how this all works, but sadly it is not working correctly for me for some reason I do not fully understand.
If I understand the feedback I am getting from my program correctly, my DNS requests are being sent out without a problem, but the reply does not seem to be working correctly or not to be interpreted correctly. I am seeing some sort of reply for my requests, but they are always from a previous request and not from the current one (I made my program so that it sends different requests at different points in time). The callback function from the DNS resolve example does not seem to be called at all.
That is probably because of the fact that the replies that I am seeing are showing "Invalid FCS" errors, so they are not interpreted correctly. I however do not understand why that is the case.
This is the output I am able to get out of my program:
[00:02:00.402,000] <inf> sample_gsm_ppp: Starting DNS resolve sample
[00:02:00.420,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:02:00.420,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:02:00.441,000] <dbg> net_conn.conn_register_debug: (main): local 0.0.0.0/56835 cb 0x800c4f5 ud 0x20001430
[00:02:00.464,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:02:00.479,000] <dbg> net_l2_ppp.0x2000d4d0
45 00 00 43 00 00 00 00 40 11 95 0f 64 6e 71 1d |E..C.... @...dnq.
08 08 08 08 de 03 00 35 00 2f 49 f9 6f df 01 00 |.......5 ./I.o...
00 01 00 00 00 00 00 00 03 77 77 77 0d 7a 65 70 |........ .www.zep
68 79 72 70 72 6f 6a 65 63 74 03 6f 72 67 00 00 |hyrproje ct.org..
01 00 01 |...
[00:02:00.581,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:02:00.595,000] <dbg> net_ppp.0x2000d4d0
45 00 00 43 00 00 00 00 40 11 95 0f 64 6e 71 1d |E..C.... @...dnq.
08 08 08 08 de 03 00 35 00 2f 49 f9 6f df 01 00 |.......5 ./I.o...
00 01 00 00 00 00 00 00 03 77 77 77 0d 7a 65 70 |........ .www.zep
68 79 72 70 72 6f 6a 65 63 74 03 6f 72 67 00 00 |hyrproje ct.org..
01 00 01 |...
[00:02:00.705,000] <dbg> sample_gsm_ppp.do_ipv4_lookup: DNS id 28639
[00:02:01.202,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:02:01.220,000] <dbg> net_ppp.ppp_input_byte: Address byte (0xff) start
[00:02:01.237,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state ADDRESS (1) => DATA (2)
[00:02:01.260,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
uart:~$ Preparing HTTP GET request for http://google.com:80/
[00:02:15.725,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:02:15.725,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:02:15.746,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:02:15.767,000] <dbg> net_conn.conn_register_debug: (main): local 0.0.0.0/56835 cb 0x800c4f5 ud 0x20001430
[00:02:15.790,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:02:15.805,000] <dbg> net_l2_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 21 c0 06 59 01 00 |.......5 .$!..Y..
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:02:15.889,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:02:15.903,000] <dbg> net_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 21 c0 06 59 01 00 |.......5 .$!..Y..
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:02:16.208,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:02:16.232,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:02:16.263,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:02:16.290,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:02:16.304,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:02:16.334,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:02:16.364,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:02:16.378,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:02:16.407,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:02:16.439,000] <dbg> net_ppp.ppp_input_byte: End of pkt (0x7e)
[00:02:16.454,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state DATA (2) => ADDRESS (1)
[00:02:16.476,000] <dbg> net_ppp.net_pkt_hexdump: recv ppp
[00:02:16.490,000] <dbg> net_ppp.0x2000d0d4
ff 03 00 21 45 00 00 53 62 ae 00 00 75 11 fd 50 |...!E..S b...u..P
08 08 08 08 64 6e 71 1d 00 35 de 03 00 3f c0 7f |....dnq. .5...?..
6f df 81 80 00 01 00 01 00 00 00 00 03 77 77 77 |o....... .....www
0d 7a 65 70 68 79 72 70 72 6f 6a 65 63 74 03 6f |.zephyrp roject.o
72 |r
[00:02:16.590,000] <dbg> net_ppp.ppp_check_fcs: Invalid FCS (0x5cac)
[00:02:16.606,000] <dbg> net_ppp.ppp_input_byte: Invalid (0x23) byte, expecting Address
[00:02:16.625,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state ADDRESS (1) => START (0)
[00:02:16.647,000] <dbg> net_ppp.ppp_input_byte: Sync byte (0x7e) start
[00:02:16.664,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state START (0) => ADDRESS (1)
[00:02:16.686,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:02:16.704,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:03:56.290,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:03:56.313,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:03:56.344,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:03:56.371,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:03:56.385,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:03:56.415,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:03:56.445,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:03:56.459,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:03:56.488,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:05:36.371,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:05:36.395,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:05:36.425,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:05:36.452,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:05:36.466,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:05:36.496,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:05:36.526,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:05:36.540,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:05:36.569,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:07:15.790,000] <dbg> net_sock_addr.dns_resolve_cb: (sysworkq): dns status: -101
uart:~$ getaddrinfo status: -101
Unable to resolve address, quitting
[00:07:16.452,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:07:16.452,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:07:16.476,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:07:16.507,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:07:16.533,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:07:16.547,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:07:16.577,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:07:16.608,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:07:16.622,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:07:16.651,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
uart:~$ Preparing HTTP GET request for http://google.com:80/
[00:07:30.819,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:07:30.819,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:07:30.840,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:07:30.861,000] <dbg> net_conn.conn_register_debug: (main): local 0.0.0.0/56835 cb 0x800c4f5 ud 0x20001430
[00:07:30.884,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:07:30.898,000] <dbg> net_l2_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 b8 c1 6f 57 01 00 |.......5 .$..oW..
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:07:30.983,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:07:30.997,000] <dbg> net_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 b8 c1 6f 57 01 00 |.......5 .$..oW..
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:07:32.646,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:07:32.664,000] <dbg> net_ppp.ppp_input_byte: Address byte (0xff) start
[00:07:32.681,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state ADDRESS (1) => DATA (2)
[00:07:32.703,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:08:56.533,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:08:56.557,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:08:56.588,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:08:56.614,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:08:56.629,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:08:56.659,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:08:56.689,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:08:56.703,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:08:56.732,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:10:36.614,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:10:36.638,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:10:36.669,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:10:36.696,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:10:36.710,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:10:36.740,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:10:36.770,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:10:36.784,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:10:36.813,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:12:16.696,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:12:16.719,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:12:16.750,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:12:16.777,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:12:16.791,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:12:16.821,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:12:16.851,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:12:16.865,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:12:16.894,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:12:30.884,000] <dbg> net_sock_addr.dns_resolve_cb: (sysworkq): dns status: -101
uart:~$ getaddrinfo status: -101
Unable to resolve address, quitting
Preparing HTTP GET request for http://google.com:80/
[00:12:45.912,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:12:45.912,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:12:45.933,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:12:45.954,000] <dbg> net_conn.conn_register_debug: (main): local 0.0.0.0/56835 cb 0x800c4f5 ud 0x20001430
[00:12:45.977,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:12:45.992,000] <dbg> net_l2_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 50 02 d8 16 01 00 |.......5 .$P.....
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:12:46.076,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:12:46.090,000] <dbg> net_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 50 02 d8 16 01 00 |.......5 .$P.....
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:12:47.729,000] <dbg> net_ppp.ppp_input_byte: End of pkt (0x7e)
[00:12:47.744,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state DATA (2) => ADDRESS (1)
[00:12:47.767,000] <dbg> net_ppp.net_pkt_hexdump: recv ppp
[00:12:47.781,000] <dbg> net_ppp.0x2000d0d4
ff 03 00 21 45 00 00 48 16 67 00 00 76 11 48 a3 |...!E..H .g..v.H.
08 08 08 08 64 6e 71 1d 00 35 de 03 00 34 ca 8a |....dnq. .5...4..
6f 57 81 80 00 01 00 01 00 00 00 00 06 67 6f 6f |oW...... .....goo
67 6c 65 03 63 6f 6d 00 00 01 00 01 |gle.com. ....
[00:12:47.863,000] <dbg> net_ppp.ppp_check_fcs: Invalid FCS (0x1223)
[00:12:47.878,000] <dbg> net_ppp.ppp_input_byte: Address byte (0xff) start
[00:12:47.895,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state ADDRESS (1) => DATA (2)
[00:12:47.918,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:12:47.936,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:13:56.777,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:13:56.801,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:13:56.831,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:13:56.858,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:13:56.872,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:13:56.902,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:13:56.932,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:13:56.946,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:13:56.975,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:15:36.858,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:15:36.882,000] <dbg> net_l2_ppp.fsm_send_configure_req: (sysworkq): [IPV6CP/0x20002c80] Sending Configure-Req (1) id 1 to peer while in REQUEST_SENT (6)
[00:15:36.913,000] <dbg> net_l2_ppp.ppp_send_pkt: (sysworkq): [IPV6CP/0x20002c80] Sending 16 bytes pkt 0x2000d4d0 (options len 10)
[00:15:36.939,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:15:36.953,000] <dbg> net_l2_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:15:36.983,000] <dbg> net_l2_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:15:37.014,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:15:37.028,000] <dbg> net_ppp.0x2000d4d0
80 57 01 01 00 0e |.W....
[00:15:37.057,000] <dbg> net_ppp.0x2000d4d0
01 0a 00 00 5e ff fe 00 53 34 |....^... S4
[00:17:16.939,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Current state REQUEST_SENT (6)
[00:17:16.963,000] <dbg> net_l2_ppp.ppp_fsm_timeout: (sysworkq): [IPV6CP/0x20002c80] Configure-Req retransmit limit 0 reached
[00:17:16.988,000] <dbg> net_l2_ppp.ppp_change_state_debug: (sysworkq): [IPV6CP/0x20002c80] state REQUEST_SENT (6) => STOPPED (3) (ppp_fsm_timeout():112)
[00:17:45.977,000] <dbg> net_sock_addr.dns_resolve_cb: (sysworkq): dns status: -101
uart:~$ getaddrinfo status: -101
Unable to resolve address, quitting
Preparing HTTP GET request for http://google.com:80/
[00:18:01.006,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:18:01.006,000] <dbg> net_conn.net_conn_unregister: (main): Connection handler 0x20005a18 removed
[00:18:01.027,000] <dbg> net_conn.conn_register_debug: (main): [0x20005a18/17/1/0x15] remote -/0
[00:18:01.048,000] <dbg> net_conn.conn_register_debug: (main): local 0.0.0.0/56835 cb 0x800c4f5 ud 0x20001430
[00:18:01.071,000] <dbg> net_l2_ppp.net_pkt_hexdump: send L2
[00:18:01.085,000] <dbg> net_l2_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 e7 5e 40 ba 01 00 |.......5 .$.^@...
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:18:01.170,000] <dbg> net_ppp.net_pkt_hexdump: send ppp
[00:18:01.184,000] <dbg> net_ppp.0x2000d4d0
45 00 00 38 00 00 00 00 40 11 95 1a 64 6e 71 1d |E..8.... @...dnq.
08 08 08 08 de 03 00 35 00 24 e7 5e 40 ba 01 00 |.......5 .$.^@...
00 01 00 00 00 00 00 00 06 67 6f 6f 67 6c 65 03 |........ .google.
63 6f 6d 00 00 01 00 01 |com.....
[00:18:02.898,000] <dbg> net_ppp.ppp_input_byte: End of pkt (0x7e)
[00:18:02.913,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state DATA (2) => ADDRESS (1)
[00:18:02.935,000] <dbg> net_ppp.net_pkt_hexdump: recv ppp
[00:18:02.949,000] <dbg> net_ppp.0x2000d0d4
ff 03 00 21 45 00 00 48 ee 08 00 00 36 11 b1 01 |...!E..H ....6...
08 08 08 08 64 6e 71 1d 00 35 de 03 00 34 62 4e |....dnq. .5...4bN
d8 16 81 80 00 01 00 01 00 00 00 00 06 67 6f 6f |........ .....goo
[00:18:03.014,000] <dbg> net_ppp.ppp_check_fcs: Invalid FCS (0x3c24)
[00:18:03.030,000] <dbg> net_ppp.ppp_input_byte: Address byte (0xff) start
[00:18:03.046,000] <dbg> net_ppp.ppp_change_state: (ppp_workq): [0x20002d88] state ADDRESS (1) => DATA (2)
[00:18:03.069,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
[00:18:03.087,000] <dbg> net_ppp.ppp_consume_ringbuf: Ringbuf 0x20002dbc is empty!
And this is my program code (which is basically a mashup of the three sample applications I mentioned above):
/*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <sys/printk.h>
// #include <shell/shell.h>
#include <drivers/uart.h>
#include <net/net_mgmt.h>
#include <net/net_event.h>
#include <net/net_conn_mgr.h>
#include <drivers/modem/gsm_ppp.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(sample_gsm_ppp, LOG_LEVEL_DBG);
/* DNS stuff */
#include <linker/sections.h>
#include <errno.h>
#include <stdio.h>
#include <net/net_core.h>
#include <net/net_if.h>
#include <net/net_mgmt.h>
#include <net/dns_resolve.h>
/* http get sample code */
#include <net/socket.h>
#include <kernel.h>
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
#include <net/tls_credentials.h>
#include "ca_certificate.h"
#endif
/* HTTP server to connect to */
#define HTTP_HOST "google.com"
// #define HTTP_HOST "193.99.144.80"
/* Port to connect to, as string */
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
#define HTTP_PORT "443"
#else
#define HTTP_PORT "80"
#endif
/* HTTP path to request */
#define HTTP_PATH "/"
#define SSTRLEN(s) (sizeof(s) - 1)
#define CHECK(r) { if (r == -1) { printf("Error: " #r "\n"); exit(1); } }
#define REQUEST "GET " HTTP_PATH " HTTP/1.0\r\nHost: " HTTP_HOST "\r\n\r\n"
static char response[1024];
/* end of http get sample code */
/* DNS defines */
#define DNS_TIMEOUT (SYS_FOREVER_MS)
/* end of DNS defines */
static const struct device *gsm_dev;
static struct net_mgmt_event_callback mgmt_cb;
static bool connected;
static bool starting = true;
/* DNS sample code*/
void dns_result_cb(enum dns_resolve_status status,
struct dns_addrinfo *info,
void *user_data)
{
printk("now entering dns result callback fcn\n");
char hr_addr[NET_IPV6_ADDR_LEN];
char *hr_family;
void *addr;
switch (status) {
case DNS_EAI_CANCELED:
LOG_INF("DNS query was canceled");
return;
case DNS_EAI_FAIL:
LOG_INF("DNS resolve failed");
return;
case DNS_EAI_NODATA:
LOG_INF("Cannot resolve address");
return;
case DNS_EAI_ALLDONE:
LOG_INF("DNS resolving finished");
return;
case DNS_EAI_INPROGRESS:
break;
default:
LOG_INF("DNS resolving error (%d)", status);
return;
}
if (!info) {
return;
}
if (info->ai_family == AF_INET) {
hr_family = "IPv4";
addr = &net_sin(&info->ai_addr)->sin_addr;
} else if (info->ai_family == AF_INET6) {
hr_family = "IPv6";
addr = &net_sin6(&info->ai_addr)->sin6_addr;
} else {
LOG_ERR("Invalid IP address family %d", info->ai_family);
return;
}
LOG_INF("%s %s address: %s", user_data ? (char *)user_data : "<null>",
hr_family,
log_strdup(net_addr_ntop(info->ai_family, addr,
hr_addr, sizeof(hr_addr))));
}
#if defined(CONFIG_NET_IPV4)
static void do_ipv4_lookup(void)
{
static const char *query = "www.zephyrproject.org";
static uint16_t dns_id;
int ret;
ret = dns_get_addr_info(query,
DNS_QUERY_TYPE_A,
&dns_id,
dns_result_cb,
(void *)query,
DNS_TIMEOUT);
if (ret < 0) {
LOG_ERR("Cannot resolve IPv4 address (%d)", ret);
return;
}
LOG_DBG("DNS id %u", dns_id);
}
static void setup_ipv4(struct net_if *iface)
{
ARG_UNUSED(iface);
do_ipv4_lookup();
}
#endif /* CONFIG_NET_IPV4 */
/* end of DNS sample code */
/* http get sample code */
void dump_addrinfo(const struct addrinfo *ai)
{
printf("addrinfo @%p: ai_family=%d, ai_socktype=%d, ai_protocol=%d, "
"sa_family=%d, sin_port=%x\n",
ai, ai->ai_family, ai->ai_socktype, ai->ai_protocol,
ai->ai_addr->sa_family,
((struct sockaddr_in *)ai->ai_addr)->sin_port);
}
void http_get_main(void){
static struct addrinfo hints;
struct addrinfo *res;
int st, sock;
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
tls_credential_add(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,
ca_certificate, sizeof(ca_certificate));
#endif
printf("Preparing HTTP GET request for http://" HTTP_HOST
":" HTTP_PORT HTTP_PATH "\n");
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
st = getaddrinfo(HTTP_HOST, HTTP_PORT, &hints, &res);
printf("getaddrinfo status: %d\n", st);
if (st != 0) {
printf("Unable to resolve address, quitting\n");
return;
}
#if 0
for (; res; res = res->ai_next) {
dump_addrinfo(res);
}
#endif
dump_addrinfo(res);
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
sock = socket(res->ai_family, res->ai_socktype, IPPROTO_TLS_1_2);
#else
sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
#endif
CHECK(sock);
printf("sock = %d\n", sock);
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
sec_tag_t sec_tag_opt[] = {
CA_CERTIFICATE_TAG,
};
CHECK(setsockopt(sock, SOL_TLS, TLS_SEC_TAG_LIST,
sec_tag_opt, sizeof(sec_tag_opt)));
CHECK(setsockopt(sock, SOL_TLS, TLS_HOSTNAME,
HTTP_HOST, sizeof(HTTP_HOST)))
#endif
CHECK(connect(sock, res->ai_addr, res->ai_addrlen));
CHECK(send(sock, REQUEST, SSTRLEN(REQUEST), 0));
printf("Response:\n\n");
while (1) {
int len = recv(sock, response, sizeof(response) - 1, 0);
if (len < 0) {
printf("Error reading response\n");
return;
}
if (len == 0) {
break;
}
response[len] = 0;
printf("%s", response);
}
printf("\n");
(void)close(sock);
}
/* end of http get sample code */
static void event_handler(struct net_mgmt_event_callback *cb,
uint32_t mgmt_event, struct net_if *iface)
{
if ((mgmt_event & (NET_EVENT_L4_CONNECTED
| NET_EVENT_L4_DISCONNECTED)) != mgmt_event) {
return;
}
starting = false;
if (mgmt_event == NET_EVENT_L4_CONNECTED) {
LOG_INF("Network connected");
connected = true;
return;
}
if (mgmt_event == NET_EVENT_L4_DISCONNECTED) {
LOG_INF("Network disconnected");
connected = false;
return;
}
}
int main(void)
{
const struct device *uart_dev =
DEVICE_DT_GET(DT_BUS(DT_INST(0, zephyr_gsm_ppp)));
gsm_dev = DEVICE_DT_GET(DT_INST(0, zephyr_gsm_ppp));
LOG_DBG("Board '%s' APN '%s' UART '%s' device %p (%s)",
CONFIG_BOARD, CONFIG_MODEM_GSM_APN,
DT_BUS_LABEL(DT_INST(0, zephyr_gsm_ppp)), uart_dev,
gsm_dev->name);
net_mgmt_init_event_callback(&mgmt_cb, event_handler,
NET_EVENT_L4_CONNECTED |
NET_EVENT_L4_DISCONNECTED);
net_mgmt_add_event_callback(&mgmt_cb);
k_sleep(K_MSEC(90000));
LOG_INF("Starting DNS resolve sample");
struct net_if *iface = net_if_get_default();
setup_ipv4(iface);
k_sleep(K_MSEC(15000));
http_get_main();
k_sleep(K_MSEC(15000));
http_get_main();
k_sleep(K_MSEC(15000));
http_get_main();
k_sleep(K_MSEC(15000));
http_get_main();
k_sleep(K_MSEC(15000));
setup_ipv4(iface);
return 0;
}