OSStatus MICORestoreDefault(mico_Context_t *inContext)
{ 
  OSStatus err = kNoErr;
  uint32_t paraStartAddress, paraEndAddress;
 
  paraStartAddress = PARA_START_ADDRESS;
  paraEndAddress = PARA_END_ADDRESS;

  /*wlan configration is not need to change to a default state, use easylink to do that*/
  sprintf(inContext->flashContentInRam.micoSystemConfig.name, DEFAULT_NAME);
  inContext->flashContentInRam.micoSystemConfig.configured = unConfigured;
  inContext->flashContentInRam.micoSystemConfig.easyLinkByPass = EASYLINK_BYPASS_NO;
  inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable = false;
  inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable = false;
  inContext->flashContentInRam.micoSystemConfig.bonjourEnable = true;
  inContext->flashContentInRam.micoSystemConfig.configServerEnable = true;
  inContext->flashContentInRam.micoSystemConfig.seed = seedNum;

  /*Application's default configuration*/
  appRestoreDefault_callback(inContext);

  err = MicoFlashInitialize(MICO_FLASH_FOR_PARA);
  require_noerr(err, exit);
  err = MicoFlashErase(MICO_FLASH_FOR_PARA, paraStartAddress, paraEndAddress);
  require_noerr(err, exit);
  err = MicoFlashWrite(MICO_FLASH_FOR_PARA, &paraStartAddress, (void *)inContext, sizeof(flash_content_t));
  require_noerr(err, exit);
  err = MicoFlashFinalize(MICO_FLASH_FOR_PARA);
  require_noerr(err, exit);

exit:
  return err;
}
Пример #2
0
OSStatus MICORestoreMFG(mico_Context_t *inContext)
{ 
  OSStatus err = kNoErr;
  uint32_t paraStartAddress, paraEndAddress;
 
  paraStartAddress = PARA_START_ADDRESS;
  paraEndAddress = PARA_END_ADDRESS;

  /*wlan configration is not need to change to a default state, use easylink to do that*/
  sprintf(inContext->flashContentInRam.micoSystemConfig.name, DEFAULT_NAME);
  inContext->flashContentInRam.micoSystemConfig.configured = mfgConfigured;

  /*Application's default configuration*/
  appRestoreDefault_callback(inContext);

  err = MicoFlashInitialize(MICO_FLASH_FOR_PARA);
  require_noerr(err, exit);
  err = MicoFlashErase(MICO_FLASH_FOR_PARA, paraStartAddress, paraEndAddress);
  require_noerr(err, exit);
  err = MicoFlashWrite(MICO_FLASH_FOR_PARA, &paraStartAddress, (void *)inContext, sizeof(flash_content_t));
  require_noerr(err, exit);
  err = MicoFlashFinalize(MICO_FLASH_FOR_PARA);
  require_noerr(err, exit);

exit:
  return err;
}