#endif
}
-void uapi_analysis_sleep_data(char * timepath , char *statuspath)
-{
+
+void uapi_analysis_sleep_data(char * timepath , char *statuspath,char*gpspath)
+{
+ typedef struct GPSData {
+ uint32_t timestamp; // 时间戳
+ double latitude; // 纬度
+ double longitude; // 经度
+}GPSData_t;
+//////////////////////////////////////////////////////////////////////
+ FILE* file = fopen(gpspath, "rb");
+ if (file == NULL) {
+ perror("无法打开文件");
+ return;
+ }
+ // 获取文件大小
+ fseek(file, 0, SEEK_END);
+ long fileSize = ftell(file);
+ rewind(file);
+ // 计算数据记录数量
+ const size_t recordSize = sizeof(GPSData_t);
+ const size_t recordCount = fileSize / recordSize;
+ printf("发现 %zu 条GPS数据记录\n", recordCount);
+ // 逐个读取并打印记录
+ GPSData_t gpsData;
+ for (size_t i = 0; i < recordCount; i++) {
+ if (fread(&gpsData, recordSize, 1, file) != 1) {
+ perror("读取数据失败");
+ break;
+ }
+
+ printf("记录 #%zu:\n", i + 1);
+ printf(" 时间戳: %u\n", gpsData.timestamp);
+ printf(" 纬度: %.8f\n", gpsData.latitude);
+ printf(" 经度: %.8f\n", gpsData.longitude);
+ }
+ fclose(gpspath);
+///////////////////////////////////////////////////////////
uint16_t datelen = 0;
uint8_t sleep_data[256] = {0};
{
char *timestr = "user/userdata/sleep/%s/sleep_time.bin";
char *statusstr = "user/userdata/sleep/%s/sleep_status.bin";
+ char *gpsstr = "user/userdata/sport/GPS_Point/%s.bin";
char timefilePath[64] = {0};
char statusfilePath[64] = {0};
+ char gpsfilePath[64] = {0};
sprintf(timefilePath,timestr,time);
sprintf(statusfilePath,statusstr,time);
+ sprintf(gpsfilePath,gpsstr,time);
- uapi_analysis_sleep_data(timefilePath,statusfilePath);
+ uapi_analysis_sleep_data(timefilePath,statusfilePath,gpsstr);
}