Initial public release of WII5 Buoy firmware
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.
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
// 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.cpp
|
||||
* @brief WII5 adapter for the Sh3d shared configuration layer.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
TODO 2024 - Sh3dConfig vs Config
|
||||
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "WII5Sh3dConfig.h"
|
||||
#include "WII5Sh3dConsole.h"
|
||||
#include <EEPROMex.h>
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
*/
|
||||
|
||||
// TODO Move this to Start Up
|
||||
void WII5Sh3dConfig::begin() {
|
||||
initialized = true;
|
||||
readConfig();
|
||||
updateRunCount();
|
||||
};
|
||||
|
||||
void WII5Sh3dConfig::readConfig() {
|
||||
EEPROM.readBlock(configStart, dataConfig);
|
||||
|
||||
if (
|
||||
(dataConfig.configType == CONFIG_TYPE)
|
||||
&& (dataConfig.configVersion == CONFIG_VERSION)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(LOG_ERROR, F("!EEPROM old=%d,%d. new=%d,%d"),
|
||||
dataConfig.configType,
|
||||
dataConfig.configVersion,
|
||||
CONFIG_TYPE,
|
||||
CONFIG_VERSION
|
||||
);
|
||||
|
||||
memset(&dataConfig, 0, sizeof(dataConfig));
|
||||
dataConfig.configType = CONFIG_TYPE;
|
||||
dataConfig.configVersion = CONFIG_VERSION;
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
void WII5Sh3dConfig::updateConfig() {
|
||||
EEPROM.updateBlock(configStart, dataConfig);
|
||||
}
|
||||
|
||||
SH3D_TYPE_UNIQUEID WII5Sh3dConfig::getNodeId() {
|
||||
if ( (dataConfig.nodeId < 10000) || (dataConfig.nodeId > 32000) )
|
||||
console.safeLog(LOG_ERROR, F("Invalid nodeId"));
|
||||
return dataConfig.nodeId;
|
||||
}
|
||||
|
||||
// TODO Ways of getting id etc?
|
||||
SH3D_TYPE_UNIQUEID WII5Sh3dConfig::setNodeId(SH3D_TYPE_UNIQUEID newId) {
|
||||
dataConfig.nodeId = newId;
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::getRunCount() {
|
||||
return dataConfig.runCount;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::updateRunCount() {
|
||||
dataConfig.runCount++;
|
||||
updateConfig();
|
||||
return dataConfig.runCount;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::clearRunCount(SH3D_TYPE_COUNTER setId) {
|
||||
dataConfig.runCount = setId;
|
||||
updateConfig();
|
||||
return dataConfig.runCount;
|
||||
}
|
||||
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::getRecordCount() {
|
||||
return dataConfig.recordCount;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::updateRecordCount() {
|
||||
dataConfig.recordCount++;
|
||||
updateConfig();
|
||||
return dataConfig.recordCount;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::clearRecordCount(SH3D_TYPE_COUNTER setId) {
|
||||
dataConfig.recordCount = setId;
|
||||
updateConfig();
|
||||
return dataConfig.recordCount;
|
||||
}
|
||||
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::getStorageLogLast() {
|
||||
return dataConfig.storageLogLast;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::updateStorageLogLast() {
|
||||
dataConfig.storageLogLast++;
|
||||
updateConfig();
|
||||
return dataConfig.storageLogLast;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::clearStorageLogLast(SH3D_TYPE_COUNTER setId) {
|
||||
dataConfig.storageLogLast = setId;
|
||||
updateConfig();
|
||||
return dataConfig.storageLogLast;
|
||||
}
|
||||
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::getStorageSensorLast() {
|
||||
return dataConfig.storageSensorLast;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::updateStorageSensorLast() {
|
||||
dataConfig.storageSensorLast++;
|
||||
updateConfig();
|
||||
return dataConfig.storageSensorLast;
|
||||
}
|
||||
SH3D_TYPE_COUNTER WII5Sh3dConfig::clearStorageSensorLast(SH3D_TYPE_COUNTER setId) {
|
||||
dataConfig.storageSensorLast = setId;
|
||||
updateConfig();
|
||||
return dataConfig.storageSensorLast;
|
||||
}
|
||||
|
||||
uint16_t sizeExtra() {
|
||||
// TODO return extraLen;
|
||||
return extraLen;
|
||||
}
|
||||
void readExtra(char *data, uint16_t len, uint16_t offset) {
|
||||
// TODO EEPROM.readBlock(data, extraStart + offset, len);
|
||||
}
|
||||
|
||||
void updateExtra(char *data, uint16_t len, uint16_t offset) {
|
||||
// TODO EEPROM.updateData(data, extraStart + offset, len);
|
||||
// EEPROM.updateBlock(extraStart, dataConfig);
|
||||
}
|
||||
|
||||
WII5Sh3dConfig sh3dNodeConfig;
|
||||
Reference in New Issue
Block a user