⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cphs_mod.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
 /*
+--------------------------------------------------------------------+
|         MODULE  : CPHS standalone module           |
| STATE   : code                        ROUTINE : cphs_getMailboxNumbers |
+--------------------------------------------------------------------+
*/
 /* reads all mailbox numbers from the SIM fills all mailbox number     */
  /* entries in the mailbox number list                                  */
T_CPHS_RET cphs_getMailboxNumbers ( T_CPHS_MAILBOX_NUM_LIST *nums )
 {if (cphs_data EQ NULL)
		return CPHS_NOT_INIT;
	if (nums EQ NULL)
		return CPHS_FAIL;

	memcpy(nums, &cphs_data->mbNum, sizeof(T_CPHS_CSP));
	return CPHS_IS_OK;
 }
 /*
+--------------------------------------------------------------------+
|         MODULE  : CPHS standalone module           |
| STATE   : code                        ROUTINE : cphs_getInfoNumbers|
+--------------------------------------------------------------------+

*/


 /* reads all information numbers from the SIM fills all information    */
  /* numbers into the array of pointers to information number lists down to the level specified  */
  //MC-Not sure about the format of this as current mfw_cphs code returns an information number list
  //with only 4 entries
T_CPHS_RET cphs_getInfoNumbers    ( T_CPHS_INFO_NUM_LIST *nums, UBYTE level, UBYTE start_index, T_CPHS_CB_FUNC callback)
{		cphs_data->InfoNumberListCB = callback;
 		cphs_data->numList=nums;
		Cphs_get_info_num(level, start_index);
 }
 /*
+--------------------------------------------------------------------+
|         MODULE  : CPHS standalone module           |
| STATE   : code                        ROUTINE : cphs_selectInfoNumber |
+--------------------------------------------------------------------+

  PURPOSE : reads the information number entry given by level and index from
   the SIM

*/
T_CPHS_RET cphs_selectInfoNumber  ( USHORT                 index,
                                    T_CPHS_INFO_NUM_ENTRY *num, T_CPHS_CB_FUNC callback)
{	cphs_data->InfoNumberCB = callback;
 	cphs_data->infoEntry= num;
	Cphs_select_info_num(index);
	//num = &cphs_data->infoEntry;

}




/*
+--------------------------------------------------------------------+
|         MODULE  : CPHS standalone module           |
| STATE   : code                        ROUTINE : Cphs_support_check |
+--------------------------------------------------------------------+

  PURPOSE : Check whether CPHS is supported.

*/

void Cphs_support_check (void)
{
  TRACE_FUNCTION ("Cphs_support_check()");

  /* Read CPHS information filed (6F16 - 3 bytes) from SIM card */
  if (!Cphs_read_sim_dat(SIM_CPHS_CINF, NOT_PRESENT_8BIT, CPHS_INFO_SIZE))
  {
    /* Read failed */
    cphs_data->cphsStatus = CPHS_NOT_PRESENT;

  }
}



 /*
  +--------------------------------------------------------------------+
|         MODULE  : CPHS standalone module           |
| STATE   : code                        ROUTINE : Cphs_operator_name |
+--------------------------------------------------------------------+

  PURPOSE : Request the network operator name

*/

void Cphs_operator_name (void)
{
  TRACE_FUNCTION ("Cphs_operator_name()");

  /* Check CPHS support status */
  if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
    return;

  /* Read operator name sring */
  if (!Cphs_read_sim_dat(SIM_CPHS_ONSTR, NOT_PRESENT_8BIT, CPHS_ONS_SIZE))
  {
    /* Read operator name sring failed */
    cphs_data->opName.long_name.len = 0;

    /* Read operator name shortform */
    if ((cphs_data->cphsPhase NEQ 2)                                                          OR
        (Cphs_ssc(CHPS_NAME_SHORT,   cphs_data->cphsServTab) NEQ ALLOCATED_AND_ACTIVATED) OR
        !Cphs_read_sim_dat(SIM_CPHS_ONSHF, NOT_PRESENT_8BIT, CPHS_ONSF_SIZE)                  )
    {
      /* Read operator name shortform failed.
           */
      cphs_data->opName.short_name.len = 0;
      cphs_data->opName.result = SIMOP_READ_ERR;
    }
  }

}

  /*
+-------------------------------------------------------------------------+
|         MODULE  : CPHS standalone module                |
| STATE   : code                        ROUTINE : Cphs_get_mailbox_status |
+-------------------------------------------------------------------------+

  PURPOSE : get the voice message waiting flag

*/

void Cphs_get_mailbox_status ()
{
  TRACE_FUNCTION ("Cphs_get_mailbox_status()");

  /* Check CPHS support status. */
  if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
    return ;

  /* Read voice message waiting flag.
     When this reading failed, send event with "read error" parameter to MMI */
  if (!Cphs_read_sim_dat(SIM_CPHS_VMW, NOT_PRESENT_8BIT, CPHS_MBS_SIZE))
  {
    cphs_data->mbStatus.result = SIMOP_READ_ERR;
    TRACE_EVENT("Reading mailbox status failed");
  }
}

/*
+------------------------------------------------------------------------+
|         MODULE  : CPHS standalone module               |
| STATE   : code                        ROUTINE : Cphs_get_divert_status |
+------------------------------------------------------------------------+

  PURPOSE : Request the call forwarding flags

*/

void Cphs_get_divert_status ()
{
  TRACE_FUNCTION ("Cphs_get_divert_status()");

  /* Check CPHS support status. */
  if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
    return;

  /* Read call forwarding flags.
     When this reading failed, send event with "read error" parameter to MMI */
  if (!Cphs_read_sim_dat(SIM_CPHS_CFF, NOT_PRESENT_8BIT, CPHS_CFF_SIZE))
  {
    cphs_data->dvStatus.result = SIMOP_READ_ERR;

  }

}

/*
+---------------------------------------------------------------------+
|         MODULE  : CPHS standalone module            |
| STATE   : code                        ROUTINE : Cphs_get_als_info   |
+---------------------------------------------------------------------+

  PURPOSE : Request the Status of Alternate Line Service information
            (first read selected ALS line, dann status of this line).
            When the field does not exist in SIM, read it from EEPROM.

*/
//ATM, cannot get als lock status from SIM
/*void Cphs_get_als_info ()
{
  TRACE_EVENT ("Cphs_get_als_info()");

    Cphs_read_eeprom_als();

}*/

/*
+---------------------------------------------------------------------+
|         MODULE  : CPHS standalone module            |
| STATE   : code                        ROUTINE : Cphs_get_csp        |
+---------------------------------------------------------------------+

  PURPOSE : Request the customer service profile

*/

void Cphs_get_csp ()
{
  UBYTE res;

  TRACE_FUNCTION ("Cphs_get_csp()");

  /* Check CPHS support status. */
  if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
    return ;

  /* check CPHS service table */
  res = Cphs_ssc(CPHS_CSP, cphs_data->cphsServTab);
  if ( res NEQ ALLOCATED_AND_ACTIVATED)
    return;

  /* Read customer service profile.
     When this reading failed, send event with empty parameter array to MMI */
  if (!Cphs_read_sim_dat(SIM_CPHS_CSP, NOT_PRESENT_8BIT, CPHS_CSP_SIZE))
  {
    cphs_data->csProfile.result = SIMOP_READ_ERR;
    memset(cphs_data->csProfile.csp, 0, sizeof(cphs_data->csProfile.csp));
  }
}
/*
+---------------------------------------------------------------------+
|         MODULE  : CPHS standalone module            |
| STATE   : code                        ROUTINE : Cphs_get_mailbox       |
+---------------------------------------------------------------------+

  PURPOSE : Request the customer service profile

*/
void Cphs_get_mailbox (void)
{
  TRACE_FUNCTION ("Cphs_get_mailbox()");

  cphs_data->mbNum.count = 0;

  /* Check CPHS support status.
     When CPHS is not support, read mailbox numbers from EEPROM */
  if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
  {
    Cphs_read_eeprom_mailbox();
    return;
  }

  /* Check CPHS service table.
     When CPHS is not support, read mailbox numbers from EEPROM */
  if (Cphs_ssc(CPHS_MB_NUMBER, cphs_data->cphsServTab) NEQ ALLOCATED_AND_ACTIVATED)
  {
  	TRACE_EVENT("CPHS doesn't support mailbox");
    Cphs_read_eeprom_mailbox();
    return;
  }

  /* Read mailbox numbers from SIM.
     When this reading failed, read mailbox numbers from EEPROM */
     //cphs_data->simStatus = SIMOP_UNKNOWN;
  if (!Cphs_read_sim_rcd(SIM_CPHS_MBXN, 1, 0)) /* read the first record */
  {	TRACE_EVENT("Mailbox Sim read failed");
    Cphs_read_eeprom_mailbox();
  }
}

/*
+----------------------------------------------------------------------+
|          MODULE: CPHS standalone module               |
| STATE  : code                         ROUTINE: Cphs_ssc				       |
+----------------------------------------------------------------------+


   PURPOSE :   Check CPHS service status.

*/

UBYTE Cphs_ssc (UBYTE nr, UBYTE * serv_table)
{
  UBYTE value;

  TRACE_FUNCTION ("Cphs_ssc()");

  serv_table = serv_table + (nr-1)/4;
  value      = * serv_table;

  value = value >> (((nr-1) & 3) * 2);
  value = value & 3;

  return value;
}

/*
+------------------------------------------------------------------------+
| MODULE  : CPHS standalone module               						|
| STATE   : code                        ROUTINE : Cphs_set_mailbox_status|
+------------------------------------------------------------------------+

  PURPOSE : Set the mailbox status on each line

*/

 T_CPHS_RET Cphs_set_mailbox_status (T_CPHS_FLAG_STATUS line1,
                               T_CPHS_FLAG_STATUS line2,
                               T_CPHS_FLAG_STATUS fax,
                               T_CPHS_FLAG_STATUS data)
{
  UBYTE result;
  char debug[50];

  TRACE_FUNCTION ("Cphs_set_mailbox_status()");

  /* Check CPHS support status. */
 // if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
 //   return CPHS_FAIL;
  sprintf(debug, "Original mailbox status: %x%x",cphs_data->mbsData[0],cphs_data->mbsData[1]);
  TRACE_EVENT(debug);
  /* Write status in buffer */
  if (line1 EQ CPHS_LINEFLAG_SET   OR
      line1 ==CPHS_LINEFLAG_NOT_SET  )
  {             			/* low Nibble */
  	cphs_data->mbsData[0]&=0xF0; //get rid of low nibble
  	cphs_data->mbsData[0] += (line1&0x0F);
  	}
 /* else
    cphs_data->mbsData[0] |= 0x0F;*/

  if (line2 EQ CPHS_LINEFLAG_SET   OR
      line2 EQ CPHS_LINEFLAG_NOT_SET  )
  {	cphs_data->mbsData[0]&=0x0F; //get rid of high nibble
    cphs_data->mbsData[0] += (line2 << 4)&0xF0;    /* high Nibble */
  }
/*  else
    cphs_data->mbsData[0] = 0xF0 | cphs_data->mbsData[0];*/

  if (fax EQ CPHS_LINEFLAG_SET   OR
      fax EQ CPHS_LINEFLAG_NOT_SET  )
  {cphs_data->mbsData[1]&=0xF0; //get rid of low nibble
    cphs_data->mbsData[1] += fax&0x0F;              /* low Nibble */
  }
/*  else
    cphs_data->mbsData[1] |= 0x0F;*/

  if (data EQ CPHS_LINEFLAG_SET   OR
      data EQ CPHS_LINEFLAG_NOT_SET  )
  {	cphs_data->mbsData[1]&=0x0F; //get rid of high nibble
    cphs_data->mbsData[1] += (data << 4)&0xF0;     /* high Nibble */
  }
/*  else
    cphs_data->mbsData[1] = 0xF0 | cphs_data->mbsData[1];*/

	sprintf(debug, "MBS Data:%x%x", cphs_data->mbsData[0], cphs_data->mbsData[1]);
	TRACE_EVENT(debug);

  /* Read voice message waiting flag to determine the size */
  cphs_data->simStatus = SIMOP_WRITE_OK;
  if (!Cphs_read_sim_dat(SIM_CPHS_VMW, NOT_PRESENT_8BIT, CPHS_MBS_SIZE))
  //if (!Cphs_write_sim_dat(SIM_CPHS_VMW, cphs_data->mbsData, CPHS_MBS_SIZE))
  { TRACE_EVENT("Mailbox status SIM write failed");
    return  CPHS_SIM_WRITE_ERROR;
  }
}

/*
+------------------------------------------------------------------------+
| MODULE  : CPHS standalone module               						|
| STATE   : code                        ROUTINE : Cphs_set_divert_status|
+------------------------------------------------------------------------+

  PURPOSE : Set the divert status on each line

*/

T_CPHS_RET Cphs_set_divert_status  (T_CPHS_FLAG_STATUS line1,
                               T_CPHS_FLAG_STATUS line2,
                               T_CPHS_FLAG_STATUS fax,
                               T_CPHS_FLAG_STATUS data)
{
  UBYTE result;
  char debug[50];

  TRACE_FUNCTION ("Cphs_set_divert_status()");

  /* Check CPHS support status. */
 // if (cphs_data->cphsStatus EQ CPHS_NOT_PRESENT)
  //  return cphs_data->cphsStatus;
sprintf(debug, "Original divert status: %x%x",cphs_data->dvData[0],cphs_data->dvData[1]);
  TRACE_EVENT(debug);
  /* Write status in buffer */
  if (line1 EQ CPHS_LINEFLAG_SET  OR
      line1 EQ CPHS_LINEFLAG_NOT_SET  )
  { cphs_data->dvData[0] &= 0xF0;			//zero low nibble
  	cphs_data->dvData[0] += line1&0x0F;            /* low Nibble */
  	}
  /*else
    cphs_data->dvData[0] |= 0x0F;*/

  if (line2 EQ CPHS_LINEFLAG_SET   OR
      line2 EQ CPHS_LINEFLAG_NOT_SET  )
  {cphs_data->dvData[0] &= 0x0F;			//zero high nibble
    cphs_data->dvData[0] += (line2 << 4)&0xF0;    /* high Nibble */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -