295abb37ee
Firmware for an autonomous wave-measurement buoy (ATmega2560-based WII5 v2 board). Reads wave motion from a Sparton AHRS-M1/M2 IMU, samples GPS and battery state, and reports back over Iridium SBD satellite telemetry. Originally developed 2012-2024. This is the first public release. Code, documentation, and field-tested operating modes (Capture, Sleep, Position, ManualTest, SelfTest, LowBattery) are licensed under Apache 2.0 — see LICENSE and NOTICE. See README.md for an overview and build instructions, CONTRIBUTING.md for how to contribute, and DEPLOYMENTS.md for the field-deployment log.
147 lines
3.3 KiB
C
147 lines
3.3 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
|
//
|
|
// This file is part of WII5 Buoy firmware.
|
|
// See LICENSE for full terms.
|
|
|
|
/**
|
|
* @file WII5DataShared.h
|
|
* @brief Cross-class shared data structures and constants.
|
|
*/
|
|
|
|
// **********************************************************************
|
|
// *** This file belongs in WII5_SD_Block ***
|
|
// **********************************************************************
|
|
|
|
// NOTE: Manually copied from WII5_Buoy - but unlikely to change
|
|
// NOTE: Not aligned - must manually extract characters
|
|
typedef struct {
|
|
uint8_t byteCount;
|
|
uint8_t status; // 3 bits error, 5 bits protocol
|
|
uint8_t channel;
|
|
float pose_x;
|
|
float pose_y;
|
|
float pose_z;
|
|
// float mag_x;
|
|
// float mag_y;
|
|
// float mag_z;
|
|
float accel_x;
|
|
float accel_y;
|
|
float accel_z;
|
|
// float gyro_x;
|
|
// float gyro_y;
|
|
// float gyro_z;
|
|
uint32_t stamp;
|
|
uint16_t crc;
|
|
} WII5_DATA_SpartonBinary;
|
|
|
|
// Max size in Block Store = 488
|
|
// NOTE: Manually copied from WII5_Buoy - Very likely to change !!!
|
|
typedef struct {
|
|
// 4. This device and Current Record
|
|
uint32_t deviceId;
|
|
uint32_t recordCount;
|
|
|
|
// 12. Date, Time etc
|
|
time_t last;
|
|
uint32_t age; // Update as written to disk - (now() - last)
|
|
uint32_t uptime; // Uptime in minutes (not sure how this goes wih sleep)
|
|
|
|
// 4. Software Versions
|
|
uint32_t version; // Bytes.... 0,n.n.n = vn.n.n
|
|
|
|
// 8. Temperature
|
|
int32_t temperatureValue;
|
|
uint32_t temperatureAge;
|
|
|
|
// 8. Battery
|
|
int32_t batteryValue;
|
|
uint32_t batteryAge;
|
|
|
|
// 24. GPS
|
|
float gpsLat;
|
|
float gpsLon;
|
|
float gpsAlt;
|
|
int32_t gpsSat;
|
|
int32_t gpsHdop;
|
|
uint32_t gpsFixTime;
|
|
uint32_t gpsAge;
|
|
|
|
// Iridium ?
|
|
|
|
// 24. Capture
|
|
uint32_t captureWriteMax;
|
|
uint32_t captureWriteMin;
|
|
uint32_t captureWriteOver;
|
|
uint32_t captureTimeError;
|
|
uint32_t captureSizeError;
|
|
uint32_t captureStartTime;
|
|
|
|
// 1. mode - what is current
|
|
uint8_t mode;
|
|
// TODO more !!!
|
|
|
|
uint32_t iridiumFixTime;
|
|
uint32_t iridiumSignalQuality;
|
|
|
|
// CAPTURE Info - e.g. number of errors etc
|
|
} WII5MetaDataObject;
|
|
|
|
// **********************************************************************
|
|
// *** This file belongs in WII5_SD_Block ***
|
|
// **********************************************************************
|
|
// Processed output data
|
|
typedef struct {
|
|
// Reordered version
|
|
float part1float[73]; // 73*4 = 292 bytes
|
|
/*
|
|
float hz_max[4];
|
|
float hcm_max[4];
|
|
float htm_max[4];
|
|
float tz_max[4];
|
|
float tp;
|
|
float hmo;
|
|
float psd[55];
|
|
*/
|
|
|
|
} WII5Processed1;
|
|
typedef struct {
|
|
// Reordered version
|
|
float part2float[20]; // 20*4 = 80
|
|
int part2int[62]; // 62*2 = 124
|
|
// Total = 204
|
|
/*
|
|
float moments[7];
|
|
float theta;
|
|
float dp;
|
|
float s;
|
|
float r;
|
|
float hs_dir;
|
|
float a;
|
|
float b;
|
|
float nstd;
|
|
float f2;
|
|
float qf_mvar;
|
|
int qf_kist;
|
|
int qf_imu;
|
|
int qf_p_kist;
|
|
int qf_p_accel;
|
|
int qf_p_gyro;
|
|
int qf_p_mag;
|
|
int qf_head;
|
|
float power_diff;
|
|
float yaw_std;
|
|
int open_water;
|
|
int direction[54];
|
|
*/
|
|
} WII5Processed2;
|
|
|
|
typedef struct {
|
|
WII5Processed1 processed1;
|
|
WII5Processed2 processed2;
|
|
} WII5Processed;
|
|
|
|
// **********************************************************************
|
|
// *** This file belongs in WII5_SD_Block ***
|
|
// **********************************************************************
|