Complete IoT monitoring platform for Acuvim II power meters via ESP32. Firmware (Phases 1-7): - ESP32-WROVER-B (TTGO T-Call v1.4) with RS485 Modbus RTU - WiFi STA+AP concurrent mode with GSM/GPRS failover - Transport abstraction layer with 4 priority modes - MQTT protocol with 20 commands, LWT, QoS, exponential backoff - SD card offline buffering with JSONL rotation and non-blocking drain - OTA firmware updates with dual partition rollback protection - Watchdog timer, crash loop detection, Acuvim health monitoring - Captive portal provisioning with AP mode Console backend (Phase 8): - .NET 10 minimal API with PostgreSQL + EF Core - JWT authentication, SignalR real-time updates - MQTTnet 5.x bridge service with health monitoring - Device, telemetry, firmware, alert, group management - Rate limiting, security headers, Swagger/OpenAPI Frontend (Phase 9): - React 18 + TypeScript + Vite with Ant Design 5 - ECharts telemetry visualization, TanStack Query - SignalR live updates, device management UI - Dashboard, fleet management, firmware deployment Testing & Production (Phase 10): - 28 firmware unit tests (Modbus, JSON, config, version) - 23 xUnit backend tests (device, telemetry, command, alert) - Docker Compose with nginx, TLS MQTT, PostgreSQL - Production deployment, commissioning, and troubleshooting docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#include <unity.h>
|
|
#include <Arduino.h>
|
|
|
|
static bool isNewer(const char* available, const char* current) {
|
|
int av[3] = {0, 0, 0};
|
|
int cur[3] = {0, 0, 0};
|
|
sscanf(available, "%d.%d.%d", &av[0], &av[1], &av[2]);
|
|
sscanf(current, "%d.%d.%d", &cur[0], &cur[1], &cur[2]);
|
|
for (int i = 0; i < 3; i++) {
|
|
if (av[i] != cur[i]) return av[i] > cur[i];
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void test_newer_major() {
|
|
TEST_ASSERT_TRUE(isNewer("2.0.0", "1.0.0"));
|
|
}
|
|
|
|
void test_newer_minor() {
|
|
TEST_ASSERT_TRUE(isNewer("1.2.0", "1.1.0"));
|
|
}
|
|
|
|
void test_newer_patch() {
|
|
TEST_ASSERT_TRUE(isNewer("1.0.1", "1.0.0"));
|
|
}
|
|
|
|
void test_same_version() {
|
|
TEST_ASSERT_FALSE(isNewer("1.0.0", "1.0.0"));
|
|
}
|
|
|
|
void test_older_version() {
|
|
TEST_ASSERT_FALSE(isNewer("1.0.0", "1.1.0"));
|
|
}
|
|
|
|
void test_complex_version() {
|
|
TEST_ASSERT_TRUE(isNewer("2.1.3", "2.1.2"));
|
|
TEST_ASSERT_FALSE(isNewer("2.1.2", "2.1.3"));
|
|
TEST_ASSERT_TRUE(isNewer("3.0.0", "2.99.99"));
|
|
}
|
|
|
|
void setup() {
|
|
delay(2000);
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_newer_major);
|
|
RUN_TEST(test_newer_minor);
|
|
RUN_TEST(test_newer_patch);
|
|
RUN_TEST(test_same_version);
|
|
RUN_TEST(test_older_version);
|
|
RUN_TEST(test_complex_version);
|
|
UNITY_END();
|
|
}
|
|
|
|
void loop() {}
|