Sample code for Data Statistics

//--------------------------------------------------------------------------------------------------
/**
* Test the connectivity.
*
*/
//--------------------------------------------------------------------------------------------------
void TestConnectivity
(
)
{
char systemCmd[200] = {0};
char itfName[LE_MDC_INTERFACE_NAME_MAX_BYTES]="\0";
 
le_mdc_DataBearerTechnology_t downlinkDataBearerTech;
le_mdc_DataBearerTechnology_t uplinkDataBearerTech;
 
&downlinkDataBearerTech,
&uplinkDataBearerTech) == LE_OK);
 
LE_INFO("downlinkDataBearerTech %d, uplinkDataBearerTech %d",
downlinkDataBearerTech, uplinkDataBearerTech);
 
// Get interface name
== LE_OK);
 
if ( le_mdc_IsIPv4(profileRef) )
{
snprintf(systemCmd, sizeof(systemCmd), "ping -c 4 www.sierrawireless.com -I %s", itfName);
}
else
{
// TODO ping6 needs raw access to socket and therefore root permissions => find a different
// way to test the connectivity
snprintf(systemCmd, sizeof(systemCmd), "ping6 -c 4 www.sierrawireless.com -I %s", itfName);
}
 
res = system(systemCmd);
if (res != LE_OK)
{
le_mdc_StopSession(profileRef);
}
LE_ASSERT(res == LE_OK);
 
// Get data counters
uint64_t rxBytes=0, txBytes=0;
LE_ASSERT( le_mdc_GetBytesCounters(&rxBytes, &txBytes) == LE_OK );
 
LE_INFO("rxBytes %ld, txBytes %ld", (long int) rxBytes, (long int) txBytes);
}