mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-11 04:17:43 +00:00
Compare commits
49 Commits
v1.3.13.71
...
v1.3.16.97
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97899aed26 | ||
|
|
0ee4ba4975 | ||
|
|
bbcccde787 | ||
|
|
42c285bc31 | ||
|
|
c831242f25 | ||
|
|
3c6f36c8f7 | ||
|
|
dfde6cc9c1 | ||
|
|
7816800012 | ||
|
|
ebf132ad21 | ||
|
|
67cf3018b5 | ||
|
|
eafbef0c2f | ||
|
|
4ab831c103 | ||
|
|
3df5ec0b11 | ||
|
|
c5c2765fb4 | ||
|
|
df9e9bc223 | ||
|
|
1ff0032c20 | ||
|
|
18024f1d25 | ||
|
|
313c50d6cf | ||
|
|
80e08f6de9 | ||
|
|
5a256323e2 | ||
|
|
45495c51e6 | ||
|
|
40ded630d0 | ||
|
|
432d06741e | ||
|
|
03b7f2f837 | ||
|
|
2e1b895791 | ||
|
|
9821a0535b | ||
|
|
0b666b827d | ||
|
|
235cacf9b9 | ||
|
|
db28a1562e | ||
|
|
f61d2d9eb4 | ||
|
|
5aef58e87f | ||
|
|
77a2054254 | ||
|
|
48ee995e0d | ||
|
|
c7dfd245e3 | ||
|
|
4e813b098a | ||
|
|
e57dbdd26c | ||
|
|
9512ea45de | ||
|
|
0d09767efd | ||
|
|
5828e6f423 | ||
|
|
c7a9ce7f49 | ||
|
|
95f091041b | ||
|
|
f33e6a0e66 | ||
|
|
fe8bfdb762 | ||
|
|
e8afd4fb4b | ||
|
|
b34b26518b | ||
|
|
b9f25eb85c | ||
|
|
a7fbe024e4 | ||
|
|
1f7fee8e2a | ||
|
|
b8e7c6ee7a |
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -51,7 +51,8 @@
|
||||
"iterator": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"iostream": "cpp",
|
||||
"esp_nimble_hci.h": "c"
|
||||
"esp_nimble_hci.h": "c",
|
||||
"map": "cpp"
|
||||
},
|
||||
"cSpell.words": [
|
||||
"Blox",
|
||||
|
||||
@@ -20,6 +20,7 @@ default_envs = tbeam
|
||||
;default_envs = pca10059_diy_eink
|
||||
;default_envs = meshtastic-diy-v1
|
||||
;default_envs = meshtastic-diy-v1.1
|
||||
;default_envs = m5stack-coreink
|
||||
|
||||
extra_configs = variants/*/platformio.ini
|
||||
|
||||
|
||||
Submodule protobufs updated: 695b242113...33b3ab5fde
@@ -5,6 +5,7 @@
|
||||
#include "main.h"
|
||||
#include "sleep.h"
|
||||
#include "utils.h"
|
||||
#include "buzz/buzz.h"
|
||||
|
||||
#ifdef TBEAM_V10
|
||||
// FIXME. nasty hack cleanup how we load axp192
|
||||
@@ -211,8 +212,12 @@ void Power::shutdown()
|
||||
{
|
||||
#ifdef TBEAM_V10
|
||||
DEBUG_MSG("Shutting down\n");
|
||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
||||
axp.shutdown();
|
||||
#elif NRF52_SERIES
|
||||
playBeep();
|
||||
ledOff(PIN_LED1);
|
||||
ledOff(PIN_LED2);
|
||||
doDeepSleep(DELAY_FOREVER);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ void PowerFSM_setup()
|
||||
|
||||
powerFSM.add_timed_transition(&stateON, &stateDARK,
|
||||
config.display.screen_on_secs ? config.display.screen_on_secs
|
||||
: 60 * 1000,
|
||||
: 60 * 1000 * 10,
|
||||
NULL, "Screen-on timeout");
|
||||
|
||||
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
|
||||
|
||||
@@ -45,9 +45,8 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
||||
bool SerialConsole::checkIsConnected()
|
||||
{
|
||||
uint32_t now = millis();
|
||||
return (now - lastContactMsec) < config.power.phone_timeout_secs
|
||||
? config.power.phone_timeout_secs
|
||||
: default_phone_timeout_secs * 1000UL;
|
||||
uint32_t timeout = (config.power.phone_timeout_secs > 0 ? config.power.phone_timeout_secs : default_phone_timeout_secs )* 1000UL;
|
||||
return (now - lastContactMsec) < timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef RV3028_RTC
|
||||
#include "Melopero_RV3028.h"
|
||||
#endif
|
||||
@@ -144,7 +145,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//#define DISABLE_NTP
|
||||
|
||||
// Disable the welcome screen and allow
|
||||
//#define DISABLE_WELCOME_UNSET
|
||||
#define DISABLE_WELCOME_UNSET
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// OLED & Input
|
||||
@@ -170,6 +171,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// The older M5 Faces I2C Keyboard
|
||||
#define FACESKB_ADDR 0x88
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SENSOR
|
||||
// -----------------------------------------------------------------------------
|
||||
#define BME_ADDR 0x76
|
||||
#define BME_ADDR_ALTERNATE 0x77
|
||||
#define MCP9808_ADDR 0x18
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// GPS
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../configuration.h"
|
||||
#include "../main.h"
|
||||
#include <Wire.h>
|
||||
#include "mesh/generated/telemetry.pb.h"
|
||||
|
||||
#ifndef NO_WIRE
|
||||
uint8_t oled_probe(byte addr)
|
||||
@@ -104,6 +105,27 @@ void scanI2Cdevice(void)
|
||||
DEBUG_MSG("axp192 PMU found\n");
|
||||
}
|
||||
#endif
|
||||
if (addr == BME_ADDR || addr == BME_ADDR_ALTERNATE) {
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write(0xD0); // GET_ID
|
||||
Wire.endTransmission();
|
||||
delay(20);
|
||||
Wire.requestFrom((int)addr, 1);
|
||||
if (Wire.available()) {
|
||||
r = Wire.read();
|
||||
}
|
||||
if (r == 0x61) {
|
||||
DEBUG_MSG("BME-680 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = addr;
|
||||
} else if (r == 0x60) {
|
||||
DEBUG_MSG("BME-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME280] = addr;
|
||||
}
|
||||
}
|
||||
if (addr == MCP9808_ADDR) {
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
||||
DEBUG_MSG("MCP9808 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||
}
|
||||
} else if (err == 4) {
|
||||
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
||||
}
|
||||
|
||||
@@ -49,12 +49,13 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
*/
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
hexDump("before", bytes, numBytes, 16);
|
||||
if (key.length > 0) {
|
||||
uint8_t stream_block[16];
|
||||
static uint8_t scratch[MAX_BLOCKSIZE];
|
||||
size_t nc_off = 0;
|
||||
|
||||
// DEBUG_MSG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
DEBUG_MSG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
initNonce(fromNode, packetId);
|
||||
assert(numBytes <= MAX_BLOCKSIZE);
|
||||
memcpy(scratch, bytes, numBytes);
|
||||
@@ -64,12 +65,11 @@ class ESP32CryptoEngine : public CryptoEngine
|
||||
auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes);
|
||||
assert(!res);
|
||||
}
|
||||
hexDump("after", bytes, numBytes, 16);
|
||||
}
|
||||
|
||||
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
// DEBUG_MSG("ESP32 decrypt!\n");
|
||||
|
||||
// For CTR, the implementation is the same
|
||||
encrypt(fromNode, packetId, numBytes, bytes);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
//4.2 inch 300x400 - GxEPD2_420_M01
|
||||
#define TECHO_DISPLAY_MODEL GxEPD2_420_M01
|
||||
|
||||
#elif defined(M5_COREINK)
|
||||
//M5Stack CoreInk
|
||||
//1.54 inch 200x200 - GxEPD2_154_M09
|
||||
#define TECHO_DISPLAY_MODEL GxEPD2_154_M09
|
||||
|
||||
#endif
|
||||
|
||||
GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT> *adafruitDisplay;
|
||||
@@ -58,6 +63,12 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl)
|
||||
//GxEPD2_420_M01
|
||||
setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
||||
|
||||
#elif defined(M5_COREINK)
|
||||
|
||||
//M5Stack_CoreInk 200x200
|
||||
//1.54 inch 200x200 - GxEPD2_154_M09
|
||||
setGeometry(GEOMETRY_RAWMODE, EPD_HEIGHT, EPD_WIDTH);
|
||||
|
||||
#endif
|
||||
// setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution
|
||||
// setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does
|
||||
@@ -108,7 +119,7 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit)
|
||||
// 4.2 inch 300x400 - GxEPD2_420_M01
|
||||
//adafruitDisplay->nextPage();
|
||||
|
||||
#elif defined(PCA10059)
|
||||
#elif defined(PCA10059) || defined(M5_COREINK)
|
||||
adafruitDisplay->nextPage();
|
||||
#endif
|
||||
|
||||
@@ -180,35 +191,10 @@ bool EInkDisplay::connect()
|
||||
adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
||||
adafruitDisplay->setRotation(3);
|
||||
//For 1.54, 2.9 and 4.2
|
||||
//adafruitDisplay->setRotation(1);
|
||||
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
//adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
} else {
|
||||
(void)adafruitDisplay;
|
||||
}
|
||||
@@ -221,6 +207,13 @@ bool EInkDisplay::connect()
|
||||
adafruitDisplay->setRotation(3);
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
}
|
||||
#elif defined(M5_COREINK)
|
||||
auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY);
|
||||
adafruitDisplay = new GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||
delay(100);
|
||||
adafruitDisplay->init(115200, true, 20, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
adafruitDisplay->setRotation(0);
|
||||
adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ bool eink_found = true;
|
||||
uint32_t serialSinceMsec;
|
||||
|
||||
bool axp192_found;
|
||||
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
|
||||
uint8_t nodeTelemetrySensorsMap[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include "GPSStatus.h"
|
||||
#include "NodeStatus.h"
|
||||
#include "PowerStatus.h"
|
||||
#include "graphics/Screen.h"
|
||||
#include "mesh/generated/telemetry.pb.h"
|
||||
|
||||
extern uint8_t screen_found;
|
||||
extern uint8_t screen_model;
|
||||
@@ -17,6 +19,8 @@ extern bool axp192_found;
|
||||
extern bool isCharging;
|
||||
extern bool isUSBPowered;
|
||||
|
||||
extern uint8_t nodeTelemetrySensorsMap[10];
|
||||
|
||||
// Global Screen singleton.
|
||||
extern graphics::Screen *screen;
|
||||
// extern Observable<meshtastic::PowerStatus> newPowerStatus; //TODO: move this to main-esp32.cpp somehow or a helper class
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void CryptoEngine::setKey(const CryptoKey &k)
|
||||
{
|
||||
DEBUG_MSG("Installing AES%d key!\n", k.length * 8);
|
||||
DEBUG_MSG("Using AES%d key!\n", k.length * 8);
|
||||
/* for(uint8_t i = 0; i < k.length; i++)
|
||||
DEBUG_MSG("%02x ", k.bytes[i]);
|
||||
DEBUG_MSG("\n"); */
|
||||
@@ -26,6 +26,78 @@ void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes
|
||||
DEBUG_MSG("WARNING: noop decryption!\n");
|
||||
}
|
||||
|
||||
// Usage:
|
||||
// hexDump(desc, addr, len, perLine);
|
||||
// desc: if non-NULL, printed as a description before hex dump.
|
||||
// addr: the address to start dumping from.
|
||||
// len: the number of bytes to dump.
|
||||
// perLine: number of bytes on each output line.
|
||||
|
||||
void CryptoEngine::hexDump (const char * desc, const void * addr, const int len, int perLine)
|
||||
{
|
||||
// Silently ignore silly per-line values.
|
||||
|
||||
if (perLine < 4 || perLine > 64) perLine = 16;
|
||||
|
||||
int i;
|
||||
unsigned char buff[perLine+1];
|
||||
const unsigned char * pc = (const unsigned char *)addr;
|
||||
|
||||
// Output description if given.
|
||||
|
||||
if (desc != NULL) DEBUG_MSG ("%s:\n", desc);
|
||||
|
||||
// Length checks.
|
||||
|
||||
if (len == 0) {
|
||||
DEBUG_MSG(" ZERO LENGTH\n");
|
||||
return;
|
||||
}
|
||||
if (len < 0) {
|
||||
DEBUG_MSG(" NEGATIVE LENGTH: %d\n", len);
|
||||
return;
|
||||
}
|
||||
|
||||
// Process every byte in the data.
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
// Multiple of perLine means new or first line (with line offset).
|
||||
|
||||
if ((i % perLine) == 0) {
|
||||
// Only print previous-line ASCII buffer for lines beyond first.
|
||||
|
||||
if (i != 0) DEBUG_MSG (" %s\n", buff);
|
||||
|
||||
// Output the offset of current line.
|
||||
|
||||
DEBUG_MSG (" %04x ", i);
|
||||
}
|
||||
|
||||
// Now the hex code for the specific character.
|
||||
|
||||
DEBUG_MSG (" %02x", pc[i]);
|
||||
|
||||
// And buffer a printable ASCII character for later.
|
||||
|
||||
if ((pc[i] < 0x20) || (pc[i] > 0x7e)) // isprint() may be better.
|
||||
buff[i % perLine] = '.';
|
||||
else
|
||||
buff[i % perLine] = pc[i];
|
||||
buff[(i % perLine) + 1] = '\0';
|
||||
}
|
||||
|
||||
// Pad out last line if not exactly perLine characters.
|
||||
|
||||
while ((i % perLine) != 0) {
|
||||
DEBUG_MSG (" ");
|
||||
i++;
|
||||
}
|
||||
|
||||
// And print the final ASCII buffer.
|
||||
|
||||
DEBUG_MSG (" %s\n", buff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init our 128 bit nonce for a new packet
|
||||
*/
|
||||
|
||||
@@ -56,6 +56,8 @@ class CryptoEngine
|
||||
* a 32 bit block counter (starts at zero)
|
||||
*/
|
||||
void initNonce(uint32_t fromNode, uint64_t packetId);
|
||||
|
||||
void hexDump(const char * desc, const void * addr, const int len, int perLine);
|
||||
};
|
||||
|
||||
extern CryptoEngine *crypto;
|
||||
|
||||
@@ -77,10 +77,13 @@ template <class T> class ProtobufModule : protected SinglePortModule
|
||||
T *decoded = NULL;
|
||||
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
|
||||
memset(&scratch, 0, sizeof(scratch));
|
||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch))
|
||||
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
|
||||
decoded = &scratch;
|
||||
else
|
||||
} else {
|
||||
DEBUG_MSG("Error decoding protobuf module!\n");
|
||||
// if we can't decode it, nobody can process it!
|
||||
return ProcessMessage::STOP;
|
||||
}
|
||||
}
|
||||
|
||||
return handleReceivedProtobuf(mp, decoded) ? ProcessMessage::STOP : ProcessMessage::CONTINUE;
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef struct _DeviceState {
|
||||
User owner;
|
||||
/* TODO: REPLACE */
|
||||
pb_size_t node_db_count;
|
||||
NodeInfo node_db[64];
|
||||
NodeInfo node_db[80];
|
||||
/* Received packets saved for delivery to the phone */
|
||||
pb_size_t receive_queue_count;
|
||||
MeshPacket receive_queue[1];
|
||||
@@ -92,10 +92,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0}
|
||||
#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0}
|
||||
#define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}}
|
||||
#define OEMStore_init_default {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
||||
#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0}
|
||||
#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0}
|
||||
#define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}}
|
||||
#define OEMStore_init_zero {0, 0, {0, {0}}, _ScreenFonts_MIN, ""}
|
||||
|
||||
@@ -159,7 +159,7 @@ extern const pb_msgdesc_t OEMStore_msg;
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define ChannelFile_size 624
|
||||
#define DeviceState_size 19184
|
||||
#define DeviceState_size 23728
|
||||
#define OEMStore_size 2106
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -48,6 +48,8 @@ typedef enum _PortNum {
|
||||
PortNum_ADMIN_APP = 6,
|
||||
/* Compressed TEXT_MESSAGE payloads. */
|
||||
PortNum_TEXT_MESSAGE_COMPRESSED_APP = 7,
|
||||
/* Waypoint payloads. */
|
||||
PortNum_WAYPOINT_APP = 8,
|
||||
/* Provides a 'ping' service that replies to any packet it receives.
|
||||
Also serves as a small example module. */
|
||||
PortNum_REPLY_APP = 32,
|
||||
|
||||
@@ -17,14 +17,6 @@ AdminModule *adminModule;
|
||||
/// a change.
|
||||
static const char *secretReserved = "sekrit";
|
||||
|
||||
/// If buf is !empty, change it to secret
|
||||
static void hideSecret(char *buf)
|
||||
{
|
||||
if (*buf) {
|
||||
strcpy(buf, secretReserved);
|
||||
}
|
||||
}
|
||||
|
||||
/// If buf is the reserved secret word, replace the buffer with currentVal
|
||||
static void writeSecret(char *buf, const char *currentVal)
|
||||
{
|
||||
|
||||
@@ -45,10 +45,12 @@ MCP9808Sensor mcp9808Sensor;
|
||||
int32_t EnvironmentTelemetryModule::runOnce()
|
||||
{
|
||||
#ifndef PORTDUINO
|
||||
int32_t result = INT32_MAX;
|
||||
/*
|
||||
Uncomment the preferences below if you want to use the module
|
||||
without having to configure it from the PythonAPI or WebUI.
|
||||
*/
|
||||
|
||||
/*
|
||||
moduleConfig.telemetry.environment_measurement_enabled = 1;
|
||||
moduleConfig.telemetry.environment_screen_enabled = 1;
|
||||
@@ -62,7 +64,7 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
if (!(moduleConfig.telemetry.environment_measurement_enabled ||
|
||||
moduleConfig.telemetry.environment_screen_enabled)) {
|
||||
// If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it
|
||||
return (INT32_MAX);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (firstTime) {
|
||||
@@ -73,32 +75,33 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
DEBUG_MSG("Environment Telemetry: Initializing\n");
|
||||
// it's possible to have this module enabled, only for displaying values on the screen.
|
||||
// therefore, we should only enable the sensor loop if measurement is also enabled
|
||||
|
||||
switch (moduleConfig.telemetry.environment_sensor_type) {
|
||||
|
||||
case TelemetrySensorType_DHT11:
|
||||
case TelemetrySensorType_DHT12:
|
||||
case TelemetrySensorType_DHT21:
|
||||
case TelemetrySensorType_DHT22:
|
||||
return dhtSensor.runOnce();
|
||||
case TelemetrySensorType_DS18B20:
|
||||
return dallasSensor.runOnce();
|
||||
case TelemetrySensorType_BME280:
|
||||
return bme280Sensor.runOnce();
|
||||
case TelemetrySensorType_BME680:
|
||||
return bme680Sensor.runOnce();
|
||||
case TelemetrySensorType_MCP9808:
|
||||
return mcp9808Sensor.runOnce();
|
||||
default:
|
||||
DEBUG_MSG("Environment Telemetry: Invalid sensor type selected; Disabling module");
|
||||
return (INT32_MAX);
|
||||
case TelemetrySensorType_DHT11:
|
||||
case TelemetrySensorType_DHT12:
|
||||
case TelemetrySensorType_DHT21:
|
||||
case TelemetrySensorType_DHT22:
|
||||
result = dhtSensor.runOnce();
|
||||
break;
|
||||
case TelemetrySensorType_DS18B20:
|
||||
result = dallasSensor.runOnce();
|
||||
break;
|
||||
default:
|
||||
DEBUG_MSG("Environment Telemetry: No sensor type specified; Checking for detected i2c sensors\n");
|
||||
break;
|
||||
}
|
||||
if (hasSensor(TelemetrySensorType_BME680))
|
||||
result = bme680Sensor.runOnce();
|
||||
if (hasSensor(TelemetrySensorType_BME280))
|
||||
result = bme280Sensor.runOnce();
|
||||
if (hasSensor(TelemetrySensorType_MCP9808))
|
||||
result = mcp9808Sensor.runOnce();
|
||||
}
|
||||
return (INT32_MAX);
|
||||
return result;
|
||||
} else {
|
||||
// if we somehow got to a second run of this module with measurement disabled, then just wait forever
|
||||
if (!moduleConfig.telemetry.environment_measurement_enabled)
|
||||
return (INT32_MAX);
|
||||
return result;
|
||||
// this is not the first time OSThread library has called this function
|
||||
// so just do what we intend to do on the interval
|
||||
if (sensor_read_error_count > moduleConfig.telemetry.environment_read_error_count_threshold) {
|
||||
@@ -114,7 +117,7 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
DEBUG_MSG("Environment Telemetry: DISABLED; The telemetry_module_environment_read_error_count_threshold has "
|
||||
"been exceed: %d. Reads will not be retried until after device reset\n",
|
||||
moduleConfig.telemetry.environment_read_error_count_threshold);
|
||||
return (INT32_MAX);
|
||||
return result;
|
||||
|
||||
} else if (sensor_read_error_count > 0) {
|
||||
DEBUG_MSG("Environment Telemetry: There have been %d sensor read failures. Will retry %d more times\n",
|
||||
@@ -124,23 +127,7 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
if (!sendOurTelemetry()) {
|
||||
// if we failed to read the sensor, then try again
|
||||
// as soon as we can according to the maximum polling frequency
|
||||
|
||||
switch (moduleConfig.telemetry.environment_sensor_type) {
|
||||
case TelemetrySensorType_DHT11:
|
||||
case TelemetrySensorType_DHT12:
|
||||
case TelemetrySensorType_DHT21:
|
||||
case TelemetrySensorType_DHT22:
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case TelemetrySensorType_DS18B20:
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case TelemetrySensorType_BME280:
|
||||
case TelemetrySensorType_BME680:
|
||||
return (BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
case TelemetrySensorType_MCP9808:
|
||||
return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
default:
|
||||
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
}
|
||||
return getIntervalOrDefaultMs(moduleConfig.telemetry.environment_update_interval);
|
||||
@@ -245,29 +232,26 @@ bool EnvironmentTelemetryModule::sendOurTelemetry(NodeNum dest, bool wantReplies
|
||||
DEBUG_MSG("Environment Telemetry: Read data\n");
|
||||
|
||||
switch (moduleConfig.telemetry.environment_sensor_type) {
|
||||
case TelemetrySensorType_DS18B20:
|
||||
if (!dallasSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
case TelemetrySensorType_DHT11:
|
||||
case TelemetrySensorType_DHT12:
|
||||
case TelemetrySensorType_DHT21:
|
||||
case TelemetrySensorType_DHT22:
|
||||
if (!dhtSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
case TelemetrySensorType_BME280:
|
||||
bme280Sensor.getMeasurement(&m);
|
||||
break;
|
||||
case TelemetrySensorType_BME680:
|
||||
bme680Sensor.getMeasurement(&m);
|
||||
break;
|
||||
case TelemetrySensorType_MCP9808:
|
||||
mcp9808Sensor.getMeasurement(&m);
|
||||
break;
|
||||
default:
|
||||
DEBUG_MSG("Environment Telemetry: No external sensor type selected; Only sending internal metrics\n");
|
||||
case TelemetrySensorType_DS18B20:
|
||||
if (!dallasSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
case TelemetrySensorType_DHT11:
|
||||
case TelemetrySensorType_DHT12:
|
||||
case TelemetrySensorType_DHT21:
|
||||
case TelemetrySensorType_DHT22:
|
||||
if (!dhtSensor.getMeasurement(&m))
|
||||
sensor_read_error_count++;
|
||||
break;
|
||||
default:
|
||||
DEBUG_MSG("Environment Telemetry: No specified sensor type; Trying any detected i2c sensors\n");
|
||||
}
|
||||
if (hasSensor(TelemetrySensorType_BME280))
|
||||
bme280Sensor.getMeasurement(&m);
|
||||
if (hasSensor(TelemetrySensorType_BME680))
|
||||
bme680Sensor.getMeasurement(&m);
|
||||
if (hasSensor(TelemetrySensorType_MCP9808))
|
||||
mcp9808Sensor.getMeasurement(&m);
|
||||
|
||||
DEBUG_MSG("Telemetry->time: %i\n", m.time);
|
||||
DEBUG_MSG("Telemetry->barometric_pressure: %f\n", m.variant.environment_metrics.barometric_pressure);
|
||||
|
||||
@@ -4,23 +4,28 @@
|
||||
#include "BME280Sensor.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
BME280Sensor::BME280Sensor() : TelemetrySensor {} {
|
||||
BME280Sensor::BME280Sensor() : TelemetrySensor {}
|
||||
{
|
||||
}
|
||||
|
||||
int32_t BME280Sensor::runOnce() {
|
||||
unsigned bme280Status;
|
||||
// Default i2c address for BME280
|
||||
bme280Status = bme280.begin(0x76);
|
||||
if (!bme280Status) {
|
||||
DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose diagnostics
|
||||
} else {
|
||||
DEBUG_MSG("Telemetry: Opened BME280 on default i2c bus");
|
||||
DEBUG_MSG("Init sensor: TelemetrySensorType_BME280\n");
|
||||
if (!hasSensor(TelemetrySensorType_BME280)) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
return BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
bme280Status = bme280.begin(nodeTelemetrySensorsMap[TelemetrySensorType_BME280]);
|
||||
if (!bme280Status) {
|
||||
DEBUG_MSG("Could not connect to any detected BME-280 sensor.\nRemoving from nodeTelemetrySensorsMap.\n");
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME280] = 0;
|
||||
} else {
|
||||
DEBUG_MSG("Opened BME280 on default i2c bus\n");
|
||||
}
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bool BME280Sensor::getMeasurement(Telemetry *measurement) {
|
||||
DEBUG_MSG("BME280Sensor::getMeasurement\n");
|
||||
measurement->variant.environment_metrics.temperature = bme280.readTemperature();
|
||||
measurement->variant.environment_metrics.relative_humidity = bme280.readHumidity();
|
||||
measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "TelemetrySensor.h"
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
#define BME_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class BME280Sensor : virtual public TelemetrySensor {
|
||||
private:
|
||||
Adafruit_BME280 bme280;
|
||||
|
||||
@@ -4,18 +4,22 @@
|
||||
#include "BME680Sensor.h"
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
BME680Sensor::BME680Sensor() : TelemetrySensor {} {
|
||||
BME680Sensor::BME680Sensor() : TelemetrySensor {}
|
||||
{
|
||||
}
|
||||
|
||||
int32_t BME680Sensor::runOnce() {
|
||||
unsigned bme680Status;
|
||||
// Default i2c address for BME680
|
||||
bme680Status = bme680.begin(0x76);
|
||||
DEBUG_MSG("Init sensor: TelemetrySensorType_BME680\n");
|
||||
if (!hasSensor(TelemetrySensorType_BME680)) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
bme680Status = bme680.begin(nodeTelemetrySensorsMap[TelemetrySensorType_BME680]);
|
||||
if (!bme680Status) {
|
||||
DEBUG_MSG("Could not find a valid BME680 sensor, check wiring, address, sensor ID!");
|
||||
// TODO more verbose TelemetrySensor
|
||||
DEBUG_MSG("Could not connect to any detected BME-680 sensor.\nRemoving from nodeTelemetrySensorsMap.\n");
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = 0;
|
||||
} else {
|
||||
DEBUG_MSG("Telemetry: Opened BME680 on default i2c bus");
|
||||
DEBUG_MSG("Opened BME680 on default i2c bus\n");
|
||||
// Set up oversampling and filter initialization
|
||||
bme680.setTemperatureOversampling(BME680_OS_8X);
|
||||
bme680.setHumidityOversampling(BME680_OS_2X);
|
||||
@@ -23,10 +27,11 @@ int32_t BME680Sensor::runOnce() {
|
||||
bme680.setIIRFilterSize(BME680_FILTER_SIZE_3);
|
||||
bme680.setGasHeater(320, 150); // 320*C for 150 ms
|
||||
}
|
||||
return (BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bool BME680Sensor::getMeasurement(Telemetry *measurement) {
|
||||
DEBUG_MSG("BME680Sensor::getMeasurement\n");
|
||||
measurement->variant.environment_metrics.temperature = bme680.readTemperature();
|
||||
measurement->variant.environment_metrics.relative_humidity = bme680.readHumidity();
|
||||
measurement->variant.environment_metrics.barometric_pressure = bme680.readPressure() / 100.0F;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "TelemetrySensor.h"
|
||||
#include <Adafruit_BME680.h>
|
||||
|
||||
#define BME_680_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class BME680Sensor : virtual public TelemetrySensor {
|
||||
private:
|
||||
Adafruit_BME680 bme680;
|
||||
|
||||
@@ -9,7 +9,8 @@ DHTSensor::DHTSensor() : TelemetrySensor{} {}
|
||||
|
||||
int32_t DHTSensor::runOnce()
|
||||
{
|
||||
if (TelemetrySensorType_DHT11 || TelemetrySensorType_DHT12) {
|
||||
if (moduleConfig.telemetry.environment_sensor_type == TelemetrySensorType_DHT11 ||
|
||||
moduleConfig.telemetry.environment_sensor_type == TelemetrySensorType_DHT12) {
|
||||
dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT11);
|
||||
} else {
|
||||
dht = new DHT(moduleConfig.telemetry.environment_sensor_pin, DHT22);
|
||||
@@ -17,13 +18,14 @@ int32_t DHTSensor::runOnce()
|
||||
|
||||
dht->begin();
|
||||
dht->read();
|
||||
DEBUG_MSG("Telemetry: Opened DHT11/DHT12 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
|
||||
DEBUG_MSG("Opened DHT11/DHT12 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
|
||||
|
||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bool DHTSensor::getMeasurement(Telemetry *measurement)
|
||||
{
|
||||
DEBUG_MSG("DHTSensor::getMeasurement\n");
|
||||
if (!dht->read(true)) {
|
||||
DEBUG_MSG("Telemetry: FAILED TO READ DATA\n");
|
||||
return false;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "TelemetrySensor.h"
|
||||
#include <DHT.h>
|
||||
|
||||
#define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class DHTSensor : virtual public TelemetrySensor {
|
||||
private:
|
||||
DHT *dht = NULL;
|
||||
|
||||
@@ -15,12 +15,13 @@ int32_t DallasSensor::runOnce()
|
||||
ds18b20->begin();
|
||||
ds18b20->setResolution(12);
|
||||
ds18b20->requestTemperatures();
|
||||
DEBUG_MSG("Telemetry: Opened DS18B20 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
|
||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
DEBUG_MSG("Opened DS18B20 on pin: %d\n", moduleConfig.telemetry.environment_sensor_pin);
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
bool DallasSensor::getMeasurement(Telemetry *measurement)
|
||||
{
|
||||
DEBUG_MSG("DallasSensor::getMeasurement\n");
|
||||
if (ds18b20->isConversionComplete()) {
|
||||
measurement->variant.environment_metrics.temperature = ds18b20->getTempC();
|
||||
measurement->variant.environment_metrics.relative_humidity = 0;
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
#include <DS18B20.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
#define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class DallasSensor : virtual public TelemetrySensor {
|
||||
private:
|
||||
OneWire *oneWire = NULL;
|
||||
|
||||
@@ -4,25 +4,31 @@
|
||||
#include "MCP9808Sensor.h"
|
||||
#include <Adafruit_MCP9808.h>
|
||||
|
||||
MCP9808Sensor::MCP9808Sensor() : TelemetrySensor {} {
|
||||
MCP9808Sensor::MCP9808Sensor() : TelemetrySensor {}
|
||||
{
|
||||
}
|
||||
|
||||
int32_t MCP9808Sensor::runOnce() {
|
||||
unsigned mcp9808Status;
|
||||
// Default i2c address for MCP9808
|
||||
mcp9808Status = mcp9808.begin(0x18);
|
||||
DEBUG_MSG("Init sensor: TelemetrySensorType_MCP9808\n");
|
||||
if (!hasSensor(TelemetrySensorType_MCP9808)) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
|
||||
mcp9808Status = mcp9808.begin(nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808]);
|
||||
if (!mcp9808Status) {
|
||||
DEBUG_MSG("Could not find a valid MCP9808 sensor, check wiring, address, sensor ID!");
|
||||
DEBUG_MSG("Could not connect to detected MCP9808 sensor.\n Removing from nodeTelemetrySensorsMap.\n");
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = 0;
|
||||
} else {
|
||||
DEBUG_MSG("TelemetrySensor: Opened MCP9808 on default i2c bus");
|
||||
DEBUG_MSG("TelemetrySensor: Opened MCP9808 on default i2c bus\n");
|
||||
// Reduce resolution from 0.0625 degrees (precision) to 0.125 degrees (high).
|
||||
mcp9808.setResolution(2);
|
||||
}
|
||||
return (MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||
}
|
||||
|
||||
bool MCP9808Sensor::getMeasurement(Telemetry *measurement) {
|
||||
DEBUG_MSG("MCP9808Sensor::getMeasurement\n");
|
||||
measurement->variant.environment_metrics.temperature = mcp9808.readTempC();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "TelemetrySensor.h"
|
||||
#include <Adafruit_MCP9808.h>
|
||||
|
||||
#define MCP_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
class MCP9808Sensor : virtual public TelemetrySensor {
|
||||
private:
|
||||
Adafruit_MCP9808 mcp9808;
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
#pragma once
|
||||
#include "../mesh/generated/telemetry.pb.h"
|
||||
#include "NodeDB.h"
|
||||
#include "main.h"
|
||||
|
||||
#define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000
|
||||
|
||||
inline bool hasSensor(TelemetrySensorType sensorType) {
|
||||
return sensorType < sizeof(nodeTelemetrySensorsMap) && nodeTelemetrySensorsMap[sensorType] > 0;
|
||||
}
|
||||
|
||||
class TelemetrySensor
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -16,48 +16,54 @@ class NRF52CryptoEngine : public CryptoEngine
|
||||
*/
|
||||
virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
// DEBUG_MSG("NRF52 encrypt!\n");
|
||||
|
||||
hexDump("before", bytes, numBytes, 16);
|
||||
if (key.length > 16) {
|
||||
DEBUG_MSG("Software encrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
AES_ctx ctx;
|
||||
initNonce(fromNode, packetId);
|
||||
AES_init_ctx_iv(&ctx, key.bytes, nonce);
|
||||
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
|
||||
} else if (key.length > 0) {
|
||||
DEBUG_MSG("nRF52 encrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
nRFCrypto.begin();
|
||||
nRFCrypto_AES ctx;
|
||||
uint8_t myLen = ctx.blockLen(numBytes);
|
||||
DEBUG_MSG("nRF52 encBuf myLen=%d!\n", myLen);
|
||||
char encBuf[myLen] = {0};
|
||||
memcpy(encBuf, bytes, numBytes);
|
||||
initNonce(fromNode, packetId);
|
||||
ctx.begin();
|
||||
ctx.Process(encBuf, numBytes, nonce, key.bytes, key.length, (char*)bytes, ctx.encryptFlag, ctx.ctrMode);
|
||||
ctx.Process((char*)bytes, numBytes, nonce, key.bytes, key.length, encBuf, ctx.encryptFlag, ctx.ctrMode);
|
||||
ctx.end();
|
||||
nRFCrypto.end();
|
||||
memcpy(bytes, encBuf, numBytes);
|
||||
}
|
||||
hexDump("after", bytes, numBytes, 16);
|
||||
}
|
||||
|
||||
virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override
|
||||
{
|
||||
// DEBUG_MSG("NRF52 decrypt!\n");
|
||||
|
||||
hexDump("before", bytes, numBytes, 16);
|
||||
if (key.length > 16) {
|
||||
DEBUG_MSG("Software decrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
AES_ctx ctx;
|
||||
initNonce(fromNode, packetId);
|
||||
AES_init_ctx_iv(&ctx, key.bytes, nonce);
|
||||
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
|
||||
} else if (key.length > 0) {
|
||||
DEBUG_MSG("nRF52 decrypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
|
||||
nRFCrypto.begin();
|
||||
nRFCrypto_AES ctx;
|
||||
uint8_t myLen = ctx.blockLen(numBytes);
|
||||
DEBUG_MSG("nRF52 decBuf myLen=%d!\n", myLen);
|
||||
char decBuf[myLen] = {0};
|
||||
memcpy(decBuf, bytes, numBytes);
|
||||
initNonce(fromNode, packetId);
|
||||
ctx.begin();
|
||||
ctx.Process(decBuf, numBytes, nonce, key.bytes, key.length, (char*)bytes, ctx.decryptFlag, ctx.ctrMode);
|
||||
ctx.Process((char*)bytes, numBytes, nonce, key.bytes, key.length, decBuf, ctx.decryptFlag, ctx.ctrMode);
|
||||
ctx.end();
|
||||
nRFCrypto.end();
|
||||
memcpy(bytes, decBuf, numBytes);
|
||||
}
|
||||
hexDump("after", bytes, numBytes, 16);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,7 +30,7 @@ void powerCommandsCheck()
|
||||
DEBUG_MSG("Shutting down from admin command\n");
|
||||
#ifdef TBEAM_V10
|
||||
if (axp192_found == true) {
|
||||
// setLed(false); //TODO: FIXME: this is not working
|
||||
playShutdownMelody();
|
||||
power->shutdown();
|
||||
}
|
||||
#elif NRF52_SERIES
|
||||
|
||||
18
variants/m5stack_coreink/platformio.ini
Normal file
18
variants/m5stack_coreink/platformio.ini
Normal file
@@ -0,0 +1,18 @@
|
||||
[env:m5stack-coreink]
|
||||
extends = esp32_base
|
||||
board = m5stack-coreink
|
||||
build_flags =
|
||||
${esp32_base.build_flags} -D M5_COREINK -I variants/m5stack_coreink
|
||||
;-D RADIOLIB_VERBOSE
|
||||
-Ofast
|
||||
-D__MCUXPRESSO
|
||||
-DEPD_HEIGHT=200
|
||||
-DEPD_WIDTH=200
|
||||
-DM5STACK
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
zinggjm/GxEPD2@^1.4.5
|
||||
lewisxhe/PCF8563_Library@^0.0.1
|
||||
board_build.f_cpu = 240000000L
|
||||
upload_protocol = esptool
|
||||
upload_port = /dev/ttyACM*
|
||||
49
variants/m5stack_coreink/variant.h
Normal file
49
variants/m5stack_coreink/variant.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#define I2C_SDA 21 //-1
|
||||
#define I2C_SCL 22 //-1
|
||||
|
||||
//#define LED_PIN 10
|
||||
|
||||
#include "pcf8563.h"
|
||||
// PCF8563 RTC Module
|
||||
#define PCF8563_RTC 0x51
|
||||
|
||||
#define BUTTON_NEED_PULLUP
|
||||
#define BUTTON_PIN 5
|
||||
|
||||
//Wheel
|
||||
// Down 37
|
||||
// Push 38
|
||||
// Up 39
|
||||
|
||||
// Top Physical Button 5
|
||||
|
||||
#undef RF95_SCK
|
||||
#undef RF95_MISO
|
||||
#undef RF95_MOSI
|
||||
#undef RF95_NSS
|
||||
#define USE_RF95
|
||||
|
||||
#define RF95_SCK 18 //13
|
||||
#define RF95_MISO 34 //26
|
||||
#define RF95_MOSI 23 //25
|
||||
#define RF95_NSS 14
|
||||
#define LORA_DIO0 25 //32 now moved from ext port
|
||||
#define LORA_RESET 26 //33 now moved from ext port
|
||||
#define LORA_DIO1 RADIOLIB_NC
|
||||
#define LORA_DIO2 RADIOLIB_NC
|
||||
|
||||
#define NO_GPS
|
||||
// This board has no GPS for now
|
||||
#undef GPS_RX_PIN
|
||||
#undef GPS_TX_PIN
|
||||
|
||||
#define HAS_EINK
|
||||
//https://docs.m5stack.com/en/core/coreink
|
||||
//https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/coreink/coreink_sch.pdf
|
||||
#define PIN_EINK_EN -1
|
||||
#define PIN_EINK_CS 9 // EPD_CS
|
||||
#define PIN_EINK_BUSY 4 // EPD_BUSY
|
||||
#define PIN_EINK_DC 15 // EPD_D/C
|
||||
#define PIN_EINK_RES -1 // Connected to GPIO0 but no needed !!!! maybe causing issue ?
|
||||
#define PIN_EINK_SCLK 18 // EPD_SCLK
|
||||
#define PIN_EINK_MOSI 23 // EPD_MOSI
|
||||
@@ -1,4 +1,4 @@
|
||||
[VERSION]
|
||||
major = 1
|
||||
minor = 3
|
||||
build = 13
|
||||
build = 16
|
||||
|
||||
Reference in New Issue
Block a user