app_safe.c 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. if(0 == Except_TxError(EXCEPT_Power,(const char*)buff)){
  29. mBackup.RestartCnt =0;
  30. }
  31. }
  32. }
  33. void app_safe_Init(void)
  34. {
  35. mBackup.RestartCnt++;
  36. Process_Start(10000,"app_safe_Process",app_safe_Process);
  37. }