mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #967 from fdlamotte/remove_target_h_dep
CommonCli: Remove dependency on target.h
This commit is contained in:
commit
dab44a1bb0
6 changed files with 21 additions and 19 deletions
|
|
@ -586,7 +586,7 @@ bool MyMesh::onPeerPathRecv(mesh::Packet *packet, int sender_idx, const uint8_t
|
||||||
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
|
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
|
||||||
mesh::RTCClock &rtc, mesh::MeshTables &tables)
|
mesh::RTCClock &rtc, mesh::MeshTables &tables)
|
||||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||||
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
|
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
|
||||||
#if defined(WITH_RS232_BRIDGE)
|
#if defined(WITH_RS232_BRIDGE)
|
||||||
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
|
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -580,7 +580,7 @@ void MyMesh::onAckRecv(mesh::Packet *packet, uint32_t ack_crc) {
|
||||||
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
|
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
|
||||||
mesh::RTCClock &rtc, mesh::MeshTables &tables)
|
mesh::RTCClock &rtc, mesh::MeshTables &tables)
|
||||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||||
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4) {
|
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4) {
|
||||||
next_local_advert = next_flood_advert = 0;
|
next_local_advert = next_flood_advert = 0;
|
||||||
dirty_contacts_expiry = 0;
|
dirty_contacts_expiry = 0;
|
||||||
_logging = false;
|
_logging = false;
|
||||||
|
|
|
||||||
|
|
@ -651,7 +651,7 @@ void SensorMesh::onAckRecv(mesh::Packet* packet, uint32_t ack_crc) {
|
||||||
|
|
||||||
SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
||||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||||
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
|
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
|
||||||
{
|
{
|
||||||
next_local_advert = next_flood_advert = 0;
|
next_local_advert = next_flood_advert = 0;
|
||||||
dirty_contacts_expiry = 0;
|
dirty_contacts_expiry = 0;
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ uint8_t CommonCLI::buildAdvertData(uint8_t node_type, uint8_t* app_data) {
|
||||||
AdvertDataBuilder builder(node_type, _prefs->node_name);
|
AdvertDataBuilder builder(node_type, _prefs->node_name);
|
||||||
return builder.encodeTo(app_data);
|
return builder.encodeTo(app_data);
|
||||||
} else if (_prefs->advert_loc_policy == ADVERT_LOC_SHARE) {
|
} else if (_prefs->advert_loc_policy == ADVERT_LOC_SHARE) {
|
||||||
AdvertDataBuilder builder(node_type, _prefs->node_name, sensors.node_lat, sensors.node_lon);
|
AdvertDataBuilder builder(node_type, _prefs->node_name, _sensors->node_lat, _sensors->node_lon);
|
||||||
return builder.encodeTo(app_data);
|
return builder.encodeTo(app_data);
|
||||||
} else {
|
} else {
|
||||||
AdvertDataBuilder builder(node_type, _prefs->node_name, _prefs->node_lat, _prefs->node_lon);
|
AdvertDataBuilder builder(node_type, _prefs->node_name, _prefs->node_lat, _prefs->node_lon);
|
||||||
|
|
@ -533,7 +533,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
sprintf(reply, "%s", _board->getManufacturerName());
|
sprintf(reply, "%s", _board->getManufacturerName());
|
||||||
} else if (memcmp(command, "sensor get ", 11) == 0) {
|
} else if (memcmp(command, "sensor get ", 11) == 0) {
|
||||||
const char* key = command + 11;
|
const char* key = command + 11;
|
||||||
const char* val = sensors.getSettingByKey(key);
|
const char* val = _sensors->getSettingByKey(key);
|
||||||
if (val != NULL) {
|
if (val != NULL) {
|
||||||
sprintf(reply, "> %s", val);
|
sprintf(reply, "> %s", val);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -545,7 +545,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
int num = mesh::Utils::parseTextParts(tmp, parts, 2, ' ');
|
int num = mesh::Utils::parseTextParts(tmp, parts, 2, ' ');
|
||||||
const char *key = (num > 0) ? parts[0] : "";
|
const char *key = (num > 0) ? parts[0] : "";
|
||||||
const char *value = (num > 1) ? parts[1] : "null";
|
const char *value = (num > 1) ? parts[1] : "null";
|
||||||
if (sensors.setSettingByKey(key, value)) {
|
if (_sensors->setSettingByKey(key, value)) {
|
||||||
strcpy(reply, "ok");
|
strcpy(reply, "ok");
|
||||||
} else {
|
} else {
|
||||||
strcpy(reply, "can't find custom var");
|
strcpy(reply, "can't find custom var");
|
||||||
|
|
@ -553,7 +553,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
} else if (memcmp(command, "sensor list", 11) == 0) {
|
} else if (memcmp(command, "sensor list", 11) == 0) {
|
||||||
char* dp = reply;
|
char* dp = reply;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = sensors.getNumSettings();
|
int end = _sensors->getNumSettings();
|
||||||
if (strlen(command) > 11) {
|
if (strlen(command) > 11) {
|
||||||
start = _atoi(command+12);
|
start = _atoi(command+12);
|
||||||
}
|
}
|
||||||
|
|
@ -565,8 +565,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
int i;
|
int i;
|
||||||
for (i = start; i < end && (dp-reply < 134); i++) {
|
for (i = start; i < end && (dp-reply < 134); i++) {
|
||||||
sprintf(dp, "%s=%s\n",
|
sprintf(dp, "%s=%s\n",
|
||||||
sensors.getSettingName(i),
|
_sensors->getSettingName(i),
|
||||||
sensors.getSettingValue(i));
|
_sensors->getSettingValue(i));
|
||||||
dp = strchr(dp, 0);
|
dp = strchr(dp, 0);
|
||||||
}
|
}
|
||||||
if (i < end) {
|
if (i < end) {
|
||||||
|
|
@ -577,7 +577,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
}
|
}
|
||||||
#if ENV_INCLUDE_GPS == 1
|
#if ENV_INCLUDE_GPS == 1
|
||||||
} else if (memcmp(command, "gps on", 6) == 0) {
|
} else if (memcmp(command, "gps on", 6) == 0) {
|
||||||
if (sensors.setSettingByKey("gps", "1")) {
|
if (_sensors->setSettingByKey("gps", "1")) {
|
||||||
_prefs->gps_enabled = 1;
|
_prefs->gps_enabled = 1;
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "ok");
|
strcpy(reply, "ok");
|
||||||
|
|
@ -585,7 +585,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
strcpy(reply, "gps toggle not found");
|
strcpy(reply, "gps toggle not found");
|
||||||
}
|
}
|
||||||
} else if (memcmp(command, "gps off", 7) == 0) {
|
} else if (memcmp(command, "gps off", 7) == 0) {
|
||||||
if (sensors.setSettingByKey("gps", "0")) {
|
if (_sensors->setSettingByKey("gps", "0")) {
|
||||||
_prefs->gps_enabled = 0;
|
_prefs->gps_enabled = 0;
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "ok");
|
strcpy(reply, "ok");
|
||||||
|
|
@ -593,13 +593,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
strcpy(reply, "gps toggle not found");
|
strcpy(reply, "gps toggle not found");
|
||||||
}
|
}
|
||||||
} else if (memcmp(command, "gps sync", 8) == 0) {
|
} else if (memcmp(command, "gps sync", 8) == 0) {
|
||||||
LocationProvider * l = sensors.getLocationProvider();
|
LocationProvider * l = _sensors->getLocationProvider();
|
||||||
if (l != NULL) {
|
if (l != NULL) {
|
||||||
l->syncTime();
|
l->syncTime();
|
||||||
}
|
}
|
||||||
} else if (memcmp(command, "gps setloc", 10) == 0) {
|
} else if (memcmp(command, "gps setloc", 10) == 0) {
|
||||||
_prefs->node_lat = sensors.node_lat;
|
_prefs->node_lat = _sensors->node_lat;
|
||||||
_prefs->node_lon = sensors.node_lon;
|
_prefs->node_lon = _sensors->node_lon;
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "ok");
|
strcpy(reply, "ok");
|
||||||
} else if (memcmp(command, "gps advert", 10) == 0) {
|
} else if (memcmp(command, "gps advert", 10) == 0) {
|
||||||
|
|
@ -633,12 +633,12 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||||
strcpy(reply, "error");
|
strcpy(reply, "error");
|
||||||
}
|
}
|
||||||
} else if (memcmp(command, "gps", 3) == 0) {
|
} else if (memcmp(command, "gps", 3) == 0) {
|
||||||
LocationProvider * l = sensors.getLocationProvider();
|
LocationProvider * l = _sensors->getLocationProvider();
|
||||||
if (l != NULL) {
|
if (l != NULL) {
|
||||||
bool enabled = l->isEnabled(); // is EN pin on ?
|
bool enabled = l->isEnabled(); // is EN pin on ?
|
||||||
bool fix = l->isValid(); // has fix ?
|
bool fix = l->isValid(); // has fix ?
|
||||||
int sats = l->satellitesCount();
|
int sats = l->satellitesCount();
|
||||||
bool active = !strcmp(sensors.getSettingByKey("gps"), "1");
|
bool active = !strcmp(_sensors->getSettingByKey("gps"), "1");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
sprintf(reply, "on, %s, %s, %d sats",
|
sprintf(reply, "on, %s, %s, %d sats",
|
||||||
active?"active":"deactivated",
|
active?"active":"deactivated",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "Mesh.h"
|
#include "Mesh.h"
|
||||||
#include <helpers/IdentityStore.h>
|
#include <helpers/IdentityStore.h>
|
||||||
#include <target.h>
|
#include <helpers/SensorManager.h>
|
||||||
|
|
||||||
#if defined(WITH_RS232_BRIDGE) || defined(WITH_ESPNOW_BRIDGE)
|
#if defined(WITH_RS232_BRIDGE) || defined(WITH_ESPNOW_BRIDGE)
|
||||||
#define WITH_BRIDGE
|
#define WITH_BRIDGE
|
||||||
|
|
@ -85,6 +85,7 @@ class CommonCLI {
|
||||||
NodePrefs* _prefs;
|
NodePrefs* _prefs;
|
||||||
CommonCLICallbacks* _callbacks;
|
CommonCLICallbacks* _callbacks;
|
||||||
mesh::MainBoard* _board;
|
mesh::MainBoard* _board;
|
||||||
|
SensorManager* _sensors;
|
||||||
char tmp[PRV_KEY_SIZE*2 + 4];
|
char tmp[PRV_KEY_SIZE*2 + 4];
|
||||||
|
|
||||||
mesh::RTCClock* getRTCClock() { return _rtc; }
|
mesh::RTCClock* getRTCClock() { return _rtc; }
|
||||||
|
|
@ -92,8 +93,8 @@ class CommonCLI {
|
||||||
void loadPrefsInt(FILESYSTEM* _fs, const char* filename);
|
void loadPrefsInt(FILESYSTEM* _fs, const char* filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommonCLI(mesh::MainBoard& board, mesh::RTCClock& rtc, NodePrefs* prefs, CommonCLICallbacks* callbacks)
|
CommonCLI(mesh::MainBoard& board, mesh::RTCClock& rtc, SensorManager& sensors, NodePrefs* prefs, CommonCLICallbacks* callbacks)
|
||||||
: _board(&board), _rtc(&rtc), _prefs(prefs), _callbacks(callbacks) { }
|
: _board(&board), _rtc(&rtc), _sensors(&sensors), _prefs(prefs), _callbacks(callbacks) { }
|
||||||
|
|
||||||
void loadPrefs(FILESYSTEM* _fs);
|
void loadPrefs(FILESYSTEM* _fs);
|
||||||
void savePrefs(FILESYSTEM* _fs);
|
void savePrefs(FILESYSTEM* _fs);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||||
-D P_LORA_RESET=42 ; P1.10
|
-D P_LORA_RESET=42 ; P1.10
|
||||||
-D LR11X0_DIO_AS_RF_SWITCH=true
|
-D LR11X0_DIO_AS_RF_SWITCH=true
|
||||||
-D LR11X0_DIO3_TCXO_VOLTAGE=1.6
|
-D LR11X0_DIO3_TCXO_VOLTAGE=1.6
|
||||||
|
-D ENV_INCLUDE_GPS=1
|
||||||
build_src_filter = ${nrf52_base.build_src_filter}
|
build_src_filter = ${nrf52_base.build_src_filter}
|
||||||
+<helpers/*.cpp>
|
+<helpers/*.cpp>
|
||||||
+<helpers/nrf52/T1000eBoard.cpp>
|
+<helpers/nrf52/T1000eBoard.cpp>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue