app_safe.c 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*********************************************************************
  2. * INCLUDES
  3. */
  4. #include "ble_comm.h"
  5. #include "app_flash.h"
  6. #include "hal_ble_client.h"
  7. #include "app_safe.h"
  8. #include "app_flash.h"
  9. static void app_safe_Process(void)
  10. {
  11. static uint8_t cnt =0;
  12. if(mBackup.ErrStartCnt >0){
  13. cnt++;
  14. if(cnt >=6){//Ò»·ÖÖÓºóÇå¿Õ±ê־λ
  15. mBackup.ErrStartCnt =0;
  16. if(Flash_SaveBackup() != ZONE_OP_SUCCESS)Except_TxError(EXCEPT_Power,"save ErrStartCnt fail");
  17. DEBUG_LOG("clear mBackup.ErrorStartFlag\n");
  18. }
  19. }
  20. if(mBackup.RestartCnt > 1){
  21. char buff[40]={0};
  22. memset(buff,0,sizeof(buff));
  23. if(mFlash.isHost){
  24. sprintf(buff,"left shoes restart:%d",mBackup.RestartCnt);
  25. }else{
  26. sprintf(buff,"right shoes restart:%d",mBackup.RestartCnt);
  27. }
  28. Except_TxError(EXCEPT_Power,(const char*)buff);
  29. }
  30. }
  31. void app_safe_Init(void)
  32. {
  33. mBackup.RestartCnt++;
  34. Process_Start(10000,"app_safe_Process",app_safe_Process);
  35. }