StdPJ/Core/Src/Common/Shared/iot_flash_config.c
/**
  * @brief  Write the C2C parameters to the Flash memory.
  * @retval Error code
  *             0    Success
  *             <0   Unrecoverable error
  */
@brief  Write the C2C parameters to the Flash memory.
@retval Error code
0    Success
<0   Unrecoverable error
@brief Write the C2C parameters to the Flash memory . @retval Error code 0 Success <0 Unrecoverable error
int updateC2cCredentials(void)
{
  c2c_config_t c2c_config;
  int ret = 0;
  memset(&c2c_config, 0, sizeof(c2c_config_t));
#if 0  
  {
    char c;
    do
    {
        printf("\rSelect the SIM slot (0 - External, 1 - Internal): \b");
        c = getchar();
    }
    while ( (c < '0')  || (c > '1'));
    c2c_config.use_internal_sim = (bool) (c - '0');
    printf("\nYou have selected the %s SIM.\n", (c2c_config.use_internal_sim == true) ? "external" : "internal");
  }
#endif
  printf("\nEnter Sim Operator Access Point Code (e.g. EM or ESEYE1 etc): ");
  getInputString(c2c_config.oper_ap_code, USER_CONF_C2C_SOAPC_MAX_LENGTH);
  printf("You have entered <%s> as the Sim Operator Access Point Code.\n", c2c_config.oper_ap_code);
  printf("\nEnter the username (it can be NULL) (max 16 char):  ");
  getInputString(c2c_config.username, USER_CONF_C2C_USERID_MAX_LENGTH);
  printf("You have entered <%s> as the username.\n", c2c_config.username);
  printf("\nEnter the password (it can be NULL) (max 16 char):  ");
  getInputString(c2c_config.password, USER_CONF_C2C_PSW_MAX_LENGTH);
  printf("You have entered <%s> as the password.\n", c2c_config.password);
  c2c_config.magic = USER_CONF_MAGIC;
  ret = FLASH_update((uint32_t)&lUserConfigPtr->c2c_config, &c2c_config, sizeof(c2c_config_t));
  if (ret < 0)
  {
    msg_error("Failed updating the C2C configuration in Flash.\n");
  }
  msg_info("\n");
  return ret;
}
int updateC2cCredentials ( void ) { c2c_config_t c2c_config ; int ret = 0 ; memset ( & c2c_config , 0 , sizeof ( c2c_config_t ) ) ; #if 0 { char c ; do { printf ( " \r \b " ) ; c = getchar ( ) ; } while ( ( c < ' ' ) || ( c > ' ' ) ) ; c2c_config . use_internal_sim = ( bool ) ( c - ' ' ) ; printf ( " \n \n " , ( c2c_config . use_internal_sim == true ) ? " " : " " ) ; } #endif printf ( " \n " ) ; getInputString ( c2c_config . oper_ap_code , USER_CONF_C2C_SOAPC_MAX_LENGTH ) ; printf ( " \n " , c2c_config . oper_ap_code ) ; printf ( " \n " ) ; getInputString ( c2c_config . username , USER_CONF_C2C_USERID_MAX_LENGTH ) ; printf ( " \n " , c2c_config . username ) ; printf ( " \n " ) ; getInputString ( c2c_config . password , USER_CONF_C2C_PSW_MAX_LENGTH ) ; printf ( " \n " , c2c_config . password ) ; c2c_config . magic = USER_CONF_MAGIC ; ret = FLASH_update ( ( uint32_t ) & lUserConfigPtr -> c2c_config , & c2c_config , sizeof ( c2c_config_t ) ) ; if ( ret < 0 ) { msg_error ( " \n " ) ; } msg_info ( " \n " ) ; return ret ; }
@brief  Write the C2C parameters to the Flash memory.
@brief Write the C2C parameters to the Flash memory .
/* Build this code if you want the user to choose the SIM slot. By default, the external slot is used. */