app_safe.c 1.0 KB

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.ErrorStartFlag >0){
  13. cnt++;
  14. if(cnt >=6){//一分钟后清空标志位
  15. mBackup.ErrorStartFlag =0;
  16. if(Flash_SaveBackup() != ZONE_OP_SUCCESS)Except_TxError(EXCEPT_Power,"save backup fail");
  17. DEBUG_LOG("clear mBackup.ErrorStartFlag\n");
  18. }
  19. }
  20. static uint8_t Restcnt =0;
  21. Restcnt++;
  22. if(slave_isconnect() && mFlash.RestartCnt > 1 && Restcnt>=2){Restcnt =0;
  23. char buff[40]={0};
  24. memset(buff,0,sizeof(buff));
  25. if(1 == mFlash.isHost){
  26. sprintf(buff,"left shoes restart:%d",mFlash.RestartCnt);
  27. }else{
  28. sprintf(buff,"right shoes restart:%d",mFlash.RestartCnt);
  29. }
  30. Except_TxError(EXCEPT_Power,(const char*)buff);
  31. }
  32. }
  33. void app_safe_Init(void)
  34. {
  35. mFlash.RestartCnt++;
  36. Process_Start(10000,"app_safe_Process",app_safe_Process);
  37. }