return healthTypePath + currentDate + ".json";
}
+ /*生成bin*/
+ std::string GetBinFilePath(uint8_t type)
+ {
+ std::string currentDate = GetCurrentDate();
+ const char *healthTypePath = (type == HEALTH_TYPE_HEART) ? HEALTH_JSON_PATH_HEART : HEALTH_JSON_PATH_OXYGEN;
+
+ return healthTypePath + currentDate + ".bin";
+ }
// 加载 JSON 数据
bool HealthService::LoadJsonData(uint8_t type)
{
ReleaseJsonData(HEALTH_TYPE_OXYGEN);
return false;
}
+ /*存储bin*/
+ std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART);
+ FILE *fp = fopen(binFilePath.c_str(), "ab+");
+ if (fp == NULL)
+ return false;
+ fwrite(&data.timestamp, 1, 4, fp);
+ fwrite(&data.SPO2, 1, 1, fp);
+ fclose(fp);
ReleaseJsonData(HEALTH_TYPE_OXYGEN);
+
return true;
}
heart_root = nullptr;
return false;
}
+ /*存储bin*/
+ std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART);
+ FILE *fp = fopen(binFilePath.c_str(), "ab+");
+ if (fp == NULL)
+ return false;
+ fwrite(&data.timestamp, 1, 4, fp);
+ fwrite(&data.Heart, 1, 1, fp);
+ fclose(fp);
return true;
}
cJSON_free(jsonData);
return true;
}
+
}
\ No newline at end of file