[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] LWIP+PPPos(GPRS)
From: |
bakmurat |
Subject: |
[lwip-users] LWIP+PPPos(GPRS) |
Date: |
Tue, 27 Mar 2018 06:52:44 -0700 (MST) |
*I am designing a gateway and on my ATSAME53N20 (Atmel studio 7 IDE) I have
to connect a 3G modem(Quactel UG95) using a serial port. I can communicate
with the modem using AT commands. Now, I would like to use PPPos (PPP over
serial) library from LWIP 2.03 to enter in PPP mode. FreeRTOS has to
implement as this project will be running in a threaded environment.
*Firstly, I have completed all the necessary AT commands and dialed up
ATD*99***1#. Everything is working as expected.
* Secondly, I need to proceed with LWIP(PPPos support) in order to get the
IP address. This part is
bit tough. I wrote some APIs such as sio_, sys_jiffies and linkStatusCB
functions and tried to open serial communication but it's not successful.
Link status call back says that there is a "connection lost" error. I
couldn't figure it out.
*Modem transmits the following data:
CONNECT 7200000
~ÿ}#À!}!}!} }8}"}&} } } } }#}$À#}%}&R}8}0D}'}"}(}"™Ë~... ...~ÿ}
#À!}!}!} }8}"}&} } } } }#}$À#}%}&R}8}0D}'}"}(}"™Ë~
NO CARRIER
*MCU trasmits the following command and data:
ATD*99***1#
~ÿ}#À!}!}!} }4}"}&} } } } }%}&[[ì} }'}"}(}"`?~
*my code goes at follows:
static void tcpip_init_done(void *arg)
{
if (arg) {
*((bool *)arg) = 1;
}
}
tcpip_init(tcpip_init_done, &setup); //tcpip init.
while (!setup) {
sleep(1);
}
io_write(usart, ATppp, sizeof(ATppp)/sizeof(ATppp[0]));//dials ATD*99#
vTaskDelay(1000);
pppos_example_init();
while(connected==0){
io_write(usart1, (uint8_t*)"Cant connect wait\r\n", 21);
vTaskDelay(1000);
}
if (connected)
{
io_write(usart1, (uint8_t*)"Success\r\n", 11);
}
*** My example function
static sio_fd_t ppp_sio;
static ppp_pcb *ppp;
static struct netif pppos_netif;
pppos_example_init(void)
{
ppp_sio = sio_open(0);
if(!ppp_sio)
{
//perror("PPPOS example: Error opening device");
return;
}
ppp_init();
ppp = pppos_create(&pppos_netif, ppp_output_cb, ppp_link_status_cb, NULL);
if (!ppp)
{
// printf("PPPOS example: Could not create PPP control interface");
return;
}
#ifdef LWIP_PPP_CHAP_TEST
ppp_set_auth(ppp, PPPAUTHTYPE_CHAP, "lwip", "mysecret");
#endif
ppp_connect(ppp, 0);
#if LWIP_NETIF_STATUS_CALLBACK
netif_set_status_callback(&pppos_netif, netif_status_callback);
#endif /* LWIP_NETIF_STATUS_CALLBACK */
sys_thread_new("pppos_rx_thread", pppos_rx_thread, NULL, 1048, 1);
#endif /* PPP_SUPPORT */
}
***Other functions
ppp_output_cb(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx)
{
return sio_write(ppp_sio, data, len);
}
***PPP thread
static void pppos_rx_thread(void *arg)
{
u32_t len;
u8_t buffer[128] = {0};
LWIP_UNUSED_ARG(arg);
while (1) {
len = sio_read(ppp_sio, buffer, sizeof(buffer));
if (len > 0) {
pppos_input_tcpip(ppp, buffer, len);
}
}
}
--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html
- [lwip-users] LWIP+PPPos(GPRS),
bakmurat <=