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

📄 nvimr.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 4 页
字号:

    ndigits = dial_ptr->num_digits;
    for (i = 0; i < ndigits; i++) {

      /* Even digits are copied from least significant digit,  */
      /* odd digits are copied from most significant digit.    */

      if(i%2 == 0)
      {
        dial_ptr->digits[i] =
          nvr_translate_to_external((byte)(nvi_item.dial.digits[i/2] & 0x0F));
      }
      else
      {
        dial_ptr->digits[i] =
          nvr_translate_to_external((byte)((nvi_item.dial.digits[i/2] & 0xF0) >> 4));
      }
    } /* for */

    /* Move name into external type. */
    (void)memcpy((void *) dial_ptr->letters, (void *) nvi_item.dial.letters,
                  NV_MAX_LTRS);
  }

#ifdef NV_FEATURE_EXTENDED_UI
      dial_ptr->status = nvi_item.dial.status;
#endif
  return status;

} /* nvimr_read_dial */

/*===========================================================================

FUNCTION NVIMR_READ_STDIAL

DESCRIPTION
  This procedure processes read requests for speed dial numbers.  It reads
  the NVM item using EFS services and it performs necessary translations
  and copy from internal format to external format.

DEPENDENCIES
  None.

RETURN VALUE
  Status of the read request.

SIDE EFFECTS
  None.

===========================================================================*/

LOCAL nv_stat_enum_type nvimr_read_stdial
(
  nv_items_enum_type    item,        /* Item to access */
  byte                  index_range, /* Maximum allowed range for index */
  byte                  index,       /* speed dial # */
  nv_stdial_type        *dial_ptr    /* Pointer to write source buffer */
)
{
  word   i;                 /* Digit index */
  nv_stat_enum_type status; /* Status to return to calling procedure */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Read the number from NVM into internal buffer. */
  /* Note that this data structure has a target specific member,
   * which dictates the member name we start the read into, in order
   * to skip the 'active' byte.
   */

  if (index >= index_range) return NV_BADPARM_S;

  status = nvimr_read_fixed_array(
                                  item,
                                  index,
#ifdef NV_FEATURE_EXTENDED_UI
                                  &nvi_item.stack.status,     /* skip "active" item */
#else
                                  &nvi_item.stack.num_digits, /* skip "active" item */
#endif
                                  sizeof(nvi_item.stack));

  if(status == NV_DONE_S)
  {
    /* Copy the number of dial digits stored, making  */
    /* sure that if there was an NVM error only the   */
    /* maximum number of dialed digits will be read.  */

    dial_ptr->num_digits = MIN(nvi_item.stack.num_digits, NV_MAX_DIAL_DIGITS);

    /* Copy the digits, expanding from two digits per  */
    /* byte into one digits per byte, and translating  */
    /* the digit to external character representation. */

    for (i = 0; i < dial_ptr->num_digits; i++) {

      /* Even digits are copied from least significant digit,  */
      /* odd digits are copied from most significant digit.    */

      if(i%2 == 0)
        dial_ptr->digits[i] = nvr_translate_to_external((byte)(nvi_item.stack.digits[i/2] & 0x0F));
      else
        dial_ptr->digits[i] = nvr_translate_to_external((byte)((nvi_item.stack.digits[i/2] & 0xF0) >> 4));
    } /* for */

    /* Move name into external type. */
    (void)memcpy((void *) dial_ptr->letters, (void *) nvi_item.stack.letters,
                  NV_MAX_LTRS);
  }

#ifdef NV_FEATURE_EXTENDED_UI
      dial_ptr->status = nvi_item.stack.status;
      dial_ptr->time_stamp = nvi_item.stack.time_stamp;
      dial_ptr->duration = nvi_item.stack.duration;
#endif
  return status;

} /* nvimr_read_stdial */


/*===========================================================================

FUNCTION NVIMR_READ_SMS

DESCRIPTION
  This function reads from an sms location

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S    if it worked
  NV_BADPARM_S if requested bytes are out of range for NVM

SIDE EFFECTS
  None

===========================================================================*/

LOCAL nv_stat_enum_type nvimr_read_sms
(
  nv_cmd_type  *cmd_ptr          /* Command block */
)
{
  char sms_name[20];
  int return_size;
  nv_stat_enum_type status = NV_DONE_S;
  struct fs_stat temp_buf;

  /* only sms supported at this time */
  if ((cmd_ptr->item != NV_SMS_I) ||
       (cmd_ptr->data_ptr->sms.address >= NVI_MAX_SMS_ADDR)) {
    status = NV_BADPARM_S;
  }
  else {
    /* Create the name of the file being read.*/
    (void) snprintf(sms_name,sizeof(sms_name),"/nvm/sms_%05d",
                                        cmd_ptr->data_ptr->sms.address);

    /* Check if the file is present or not. */
    if(efs_stat(sms_name,&temp_buf) == -1) {
      status = NV_NOTACTIVE_S;
    }
    else {
      if (temp_buf.st_size > (NV_SMS_DM_DATA_SIZ + sizeof(nvi_sms_type)))
      {
        MSG_HIGH ("SMS Buffer not big enough for slot %d",
                                  cmd_ptr->data_ptr->sms.address, 0, 0);
        status = NV_FAIL_S;
      }
      else
      {
        /* Extract the data from EFS */
        return_size = efs_get( sms_name,
                              (byte *)&(cmd_ptr->data_ptr->sms.address),
                              (int)temp_buf.st_size);
        if(return_size == -1)
          status = NV_FAIL_S;
      }
    }
  }
  return status;
} /* nvimr_read_sms */


#ifdef FEATURE_GWSMS
/*===========================================================================

FUNCTION NVIMR_READ_SMS_GW

DESCRIPTION
  This function reads from an sms_gw location

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S    if it worked
  NV_BADPARM_S if requested bytes are out of range for NVM

SIDE EFFECTS
  None

===========================================================================*/
LOCAL nv_stat_enum_type nvimr_read_sms_gw
(
  nv_cmd_type  *cmd_ptr          /* Command block */
)
{
  char sms_name[20];
  int return_size;
  nv_stat_enum_type status = NV_DONE_S;
  struct fs_stat temp_buf;

  /* only sms supported at this time */
  if ((cmd_ptr->item != NV_SMS_GW_I) ||
       (cmd_ptr->data_ptr->sms_gw.address >= NVI_MAX_SMS_ADDR)) {
    status = NV_BADPARM_S;
  }
  else {
    /* Create the name of the file being read.*/
    snprintf(sms_name, sizeof(sms_name), "/nvm/sms_gw_%05d",
                                        cmd_ptr->data_ptr->sms_gw.address);

    /* Check if the file is present or not. */
    if(efs_stat(sms_name,&temp_buf) == -1) {
      status = NV_NOTACTIVE_S;
    }
    else {
      if (temp_buf.st_size > (NV_SMS_GW_DATA_SIZ + sizeof(nvi_sms_gw_type)))
      {
        /* Buffer not big enough to hold the message */
        MSG_HIGH ("SMS Buffer not big enough for slot %d",
                                  cmd_ptr->data_ptr->sms_gw.address, 0, 0);
        status = NV_FAIL_S;
      }
      else
      {
        /* Extract the data from EFS */
        return_size = efs_get( sms_name,
                              (byte *)&(cmd_ptr->data_ptr->sms_gw.address),
                              temp_buf.st_size);
        if(return_size == -1)
          status = NV_FAIL_S;
      }
    }
  }
  return status;
} /* nvimr_read_sms_gw */
#endif


/*===========================================================================

FUNCTION NVIMR_READ_RENTAL_TIMER

DESCRIPTION
  This function returns the current value of the rental timer item.  Since
  this item is expected to be updated with very high frequency, it is stored
  in a way that minimizes EEPROM cell wear.  This unusual storage format
  calls for a special routine to compute and return the value for reads.

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S       if it worked
  NV_NOTACTIVE_S  if the item is uninitialized

SIDE EFFECTS
  None

===========================================================================*/
#ifdef NV_FEATURE_RENTAL_ITEMS
#error code not present
#endif


/*===========================================================================

FUNCTION NVIMR_READ_RENTAL_CNT

DESCRIPTION
  This function returns the current value of the rental count item.  Since
  this item is a fixed-pool double-buffered item, it needs a special read
  routine.

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S       if it worked
  NV_NOTACTIVE_S  if the item is uninitialized

SIDE EFFECTS
  None

===========================================================================*/
#ifdef NV_FEATURE_RENTAL_ITEMS
#error code not present
#endif


#ifdef NV_FEATURE_PRL_ITEMS
/*===========================================================================

FUNCTION NVIMR_READ_ROAMING_LIST

DESCRIPTION
  This function reads the roaming list.

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S    if it worked
  NV_BADPARM_S if requested bytes are out of range for NVM

SIDE EFFECTS
  None

===========================================================================*/

LOCAL nv_stat_enum_type nvimr_read_roaming_list
(
  nv_cmd_type  *cmd_ptr
)
{
  word               item_size;   /* Size of item (in bytes) */
  nv_stat_enum_type  status;      /* Function return value */

  /* Check for illegal NAM */
  if(cmd_ptr->data_ptr->roaming_list.nam >= NV_MAX_NAMS)
  {
    return NV_BADPARM_S;
  }

  /* Get its size */
  item_size = NV_ROAMING_LIST_HEADER_SIZE +
                 nv_max_size_of_roaming_list();

  MSG_MED("size: %d", item_size, 0, 0);

  status = nvimr_read_fixed_array(cmd_ptr->item,
                                  cmd_ptr->data_ptr->roaming_list.nam,
                                  (void *) &(cmd_ptr->data_ptr->roaming_list.prl_version),
                                  item_size);
  return status;
} /* nvimr_read_roaming_list */
#endif

/*===========================================================================

FUNCTION NVIMR_READ_FIXED

DESCRIPTION
  This function reads an fixed type item into the local buffer.  If the
  item is not active, then it is not read and a status code is returned.

DEPENDENCIES
  None.

RETURN VALUE
  NV_DONE_S      if it worked
  NV_NOTACTIVE_S if the item is not active.

SIDE EFFECTS
  None

===========================================================================*/

nv_stat_enum_type nvimr_read_fixed
(
  nv_items_enum_type item,     /* NV index of the item */
  PACKED void        *data_ptr, /* pointer to where to put read bytes */
  word               size      /* size of item */
)
{
  boolean active;            /* Indicator of whether the item is active */
  nv_stat_enum_type status;  /* Status to return to calling procedure */

⌨️ 快捷键说明

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