Example of web request over mobile data connection

For getting a mobile connection I have just made the following:

  • le_mrc_SetRadioPower(LE_ON)
  • On the le_mrc_AddNetRegStateEventHandler I have the following (pseudo code)
le_mdc_ProfileRef_t profile = le_mdc_GetProfile(LE_MDC_DEFAULT_PROFILE);
if (state == LE_MRC_REG_HOME || state == LE_MRC_REG_ROAMING)
{
  if (le_mdc_StartSession(profile) == LE_OK)
  {
    LE_DEBUG("Started data session");
  }
}
  • At the le_mdc_AddSessionStateHandler I have the following (pseudo code):
  if ( le_mdc_IsIPv4(profileRef) )
  {   
    le_mdc_GetIPv4Address(profileRef, ipAddr, sizeof(ipAddr));
    le_mdc_GetIPv4GatewayAddress(profileRef, gatewayAddr, sizeof(gatewayAddr));
    le_mdc_GetIPv4DNSAddresses( profileRef, dns1Addr, sizeof(dns1Addr), dns2Addr, sizeof(dns2Addr));
    snprintf(systemCmd, sizeof(systemCmd), "/sbin/route add default gw %s", gatewayAddr);

  }
  else if ( le_mdc_IsIPv6(profileRef) )
  {
    le_mdc_GetIPv6Address(profileRef, ipAddr, sizeof(ipAddr));
    le_mdc_GetIPv6GatewayAddress(profileRef, gatewayAddr, sizeof(gatewayAddr));
    le_mdc_GetIPv6DNSAddresses( profileRef, dns1Addr, sizeof(dns1Addr), dns2Addr, sizeof(dns2Addr)); 
    snprintf(systemCmd, sizeof(systemCmd), "/sbin/route -A inet6 add default gw %s", gatewayAddr);
  }

AddDnsAddressesToResolv();

Hope that helps