Sample code for Network Scan
//--------------------------------------------------------------------------------------------------/*** Read scan information**///--------------------------------------------------------------------------------------------------static void ReadScanInfo(le_mrc_ScanInformationRef_t scanInfoRef){le_mrc_Rat_t rat;bool boolTest;le_result_t res;char mcc[LE_MRC_MCC_BYTES] = {0};char mnc[LE_MRC_MNC_BYTES] = {0};char nameStr[100] = {0};res = le_mrc_GetCellularNetworkMccMnc(scanInfoRef, mcc, LE_MRC_MCC_BYTES, mnc, LE_MRC_MCC_BYTES);LE_ASSERT(res == LE_OK);res = le_mrc_GetCellularNetworkName(scanInfoRef, nameStr, 1);LE_ASSERT(res == LE_OVERFLOW);res = le_mrc_GetCellularNetworkName(scanInfoRef, nameStr, 100);;LE_ASSERT(res == LE_OK);LE_INFO("1st cellular network name.%s", nameStr);rat = le_mrc_GetCellularNetworkRat(scanInfoRef);LE_INFO("le_mrc_GetCellularNetworkRat returns rat %d", rat);boolTest = le_mrc_IsCellularNetworkInUse(scanInfoRef);boolTest = le_mrc_IsCellularNetworkAvailable(scanInfoRef);boolTest = le_mrc_IsCellularNetworkHome(scanInfoRef);boolTest = le_mrc_IsCellularNetworkForbidden(scanInfoRef);}//--------------------------------------------------------------------------------------------------/*** Test: Cellular Network Scan.** le_mrc_PerformCellularNetworkScan() API test*///--------------------------------------------------------------------------------------------------static void Testle_mrc_PerformCellularNetworkScan(void){le_result_t res;le_mrc_RatBitMask_t bitMaskOrigin = 0;le_mrc_ScanInformationListRef_t scanInfoListRef = NULL;le_mrc_ScanInformationRef_t scanInfoRef = NULL;// Get the current rat preference.res = le_mrc_GetRatPreferences(&bitMaskOrigin);LE_ASSERT(res == LE_OK);if ((bitMaskOrigin & LE_MRC_BITMASK_RAT_GSM) || (bitMaskOrigin == LE_MRC_BITMASK_RAT_ALL)){LE_INFO("Perform scan on GSM");scanInfoListRef = le_mrc_PerformCellularNetworkScan(LE_MRC_BITMASK_RAT_GSM);}else if (bitMaskOrigin & LE_MRC_BITMASK_RAT_UMTS){LE_INFO("Perform scan on UMTS");scanInfoListRef = le_mrc_PerformCellularNetworkScan(LE_MRC_BITMASK_RAT_UMTS);}LE_ASSERT(scanInfoListRef != NULL);scanInfoRef = le_mrc_GetFirstCellularNetworkScan(scanInfoListRef);LE_ASSERT(scanInfoRef != NULL);ReadScanInfo(scanInfoRef);while ((scanInfoRef = le_mrc_GetNextCellularNetworkScan(scanInfoListRef)) != NULL){ReadScanInfo(scanInfoRef);}le_mrc_DeleteCellularNetworkScan(scanInfoListRef);res = le_mrc_SetRatPreferences(bitMaskOrigin);LE_ASSERT(LE_OK == res);}//--------------------------------------------------------------------------------------------------/*** Test: Cellular Network Scan handler function.**///--------------------------------------------------------------------------------------------------static void MyNetworkScanHandler(le_mrc_ScanInformationListRef_t listRef,void* contextPtr){le_mrc_ScanInformationRef_t scanInfoRef = NULL;LE_ASSERT(listRef != NULL);scanInfoRef = le_mrc_GetFirstCellularNetworkScan(listRef);LE_ASSERT(scanInfoRef != NULL);ReadScanInfo(scanInfoRef);while ((scanInfoRef = le_mrc_GetNextCellularNetworkScan(listRef)) != NULL){ReadScanInfo(scanInfoRef);}le_mrc_DeleteCellularNetworkScan(listRef);le_sem_Post(ThreadSemaphore);}//--------------------------------------------------------------------------------------------------/*** Thread for asynchronous Network scan test.** Test API: le_mrc_PerformCellularNetworkScanAsync() API test*///--------------------------------------------------------------------------------------------------static void* MyNetworkScanAsyncThread(void* context ///< See parameter documentation above.){le_mrc_RatBitMask_t bitMaskOrigin;// Get the current rat preference.le_result_t res = le_mrc_GetRatPreferences(&bitMaskOrigin);LE_ASSERT(res == LE_OK);if ((bitMaskOrigin & LE_MRC_BITMASK_RAT_GSM) || (bitMaskOrigin == LE_MRC_BITMASK_RAT_ALL)){LE_INFO("Perform scan on GSM");le_mrc_PerformCellularNetworkScanAsync(LE_MRC_BITMASK_RAT_GSM,MyNetworkScanHandler, NULL);}else if (bitMaskOrigin & LE_MRC_BITMASK_RAT_UMTS){LE_INFO("Perform scan on UMTS");le_mrc_PerformCellularNetworkScanAsync(LE_MRC_BITMASK_RAT_UMTS,MyNetworkScanHandler, NULL);}return NULL;}