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.
128 lines
3.6 KiB
C++
128 lines
3.6 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 WII5Sh3dConfig.h
|
|
* @brief WII5 adapter for the Sh3d shared configuration layer.
|
|
*/
|
|
|
|
#ifndef WII5Sh3dConfig_h
|
|
#define WII5Sh3dConfig_h
|
|
|
|
#include <Arduino.h> //assumes Arduino IDE v1.0 or greater
|
|
#include <Arduino.h> //assumes Arduino IDE v1.0 or greater
|
|
#include <EEPROMex.h>
|
|
#include <WII5Data.h>
|
|
|
|
/*
|
|
|
|
Features:
|
|
* Automatic configuration depending on hardware:
|
|
* Size of EEPROM
|
|
* TODO
|
|
* Automatic Versioning
|
|
* Automatic counters
|
|
* EEPROM protection - by alternative locations
|
|
|
|
* Ability to extend
|
|
* Passing in one or more STRUCTS for the unused areas
|
|
* Helpers, like counters
|
|
|
|
*/
|
|
|
|
// ==============================================================================
|
|
// Address and Sizes
|
|
// ==============================================================================
|
|
// TODO Should be variable, this needs lots of work
|
|
#define totalLen 512
|
|
#define totalStart 0
|
|
#define configStart 0
|
|
#define configLen 128
|
|
#define extraStart 128
|
|
#define extraLen 384
|
|
|
|
|
|
// ==============================================================================
|
|
// Signature (experimenting)
|
|
// ==============================================================================
|
|
// TODO HARD CODED FOR NOW
|
|
#define CONFIG_TYPE 114
|
|
#define CONFIG_VERSION 12
|
|
|
|
// ==============================================================================
|
|
// Main Struct
|
|
// ==============================================================================
|
|
typedef struct {
|
|
// Internal - config data - might need more?
|
|
SH3D_TYPE_PACKET_TYPE configType; // Config Type
|
|
SH3D_TYPE_PACKET_VERSION configVersion; // Config Versio
|
|
|
|
// Device ID
|
|
SH3D_TYPE_UNIQUEID nodeId;
|
|
|
|
// Counters - To be moved around
|
|
SH3D_TYPE_COUNTER runCount; // Run ID - New ID each time device is booted
|
|
SH3D_TYPE_COUNTER recordCount; // Records, likes sesnsor data
|
|
|
|
// Some common and Basic configurables about this device
|
|
// TODO how often - eg. do we want to do it every minute, every hour, daily, etc
|
|
|
|
// Hard coded for Storage System - needs work
|
|
SH3D_TYPE_COUNTER storageLogLast;
|
|
SH3D_TYPE_COUNTER storageSensorLast;
|
|
|
|
} typeConfig;
|
|
|
|
class WII5Sh3dConfig {
|
|
public:
|
|
|
|
void begin( );
|
|
bool initialized = false;
|
|
|
|
// Do reads
|
|
void readConfig();
|
|
void updateConfig();
|
|
|
|
SH3D_TYPE_UNIQUEID getNodeId();
|
|
SH3D_TYPE_UNIQUEID setNodeId(SH3D_TYPE_UNIQUEID newId);
|
|
|
|
SH3D_TYPE_COUNTER getRunCount();
|
|
SH3D_TYPE_COUNTER updateRunCount();
|
|
SH3D_TYPE_COUNTER clearRunCount(SH3D_TYPE_COUNTER setId = 0);
|
|
|
|
// Record ID for Sensors
|
|
SH3D_TYPE_COUNTER getRecordCount();
|
|
SH3D_TYPE_COUNTER updateRecordCount();
|
|
SH3D_TYPE_COUNTER clearRecordCount(SH3D_TYPE_COUNTER setId = 0);
|
|
|
|
// Storage
|
|
SH3D_TYPE_COUNTER getStorageLogLast();
|
|
SH3D_TYPE_COUNTER updateStorageLogLast();
|
|
SH3D_TYPE_COUNTER clearStorageLogLast(SH3D_TYPE_COUNTER setId = 0);
|
|
SH3D_TYPE_COUNTER getStorageSensorLast();
|
|
SH3D_TYPE_COUNTER updateStorageSensorLast();
|
|
SH3D_TYPE_COUNTER clearStorageSensorLast(SH3D_TYPE_COUNTER setId = 0);
|
|
|
|
// Not sure I like these names, ``
|
|
uint16_t sizeExtra();
|
|
uint16_t startExtra();
|
|
void readExtra(char *data, uint16_t len, uint16_t offset);
|
|
void updateExtra(char *data, uint16_t len, uint16_t offset);
|
|
|
|
// Storage Location etc - as we can't errase a whole device
|
|
bool getFlashErased();
|
|
bool setFlashErased(bool in);
|
|
|
|
|
|
protected:
|
|
typeConfig dataConfig; // Main Config Data
|
|
|
|
};
|
|
|
|
extern WII5Sh3dConfig sh3dNodeConfig;
|
|
|
|
#endif
|