Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions boards/inhero_mr2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
[
"0x239A",
"0x8029"
],
[
"0x239A",
"0x0029"
],
[
"0x239A",
"0x002A"
],
[
"0x239A",
"0x802A"
]
],
"usb_product": "Inhero MR2",
"mcu": "nrf52840",
"variant": "Inhero_MR2_Board",
"bsp": {
"name": "adafruit"
},
"softdevice": {
"sd_flags": "-DS140",
"sd_name": "s140",
"sd_version": "6.1.1",
"sd_fwid": "0x00B6"
},
"bootloader": {
"settings_addr": "0xFF000"
}
},
"connectivity": [
"bluetooth"
],
"debug": {
"jlink_device": "nRF52840_xxAA",
"svd_path": "nrf52840.svd",
"openocd_target": "nrf52.cfg"
},
"frameworks": [
"arduino"
],
"name": "Inhero MR-2",
"upload": {
"maximum_ram_size": 235520,
"maximum_size": 815104,
"speed": 115200,
"protocol": "nrfutil",
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink",
"cmsis-dap"
],
"use_1200bps_touch": true,
"require_upload_port": true,
"wait_for_upload_port": true
},
"url": "https://inhero.de",
"vendor": "Inhero GmbH"
}
5 changes: 5 additions & 0 deletions examples/simple_repeater/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
}
sensors.querySensors(perm_mask, telemetry);

// Board-specific telemetry (boards can override queryBoardTelemetry in their Board class)
if (perm_mask & TELEM_PERM_ENVIRONMENT) {
board.queryBoardTelemetry(telemetry);
}

// This default temperature will be overridden by external sensors (if any)
float temperature = board.getMCUTemperature();
if(!isnan(temperature)) { // Supported boards with built-in temperature sensor. ESP32-C3 may return NAN
Expand Down
2 changes: 2 additions & 0 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void loop() {
command[0] = 0; // reset command buffer
}

board.tick(); // Feed watchdog and perform board-specific tasks

#if defined(PIN_USER_BTN) && defined(_SEEED_SENSECAP_SOLAR_H_)
// Hold the user button to power off the SenseCAP Solar repeater.
int btnState = digitalRead(PIN_USER_BTN);
Expand Down
2 changes: 2 additions & 0 deletions examples/simple_sensor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ void loop() {
command[0] = 0; // reset command buffer
}

board.tick(); // Feed watchdog and perform board-specific tasks

the_mesh.loop();
sensors.loop();
#ifdef DISPLAY_CLASS
Expand Down
8 changes: 8 additions & 0 deletions src/MeshCore.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

class CayenneLPP;

#include <stdint.h>
#include <math.h>

Expand Down Expand Up @@ -66,6 +68,12 @@ class MainBoard {
virtual const char* getResetReasonString(uint32_t reason) { return "Not available"; }
virtual uint8_t getShutdownReason() const { return 0; }
virtual const char* getShutdownReasonString(uint8_t reason) { return "Not available"; }

// Custom board commands and telemetry (boards can override these)
virtual void tick() {}
virtual bool getCustomGetter(const char* getCommand, char* reply, uint32_t maxlen) { return false; }
virtual const char* setCustomSetter(const char* setCommand) { return nullptr; }
virtual bool queryBoardTelemetry(CayenneLPP& telemetry) { return false; }
};

/**
Expand Down
15 changes: 15 additions & 0 deletions src/helpers/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,13 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
savePrefs();
strcpy(reply, "OK");
#endif
} else if (memcmp(config, "board.", 6) == 0) {
const char* result = _board->setCustomSetter(&config[6]);
if (result != nullptr) {
strcpy(reply, result);
} else {
strcpy(reply, "Error: unknown board command");
}
} else if (memcmp(config, "adc.multiplier ", 15) == 0) {
_prefs->adc_multiplier = atof(&config[15]);
if (_board->setAdcMultiplier(_prefs->adc_multiplier)) {
Expand Down Expand Up @@ -852,6 +859,14 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
#else
strcpy(reply, "ERROR: unsupported");
#endif
} else if (memcmp(config, "board.", 6) == 0) {
char res[100];
memset(res, 0, sizeof(res));
if (_board->getCustomGetter(&config[6], res, sizeof(res))) {
strcpy(reply, res);
} else {
strcpy(reply, "Error: unknown board command");
}
} else if (memcmp(config, "adc.multiplier", 14) == 0) {
float adc_mult = _board->getAdcMultiplier();
if (adc_mult == 0.0f) {
Expand Down
Loading