Sample code for Data Statistics

//--------------------------------------------------------------------------------------------------
/**
* Test the connectivity.
*/
//--------------------------------------------------------------------------------------------------
void TestConnectivity
(
)
{
int status;
char systemCmd[200] = {0};
char itfName[LE_MDC_INTERFACE_NAME_MAX_BYTES] = "\0";
le_mdc_DataBearerTechnology_t downlinkDataBearerTech;
le_mdc_DataBearerTechnology_t uplinkDataBearerTech;
uint64_t rxBytes = 0, txBytes = 0;
uint64_t latestRxBytes = 0, latestTxBytes = 0;
 
&downlinkDataBearerTech,
&uplinkDataBearerTech));
 
LE_INFO("downlinkDataBearerTech %d, uplinkDataBearerTech %d",
downlinkDataBearerTech, uplinkDataBearerTech);
 
// Get interface name
 
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);
}
 
// Ping to test the connectivity
status = system(systemCmd);
if (WEXITSTATUS(status))
{
le_mdc_StopSession(profileRef);
}
LE_ASSERT(!WEXITSTATUS(status));
 
// Get data counters
LE_ASSERT_OK(le_mdc_GetBytesCounters(&rxBytes, &txBytes));
latestRxBytes = rxBytes;
latestTxBytes = txBytes;
LE_INFO("rxBytes %"PRIu64", txBytes %"PRIu64, rxBytes, txBytes);
 
// Stop data counters and ping to test the connectivity
status = system(systemCmd);
if (WEXITSTATUS(status))
{
le_mdc_StopSession(profileRef);
}
LE_ASSERT(!WEXITSTATUS(status));
 
// Get data counters
LE_ASSERT_OK(le_mdc_GetBytesCounters(&rxBytes, &txBytes));
LE_INFO("rxBytes %"PRIu64", txBytes %"PRIu64, rxBytes, txBytes);
LE_ASSERT(latestRxBytes == rxBytes);
LE_ASSERT(latestTxBytes == txBytes);
 
// Start data counters
}