mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-10-20 22:01:58 +00:00
Import Airoha GPS RTC backup sleep, 24 contact search results, and the T-Echo Lite USB companion target. Preserve existing GPS telemetry and power-saving controls, crypto alignment checks, ESP32 RTC recovery, and RAK11310 dynamic-preference compatibility. Validate GPS sleep acknowledgments with their NMEA checksum and add six native regression tests covering retry, drain, corruption, grace timeout, and timer rollover. Verified: 1648 native and KISS modem tests; targeted nRF52, companion routing, one-key DM, and clock checks; T1000-E BLE, MeshTracker X1 USB, and T-Echo Lite USB companion builds.
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <ctype.h>
|
|
#include <cmath>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include "Stream.h"
|
|
|
|
using std::atof;
|
|
using std::atoi;
|
|
using std::atol;
|
|
|
|
inline uint32_t g_mock_millis = 0;
|
|
|
|
constexpr uint8_t LOW = 0;
|
|
constexpr uint8_t HIGH = 1;
|
|
constexpr uint8_t INPUT = 0;
|
|
constexpr uint8_t OUTPUT = 1;
|
|
constexpr uint8_t INPUT_PULLUP = 2;
|
|
constexpr uint8_t INPUT_PULLDOWN = 3;
|
|
|
|
inline uint8_t g_mock_pin_modes[64] = {};
|
|
inline uint8_t g_mock_pin_levels[64] = {};
|
|
inline int g_mock_analog_levels[64] = {};
|
|
|
|
using std::isnan;
|
|
|
|
inline uint32_t millis() {
|
|
return g_mock_millis;
|
|
}
|
|
|
|
inline void delay(uint32_t ms) {
|
|
g_mock_millis += ms;
|
|
}
|
|
|
|
inline char* ltoa(long value, char* dest, int base) {
|
|
if (base == 10) {
|
|
std::snprintf(dest, 16, "%ld", value);
|
|
} else {
|
|
dest[0] = '\0';
|
|
}
|
|
return dest;
|
|
}
|
|
|
|
inline void pinMode(uint8_t pin, uint8_t mode) {
|
|
if (pin < 64) g_mock_pin_modes[pin] = mode;
|
|
}
|
|
|
|
inline void digitalWrite(uint8_t pin, uint8_t level) {
|
|
if (pin < 64) g_mock_pin_levels[pin] = level;
|
|
}
|
|
|
|
inline int digitalRead(uint8_t pin) {
|
|
return pin < 64 ? g_mock_pin_levels[pin] : LOW;
|
|
}
|
|
|
|
inline int analogRead(uint8_t pin) {
|
|
return pin < 64 ? g_mock_analog_levels[pin] : 0;
|
|
}
|
|
|
|
inline void resetArduinoMock() {
|
|
g_mock_millis = 0;
|
|
for (uint8_t pin = 0; pin < 64; pin++) {
|
|
g_mock_pin_modes[pin] = INPUT;
|
|
g_mock_pin_levels[pin] = LOW;
|
|
g_mock_analog_levels[pin] = 0;
|
|
}
|
|
}
|