Добрый день.
Нужна помощь с библиотекой LWIP, неделю воюю с ней и никак не могу забороть.
Суть в следующем. Есть плата с GSM-модемом SARA G300. Сам модем умеет только данные передавать, при этом встроенного TCP стека у него нет.
Надо установить TCP соединение с сервером и отправить пакет с данными.
В итоге получилось настроить модем и установить PPP соединение (PPP Over Serial Line). Собственно ниже лог установки соединения.
CODE
[016.160] PPP-DEBUG: lcp_init: xmit_accm=0 0 0 0
[016.160] PPP-DEBUG: pppMain: unit 0: Connecting
[016.170] PPP-DEBUG: pppStartCB: unit 0
[016.180] PPP-DEBUG: ppp_set_xaccm[0]: outACCM=0 0 0 0
[016.190] PPP-DEBUG: ppp_send_config[0]: outACCM=FF FF FF FF
[016.200] PPP-DEBUG: ppp_recv_config[0]: inACCM=0 0 0 0
[016.210] PPP-DEBUG: lcp_lowerup: asyncmap=0 0 0 0
[016.220] PPP-DEBUG: LCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
[016.230] PPP-DEBUG: auth_reset: 0
[016.240] PPP-DEBUG: lcp_addci: L opt=2 0
[016.250] PPP-DEBUG: lcp_addci: L opt=5 24F8B455
[016.260] PPP-DEBUG: lcp_addci: opt=7
[016.270] PPP-DEBUG: lcp_addci: opt=8
[016.280] PPP-DEBUG: pppWrite[0]: len=45
[016.290] PPP-DEBUG: fsm_sdata(LCP): Sent code 1,1,20.
[016.300] PPP-DEBUG: LCP: sending Configure-Request, id 1
[016.310] PPP-DEBUG: LCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
[017.190] PPP-DEBUG: pppInProc[0]: got 92 bytes
[017.190] PPP-DEBUG: pppInput[0]: LCP len=20
[017.200] PPP-DEBUG: fsm_input(LCP):1,1,20
[017.210] PPP-DEBUG: fsm_rconfreq(LCP): Rcvd id 1 state=6 (LS_REQSENT)
[017.220] PPP-DEBUG: lcp_reqci: rcvd ASYNCMAP=0 MAGICNUMBER (C5402872) PCOMPRES
[017.230] PPP-DEBUG: lcp_reqci: returning CONFACK.
[017.240] PPP-DEBUG: fsm_sdata(LCP): Sent code 2,1,20.
[017.250] PPP-DEBUG: pppInput[0]: LCP len=20
[017.260] PPP-DEBUG: fsm_input(LCP):2,1,20
[017.270] PPP-DEBUG: fsm_rconfack(LCP): Rcvd id 1 state=8 (LS_ACKSENT)
[017.280] PPP-DEBUG: lcp_acki: Ack
[017.290] PPP-DEBUG: ppp_send_config[0]: outACCM=0 0 0 0
[017.300] PPP-DEBUG: ppp_recv_config[0]: inACCM=0 0 0 0
[017.310] PPP-DEBUG: link_established: 0
[017.320] PPP-DEBUG: upap_lowerup: 0 s=0
[017.330] PPP-DEBUG: IPCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
[017.340] PPP-DEBUG: pppWrite[0]: len=30
[017.350] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,1,22.
[017.360] PPP-DEBUG: IPCP: sending Configure-Request, id 1
[017.370] PPP-DEBUG: IPCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
[023.310] PPP-DEBUG: pppInProc[0]: got 46 bytes
[023.310] PPP-DEBUG: pppInput[0]: LCP len=20
[023.320] PPP-DEBUG: fsm_input(LCP):1,1,20
[023.330] PPP-DEBUG: fsm_rconfreq(LCP): Rcvd id 1 state=9 (LS_OPENED)
[023.340] PPP-DEBUG: link_down: 0
[023.350] PPP-DEBUG: upap_lowerdown: 0 s=1
[023.360] PPP-DEBUG: IPCP: lowerdown state 6 (LS_REQSENT) -> 1 (LS_STARTING)
[023.370] PPP-DEBUG: IPCP: close reason=LCP down state 1 (LS_STARTING) -> 0 (LS
[023.380] PPP-DEBUG: pppLinkDown: unit 0
[023.390] PPP-DEBUG: pppMainWakeup: unit 0
[023.400] PPP-DEBUG: ppp_send_config[0]: outACCM=FF FF FF FF
[023.410] PPP-DEBUG: ppp_recv_config[0]: inACCM=0 0 0 0
[023.420] PPP-DEBUG: auth_reset: 0
[023.430] PPP-DEBUG: lcp_addci: L opt=2 0
[023.440] PPP-DEBUG: lcp_addci: L opt=5 FB82D078
[023.450] PPP-DEBUG: lcp_addci: opt=7
[023.460] PPP-DEBUG: lcp_addci: opt=8
[023.470] PPP-DEBUG: pppWrite[0]: len=45
[023.480] PPP-DEBUG: fsm_sdata(LCP): Sent code 1,2,20.
[023.490] PPP-DEBUG: LCP: sending Configure-Request, id 2
[023.500] PPP-DEBUG: lcp_reqci: rcvd ASYNCMAP=0 MAGICNUMBER (C5402872) PCOMPRES
[023.510] PPP-DEBUG: lcp_reqci: returning CONFACK.
[023.520] PPP-DEBUG: pppWrite[0]: len=45
[023.530] PPP-DEBUG: fsm_sdata(LCP): Sent code 2,1,20.
[024.430] PPP-DEBUG: pppInProc[0]: got 45 bytes
[024.430] PPP-DEBUG: pppInput[0]: LCP len=20
[024.440] PPP-DEBUG: fsm_input(LCP):2,2,20
[024.450] PPP-DEBUG: fsm_rconfack(LCP): Rcvd id 2 state=8 (LS_ACKSENT)
[024.460] PPP-DEBUG: lcp_acki: Ack
[024.470] PPP-DEBUG: ppp_send_config[0]: outACCM=0 0 0 0
[024.480] PPP-DEBUG: ppp_recv_config[0]: inACCM=0 0 0 0
[024.490] PPP-DEBUG: link_established: 0
[024.500] PPP-DEBUG: upap_lowerup: 0 s=0
[024.510] PPP-DEBUG: IPCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
[024.520] PPP-DEBUG: pppWrite[0]: len=30
[024.530] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,2,22.
[024.540] PPP-DEBUG: IPCP: sending Configure-Request, id 2
[024.550] PPP-DEBUG: IPCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
[025.450] PPP-DEBUG: pppInProc[0]: got 42 bytes
[025.450] PPP-DEBUG: pppInput[0]: IPCP len=10
[025.460] PPP-DEBUG: fsm_input(IPCP):1,1,10
[025.470] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=6 (LS_REQSENT)
[025.480] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[025.490] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[025.500] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[025.510] PPP-DEBUG: pppInput[0]: IPCP len=16
[025.520] PPP-DEBUG: fsm_input(IPCP):4,2,16
[025.530] PPP-DEBUG: fsm_rconfnakrej(IPCP): Rcvd id 2 state=8 (LS_ACKSENT)
[025.540] PPP-DEBUG: pppWrite[0]: len=18
[025.550] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,3,10.
[025.560] PPP-DEBUG: IPCP: sending Configure-Request, id 3
[026.470] PPP-DEBUG: pppInProc[0]: got 18 bytes
[026.470] PPP-DEBUG: pppInput[0]: IPCP len=10
[026.480] PPP-DEBUG: fsm_input(IPCP):3,3,10
[026.490] PPP-DEBUG: fsm_rconfnakrej(IPCP): Rcvd id 3 state=8 (LS_ACKSENT)
[026.500] PPP-DEBUG: local IP address 10.213.160.235
[026.510] PPP-DEBUG: pppWrite[0]: len=18
[026.520] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,4,10.
[026.530] PPP-DEBUG: IPCP: sending Configure-Request, id 4
[027.490] PPP-DEBUG: pppInProc[0]: got 18 bytes
[027.490] PPP-DEBUG: pppInput[0]: IPCP len=10
[027.500] PPP-DEBUG: fsm_input(IPCP):2,4,10
[027.510] PPP-DEBUG: fsm_rconfack(IPCP): Rcvd id 4 state=8 (LS_ACKSENT)
[027.520] PPP-DEBUG: np_up: 0 proto=21
[027.530] PPP-DEBUG: np_up: maxconnect=0 idle_time_limit=0
[027.540] PPP-DEBUG: ipcp: up
[027.550] PPP-DEBUG: sifup: unit 0: linkStatusCB=8037a89 errCode=0
[027.560] network: PPP connection was established
[027.570] network: ip_addr = 10.213.160.235
[027.580] network: netmask = 255.255.255.0
[027.590] network: dns1 = 0.0.0.0
[027.600] network: dns2 = 0.0.0.0
Судя по логу, вроде как PPP установлено.
Далее пытаюсь с помощью следующего кода установить TCP соединение с сервером (IP - в пример не настоящий):
Код
void NetworkOpenTCP(void)
{
struct ip_addr server_ip;
IP4_ADDR(&server_ip, 13,14,15,16);
tcpDesc = tcp_new();
if (tcpDesc)
{
tcp_err(tcpDesc, TCPError);
tcp_recv(tcpDesc, TCPReceive);
if (tcp_connect(tcpDesc, &server_ip, 9100, TCPConnected) == ERR_OK)
{
DBG("Establishing TCP connection with server\n");
}
}
}
static err_t TCPConnected(void *arg, struct tcp_pcb *pcb, err_t err)
{
LWIP_UNUSED_ARG(arg);
if (err == ERR_OK)
{
DBG("TCP Socket was opened\n");
}
else
{
DBG("TCP Socket was not opened\n");
}
return err;
}
В итоге получаю следующий лог:
CODE
680] LWIP-DEBUG: tcp_connect to port 20485
[027.680] PPP-DEBUG: pppifOutput[0]: proto=0x0021
[027.690] network: Establishing TCP connection with server
[028.510] PPP-DEBUG: pppInProc[0]: got 162 bytes
[028.510] PPP-DEBUG: pppInput[0]: IPCP len=10
[028.520] PPP-DEBUG: fsm_input(IPCP):1,1,10
[028.530] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=9 (LS_OPENED)
[028.540] PPP-DEBUG: ipcp: down
[028.550] PPP-DEBUG: np_down: 0 proto=21
[028.560] PPP-DEBUG: sifdown: unit 0: linkStatusCB=8037a89 errCode=0
[028.570] network: PPP connection was lost
[028.580] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,5,22.
[028.590] PPP-DEBUG: IPCP: sending Configure-Request, id 5
[028.600] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[028.610] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[028.620] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[028.630] PPP-DEBUG: pppInput[0]: IPCP len=10
[028.640] PPP-DEBUG: fsm_input(IPCP):1,1,10
[028.650] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=8 (LS_ACKSENT)
[028.660] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[028.670] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[028.680] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[028.690] PPP-DEBUG: pppInput[0]: IPCP len=10
[028.700] PPP-DEBUG: fsm_input(IPCP):1,1,10
[028.710] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=8 (LS_ACKSENT)
[028.720] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[028.730] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[028.740] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[028.750] PPP-DEBUG: pppInput[0]: IPCP len=10
[028.760] PPP-DEBUG: fsm_input(IPCP):1,1,10
[028.770] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=8 (LS_ACKSENT)
[028.780] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[028.790] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[028.800] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[028.810] PPP-DEBUG: pppInput[0]: IPCP len=10
[028.820] PPP-DEBUG: fsm_input(IPCP):1,1,10
[028.830] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 1 state=8 (LS_ACKSENT)
[028.840] PPP-DEBUG: ipcp_reqci: ADDR 10.213.160.235
[028.850] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[028.860] PPP-DEBUG: pppWrite[0]: len=18
[028.870] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,1,10.
[029.870] PPP-DEBUG: pppInProc[0]: got 18 bytes
[029.870] PPP-DEBUG: pppInput[0]: IPCP len=10
[029.880] PPP-DEBUG: fsm_input(IPCP):2,1,10
[029.890] PPP-DEBUG: fsm_rconfack(IPCP): Rcvd id 1 state=8 (LS_ACKSENT)
[034.910] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[034.910] PPP-DEBUG: pppWrite[0]: len=30
[034.920] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,5,22.
[034.930] PPP-DEBUG: IPCP: sending Configure-Request, id 5
[034.970] PPP-DEBUG: pppInProc[0]: got 30 bytes
[034.970] PPP-DEBUG: pppInput[0]: IPCP len=22
[034.980] PPP-DEBUG: fsm_input(IPCP):1,5,22
[034.990] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 5 state=8 (LS_ACKSENT)
[b][b][035.000] PPP-DEBUG: ipcp_reqci: Reject ADDR 0.0.0.0
[035.010] PPP-DEBUG: ipcp_reqci: Rejecting DNS1 Request
[035.020] PPP-DEBUG: ipcp_reqci: Rejecting DNS2 Request
[035.030] PPP-DEBUG: ipcp_reqci: returning Configure-REJ
[035.040] PPP-DEBUG: pppWrite[0]: len=30
[/b][/b][035.050] PPP-DEBUG: fsm_sdata(IPCP): Sent code 4,5,22.
[035.990] PPP-DEBUG: pppInProc[0]: got 30 bytes
[035.990] PPP-DEBUG: pppInput[0]: IPCP len=22
[036.000] PPP-DEBUG: fsm_input(IPCP):4,5,22
[036.010] PPP-DEBUG: fsm_rconfnakrej(IPCP): Rcvd id 5 state=6 (LS_REQSENT)
[036.020] PPP-DEBUG: pppWrite[0]: len=22
[036.030] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,6,14.
[036.040] PPP-DEBUG: IPCP: sending Configure-Request, id 6
[037.010] PPP-DEBUG: pppInProc[0]: got 22 bytes
[037.010] PPP-DEBUG: pppInput[0]: IPCP len=14
[037.020] PPP-DEBUG: fsm_input(IPCP):1,6,14
[037.030] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 6 state=6 (LS_REQSENT)
[037.040] PPP-DEBUG: ipcp_reqci: Rejecting unknown CI type 1
[037.050] PPP-DEBUG: ipcp_reqci: returning Configure-REJ
[037.060] PPP-DEBUG: pppWrite[0]: len=22
[037.070] PPP-DEBUG: fsm_sdata(IPCP): Sent code 4,6,14.
[038.030] PPP-DEBUG: pppInProc[0]: got 22 bytes
[038.030] PPP-DEBUG: pppInput[0]: IPCP len=14
[038.040] PPP-DEBUG: fsm_input(IPCP):4,6,14
[038.050] PPP-DEBUG: fsm_rconfnakrej(IPCP): Rcvd id 6 state=6 (LS_REQSENT)
[038.060] PPP-DEBUG: pppWrite[0]: len=12
[038.070] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,7,4.
[038.080] PPP-DEBUG: IPCP: sending Configure-Request, id 7
[039.050] PPP-DEBUG: pppInProc[0]: got 12 bytes
[039.050] PPP-DEBUG: pppInput[0]: IPCP len=4
[039.060] PPP-DEBUG: fsm_input(IPCP):1,7,4
[039.070] PPP-DEBUG: fsm_rconfreq(IPCP): Rcvd id 7 state=6 (LS_REQSENT)
[039.080] PPP-DEBUG: ipcp_reqci: returning Configure-ACK
[039.090] PPP-DEBUG: pppWrite[0]: len=12
[039.100] PPP-DEBUG: fsm_sdata(IPCP): Sent code 2,7,4.
[044.150] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[044.150] PPP-DEBUG: pppWrite[0]: len=12
[044.160] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,7,4.
[044.170] PPP-DEBUG: IPCP: sending Configure-Request, id 7
[050.180] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[050.180] PPP-DEBUG: pppWrite[0]: len=12
[050.190] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,7,4.
[050.200] PPP-DEBUG: IPCP: sending Configure-Request, id 7
[056.210] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[056.210] PPP-DEBUG: pppWrite[0]: len=12
[056.220] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,7,4.
[056.230] PPP-DEBUG: IPCP: sending Configure-Request, id 7
[062.240] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[062.240] PPP-DEBUG: pppWrite[0]: len=12
....
[219.030] PPP-DEBUG: fsm_sdata(IPCP): Sent code 1,7,4.
[219.040] PPP-DEBUG: IPCP: sending Configure-Request, id 7
[225.050] PPP-DEBUG: IPCP: timeout resending Config-Request state=8 (LS_ACKSENT
[225.050] PPP-DEBUG: pppWrite[0]: len=12
дальше выделенная часть постоянно повторяется
В итоге соединение не устанавливается. В TCPConnected я не попадаю. Собственно нужна помощь, ну или хотя бы направление, куда/где смотреть.
Версия библиотеки LWIP 1.4.1.