for the module’s legato version, you can check by “legato version” in console.
For the leaf shell, you need to check the legato version of the selected package. (you can see “leaf search” for the legato version of all the package)
Hi @jyijyi ,
my legato version is
root@fx30:~# legato version
18.06.3_7b16f82bd545a87f814cb194bd6d1985_modified
So I added the include
Could I use “.leaf” folder ?
Then compile got error like before.
_build_mdcTest/wp76xx/staging/read-only/lib/libComponent_mdcTestComp.so: undefined reference to
le_mdc_GetPlatformSpecificDisconnectionCodeExt' _build_mdcTest/wp76xx/staging/read-only/lib/libComponent_mdcTestComp.so: undefined reference to
le_mdc_GetDisconnectionReasonExt’
Does 18.06.3 support “le_mdc_GetPlatformSpecificDisconnectionCodeExt” and “le_mdc_GetDisconnectionReasonExt” function?
you can download the code and see:
then you can also check the source code in your leaf download
BTW, you should use the test app in legato 18.06.3 which does not include the le_mdc_GetDisconnectionReasonExt()
Hi @jyijyi ,
I got it. I found the old version doesn’t support the function.
Hi @jyijyi ,
I have a question about connect to internet.
- I try to use mdcTest to test connect to internet.
- Simplify the workflow like below:
profileRef = le_mdc_GetProfile(1);
le_mdc_SetPDP(profileRef, LE_MDC_PDP_IPV4);
le_mdc_SetAPN(profileRef, “internet”);
le_mdc_StartSession(profileRef);
le_mdc_GetInterfaceName(profileRef, ifname, LE_MDC_INTERFACE_NAME_MAX_BYTES);
le_mdc_GetIPv4Address(profileRef, ipAddr, sizeof(ipAddr));
le_mdc_GetIPv4GatewayAddress(profileRef, gatewayAddr, sizeof(gatewayAddr);
le_mdc_GetIPv4DNSAddresses( profileRef,
dns1Addr, sizeof(dns1Addr),
dns2Addr, sizeof(dns2Addr));
/sbin/route add default gw $gatewayAddr
Then I also use mdcTest.c function to check session state
static void* TestThread
(
void* contextPtr
)
{
le_mdc_ConnectService();
le_mdc_ProfileRef_t profileRef = *((le_mdc_ProfileRef_t*)contextPtr);
// Add state handler on the profile
le_mdc_AddSessionStateHandler(profileRef, StateChangeHandler, NULL);
// Post a semaphore to synchronize the test
le_sem_Post(TestSemaphore);
// Run the event loop
le_event_RunLoop();
return NULL;
}
Then I got the log
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTest_exe T=main | _main.c main() 62 | == Starting Event Processing Loop ==
Aug 4 06:07:11 fx30 user.info Legato: INFO | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 730 | ======= MDC TEST STARTED =======
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/framework T=MDC_Test | LE_FILENAME PThreadStartRoutine() 362 | Set nice level to 0.
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/framework T=MDC_Test | LE_FILENAME le_mem_ForceAlloc() 841 | Memory pool 'framework.DestructorObjs' overflowed. Expanded to 2 blocks.
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/framework T=MDC_Test | LE_FILENAME le_mem_ForceAlloc() 841 | Memory pool '.le_mdc_ClientThreadData' overflowed. Expanded to 2 blocks.
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/framework T=MDC_Test | le_mdc_client.c DoConnectService() 355 | ======= Starting client for 'mdcTest.mdcTestComp.le_mdc' service ========
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/framework T=MDC_Test | LE_FILENAME le_mem_ForceAlloc() 841 | Memory pool '.le_mdc_ClientData' overflowed. Expanded to 1 blocks.
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 471 | ================================================
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 472 | (int) le_mdc_GetProfileIndex(profileRef)=1
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 473 | ConnectionStatus=2
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 482 | ================================================
Aug 4 06:07:11 fx30 user.info Legato: INFO | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 759 | ifname:rmnet_data0
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 769 | ipAddr=25.117.104.29
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 772 | gatewayAddr=25.117.104.30
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 777 | dns1Addr=168.95.1.1
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 778 | dns2Addr=168.95.192.1
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 471 | ================================================
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 472 | (int) le_mdc_GetProfileIndex(profileRef)=1
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 473 | ConnectionStatus=0
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 478 | le_mdc_GetDisconnectionReason(profileRef)=45
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 479 | le_mdc_GetPlatformSpecificDisconnectionCode(profileRef)=1
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 482 | ================================================
Aug 4 06:07:12 fx30 user.info Legato: INFO | modemDaemon[931]/modemDaemon T=main | le_mrc.c SignalStrengthIndHandlerFunc() 819 | Signal Strength Ind Handler called with RAT.4 and ss.-57
I found it disconnected very quickly.
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 473 | ConnectionStatus=0
Aug 4 06:07:11 fx30 user.debug Legato: DBUG | mdcTest[9767]/mdcTestComp T=MDC_Test | mdcTest.c StateChangeHandler() 478 | le_mdc_GetDisconnectionReason(profileRef)=45
I saw reason 45 from 3GPP
But I don’t know why.
BTW I can use cm commad to connect to internet.
The command like below:
cm data profile 1
cm data pdp ipv4
cm data connect
ping 8.8.8.8 ← It can ping success.
So how am I supposed to make this happen by “le_mdc” ?
then why don’t use cm tool to establish data connection?
Or you can use the code in cm tool:
cm tool is using the le_mdc API!!!
you need to port the code to your app.
OK, I got it. I will try to port it to my APP.
Hi @jyijyi ,
My process implement follow the commnad
- cm data profile 1
- cm data pdp IPV4
- cm data apn “internet”
- cm data disconnect
- cm data connect
I follow cm_data.c to implement connect to internet process like below:
COMPONENT_INIT
{
le_mdc_ProfileRef_t profileRef = NULL;
char systemcmd[512] = {0};
char ifname[LE_MDC_INTERFACE_NAME_MAX_BYTES] = "\0";
char ipAddr[100] = {0};
char gatewayAddr[100] = {0};
char dns1Addr[100] = {0};
char dns2Addr[100] = {0};
le_mdc_ConState_t state = LE_MDC_DISCONNECTED;
le_result_t result;
// Get the profile reference
profileRef = le_mdc_GetProfile( 1 );
LE_ASSERT(NULL != profileRef);
if ( (result = le_mdc_StopSession(profileRef)) )
{
HandleResult("Stop Failure", result, false);
}
HandleResult("Stop Success", result, false);
LE_ASSERT(LE_OK == le_mdc_SetPDP(profileRef, LE_MDC_PDP_IPV4));
LE_ASSERT(LE_OK == le_mdc_SetAPN(profileRef, "internet"));
if ( (result = le_mdc_StartSession(profileRef)) )
{
HandleResult("Connection Failure", result, false);
}
HandleResult("Connection Success", result, false);
// Check the state
if ( (result = le_mdc_GetSessionState(profileRef, &state)) )
{
HandleResult("Failed to get connection state", result, false);
}
if (state != LE_MDC_CONNECTED)
{
LE_INFO("state:%d",state);
}
result = le_mdc_GetInterfaceName(profileRef, ifname, sizeof(ifname));
if (result)
{
HandleResult("Failed to get interface name", result, false);
}
LE_INFO("ifname:%s",ifname);
// Get IP, gateway and DNS addresses for IPv4 or IPv6 connectivity
if ( le_mdc_IsIPv4(profileRef) )
{
LE_ASSERT(le_mdc_GetIPv4Address(profileRef, ipAddr, sizeof(ipAddr)) == LE_OK);
LE_PRINT_VALUE("%s", ipAddr);
LE_ASSERT(le_mdc_GetIPv4GatewayAddress(profileRef, gatewayAddr, sizeof(gatewayAddr)) == LE_OK);
LE_PRINT_VALUE("%s", gatewayAddr);
LE_ASSERT(le_mdc_GetIPv4DNSAddresses( profileRef,
dns1Addr, sizeof(dns1Addr),
dns2Addr, sizeof(dns2Addr)) == LE_OK );
LE_PRINT_VALUE("%s", dns1Addr);
LE_PRINT_VALUE("%s", dns2Addr);
snprintf(systemcmd, sizeof(systemcmd), "echo \"nameserver %s\" >> $RESOLV_CONF", dns1Addr);
LE_ASSERT( system(systemcmd) == 0 );
snprintf(systemcmd, sizeof(systemcmd), "echo \"nameserver %s\" >> $RESOLV_CONF", dns2Addr);
LE_ASSERT( system(systemcmd) == 0 );
snprintf(systemcmd, sizeof(systemcmd), "ip -family $family route add default via %s dev %s", gatewayAddr, ifname);
LE_ASSERT( system(systemcmd) == 0 );
sleep(5);
snprintf(systemcmd, sizeof(systemcmd), "ping -c 4 8.8.8.8 -I %s", ifname);
LE_ASSERT( system(systemcmd) == 0 );
}
exit(EXIT_SUCCESS);
}
Then I got error, but I don’t know why.
The log is below"
Aug 5 01:16:12 fx30 user.err Legato: =ERR= | modemDaemon[931]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 796 | Sending QMI_WDS_GET_PKT_STATISTICS_REQ_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=70.[0x46]
Aug 5 01:16:12 fx30 user.err Legato: =ERR= | modemDaemon[931]/le_pa T=main | pa_mdc_qmi.c pa_mdc_StopSession() 3203 | Bad input parameter
Aug 5 01:16:12 fx30 user.err Legato: =ERR= | mdcTest[14089] | Stop Failure: LE_BAD_PARAMETER
Aug 5 01:16:12 fx30 user.err Legato: =ERR= | mdcTest[14089] | Stop Success: LE_BAD_PARAMETER
Aug 5 01:16:12 fx30 user.info Legato: INFO | mdcTest[14089] | Connection Success: LE_OK
Aug 5 01:16:12 fx30 user.info Legato: INFO | mdcTest[14089]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 830 | state:0
Aug 5 01:16:12 fx30 user.err Legato: =ERR= | mdcTest[14089] | Failed to get interface name: LE_FAULT
Aug 5 01:16:12 fx30 user.info Legato: INFO | mdcTest[14089]/mdcTestComp T=main | mdcTest.c _mdcTestComp_COMPONENT_INIT() 840 | ifname:
Aug 5 01:16:12 fx30 user.warn Legato: -WRN- | modemDaemon[931]/modemDaemon T=main | le_mdc.c le_mdc_IsIPv4() 1676 | Could not get the Session Type
I saw my connection state is disconnect soon.
Please help me, thanks.
i think you need to compare the OK log in cm tool and your log
Hi @jyijyi ,
How do I do this ? Where can I get cm tool log ?
I only got the log:
Aug 5 02:04:40 fx30 user.info Legato: INFO | cm[21296]/cm T=main | cm_data.c cm_data_ProcessDataCommand() 1164 | dataParam is NULL
Aug 5 02:04:40 fx30 user.err Legato: =ERR= | modemDaemon[931]/modemDaemon T=main | le_sms.c CloseSessionEventHandler() 2311 | SessionRef (0x7f61ba8c) has been closed
Aug 5 02:04:40 fx30 daemon.warn dnsmasq[1455]: no servers found in /etc/resolv.conf, will retry
Aug 5 02:04:40 fx30 user.err Legato: =ERR= | modemDaemon[931]/modemDaemon T=main | le_sms.c CloseSessionEventHandler() 2311 | SessionRef (0x7f61c074) has been closed
Aug 5 02:06:44 fx30 user.warn Legato: -WRN- | posDaemon[944]/le_pa_gnss T=unknown | pa_gnss_qmi.c PositionHandler() 1359 | Bad position indication
let’s make another approach with modemDemo.
Please try this modemDemo application and see if it can bring the module data establishment.
app runProc modemDemo send --exe=send -- 1234567 "Online"
If it works, you can directly copy the code to your application.
Hi @jyijyi ,
I don’t understand what you mean.
The LOG described above is generated when I execute cm.
You mean that I need execute the command when I execute my APP?
BTW my device doesn’t have modemDemo app.
I mean using modemdemo app instead of cm tool
Hi @jyijyi ,
Should I update modemDemo to my device ?
I don’t know what is inside your module
Hi @jyijyi ,
My FX30 with WP76XX