|
|
Get the Cnc Profile ID of a Cellular Mobile Context. This function is used if you want to use the Telephony Mgr API and Mobile Service API. It allows you to be sure to use the same phone module in both services.
- Parameters:
-
| [in] | iContextId | - The id of the Cellular Mobile Context. |
| [out] | oCncProfileIdP | - Pointer to an AlpMblCncProfileId, to store the Cnc Profile ID. |
- Returns:
- ALP_STATUS_OK - The Cnc Profile ID has been retrieved successfully.
ALP_STATUS_MBL_IPC_ERROR - Communication problem between library and server.
ALP_STATUS_MBL_MEMORY_ERROR - System is out of enough memory.
ALP_STATUS_MBL_INVALID_OBJECT - The context id is not valid: the context doesn't exist.
ALP_STATUS_MBL_INVALID_PARAMETER - oCncProfileIdP is NULL, and it's not valid.
- Example:
- An example of using both Mobile Services and Telephony Mgr APIs: retrievs the list of phonebook of the default context.
#include <stdio.h>
#include <string.h>
#include <alp/mobile.h>
#include <alp/mobile_context.h>
#include <alp/mobile_context_cellular.h>
#include <alp/telephony.h>
#include <alp/errormgr.h>
alp_status_t prv_list_phonebooks()
{
AlpMblContextId defaultContextId;
AlpMblContextType contextType;
AlpMblCncProfileId cncProfileId;
AlpTelApplicationId telAppId;
AlpTelPhbPhonebooks telPhonebooks;
size_t i;
alp_status_t err;
if ((err = alp_mbl_get_default_context(&defaultContextId)) != ALP_STATUS_OK)
{
printf("alp_mbl_get_default_context failed with error: %s.\n", alp_err_get_string(err, true));
return err;
}
printf("The id of the default context is %d.\n", defaultContextId);
if ((err = alp_mbl_context_get_type(defaultContextId, &contextType)) != ALP_STATUS_OK)
{
printf("alp_mbl_context_get_type failed with error: %s.\n", alp_err_get_string(err, true));
return err;
}
printf("The type of the default context is %s.\n", contextType);
if (strcmp(contextType, ALP_MBL_CONTEXT_CELL_TYPE) != 0)
{
printf("Invalid context type, only Cellular context can use Telephony Mgr APIs.\n");
return ALP_STATUS_MBL_INVALID_OBJECT;
}
if ((err = alp_mbl_context_cell_get_cnc_profile_id(defaultContextId, &cncProfileId)) != ALP_STATUS_OK)
{
printf("alp_mbl_context_cell_get_cnc_profile_id failed with error: %s.\n", alp_err_get_string(err, true));
return err;
}
if ((err = alp_tel_open_phone_profile(ALP_TEL_VERSION, cncProfileId, &telAppId)) != ALP_STATUS_OK)
{
printf("alp_tel_open_phone_profile failed with error: %s.\n", alp_err_get_string(err, true));
return err;
}
telPhonebooks.count = 20;
telPhonebooks.idP = (uint16_t*) malloc(sizeof(uint16_t) * telPhonebooks.count);
if ((err = alp_tel_phb_get_phonebooks(telAppId, &telPhonebooks, NULL)) != ALP_STATUS_OK)
{
printf("alp_tel_phb_get_phonebooks failed with error: %s.\n", alp_err_get_string(err, true));
(void) alp_tel_close(telAppId);
free(telPhonebooks.idP);
return err;
}
printf("Found %d phonebooks.\n", telPhonebooks.count);
for ( i = 0 ; i < telPhonebooks.count ; i++ )
printf(" Phonebook (%c%c).\n", (char) (telPhonebooks.idP[i] >> 8), (char) telPhonebooks.idP[i]);
free(telPhonebooks.idP);
if ((err = alp_tel_close(telAppId)) != ALP_STATUS_OK)
{
printf("alp_tel_close failed with error: %s.\n", alp_err_get_string(err, true));
return err;
}
return ALP_STATUS_OK;
}
- Since:
- ALP iSDK 1.1
|