mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-30 05:32:08 +00:00
Compare commits
29 Commits
v1.3.22.c7
...
v1.3.26.00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0010231172 | ||
|
|
50300957db | ||
|
|
07d4773722 | ||
|
|
62aa740c93 | ||
|
|
4de6d5bdb0 | ||
|
|
cf4c814b59 | ||
|
|
ca8e307976 | ||
|
|
b51b7d3eb7 | ||
|
|
ea7da3178b | ||
|
|
3011d09c8c | ||
|
|
d179f02519 | ||
|
|
67a7056025 | ||
|
|
930b023d10 | ||
|
|
85f46d3231 | ||
|
|
d56094fb7c | ||
|
|
dff69157d6 | ||
|
|
38088253f8 | ||
|
|
0e560b376f | ||
|
|
8c2af4f3d5 | ||
|
|
d7d574e0a7 | ||
|
|
5462d84bfc | ||
|
|
1efcd5e125 | ||
|
|
9fd7abf3d4 | ||
|
|
4a08f86f96 | ||
|
|
3f0ff45232 | ||
|
|
f8ee1ac4f9 | ||
|
|
f26441727c | ||
|
|
004a6f9c25 | ||
|
|
d81b043f1d |
@@ -145,7 +145,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// #define DISABLE_NTP
|
// #define DISABLE_NTP
|
||||||
|
|
||||||
// Disable the welcome screen and allow
|
// Disable the welcome screen and allow
|
||||||
// #define DISABLE_WELCOME_UNSET
|
#define DISABLE_WELCOME_UNSET
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// OLED & Input
|
// OLED & Input
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ float GeoCoord::latLongToMeter(double lat_a, double lng_a, double lat_b, double
|
|||||||
* Latitude of the second point
|
* Latitude of the second point
|
||||||
* @param lon2
|
* @param lon2
|
||||||
* Longitude of the second point
|
* Longitude of the second point
|
||||||
* @return Bearing between the two points in radians. A value of 0 means due
|
* @return Bearing from point 1 to point 2 in radians. A value of 0 means due
|
||||||
* north.
|
* north.
|
||||||
*/
|
*/
|
||||||
float GeoCoord::bearing(double lat1, double lon1, double lat2, double lon2)
|
float GeoCoord::bearing(double lat1, double lon1, double lat2, double lon2)
|
||||||
|
|||||||
@@ -89,26 +89,7 @@ bool NodeDB::resetRadioConfig()
|
|||||||
|
|
||||||
// radioConfig.has_preferences = true;
|
// radioConfig.has_preferences = true;
|
||||||
if (config.device.factory_reset) {
|
if (config.device.factory_reset) {
|
||||||
DEBUG_MSG("Performing factory reset!\n");
|
didFactoryReset = factoryReset();
|
||||||
// first, remove the "/prefs" (this removes most prefs)
|
|
||||||
rmDir("/prefs");
|
|
||||||
// second, install default state (this will deal with the duplicate mac address issue)
|
|
||||||
installDefaultDeviceState();
|
|
||||||
// third, write to disk
|
|
||||||
saveToDisk();
|
|
||||||
#ifndef NO_ESP32
|
|
||||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
|
||||||
nvs_flash_erase();
|
|
||||||
#endif
|
|
||||||
#ifdef NRF52_SERIES
|
|
||||||
Bluefruit.begin();
|
|
||||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
|
||||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
|
||||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
|
||||||
Bluefruit.Periph.clearBonds();
|
|
||||||
Bluefruit.Central.clearBonds();
|
|
||||||
#endif
|
|
||||||
didFactoryReset = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
if (channelFile.channels_count != MAX_NUM_CHANNELS) {
|
||||||
@@ -142,8 +123,33 @@ bool NodeDB::resetRadioConfig()
|
|||||||
return didFactoryReset;
|
return didFactoryReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NodeDB::factoryReset()
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Performing factory reset!\n");
|
||||||
|
// first, remove the "/prefs" (this removes most prefs)
|
||||||
|
rmDir("/prefs");
|
||||||
|
// second, install default state (this will deal with the duplicate mac address issue)
|
||||||
|
installDefaultDeviceState();
|
||||||
|
// third, write to disk
|
||||||
|
saveToDisk();
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||||
|
nvs_flash_erase();
|
||||||
|
#endif
|
||||||
|
#ifdef NRF52_SERIES
|
||||||
|
Bluefruit.begin();
|
||||||
|
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
||||||
|
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
||||||
|
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
||||||
|
Bluefruit.Periph.clearBonds();
|
||||||
|
Bluefruit.Central.clearBonds();
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultConfig()
|
void NodeDB::installDefaultConfig()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default LocalConfig\n");
|
||||||
memset(&config, 0, sizeof(LocalConfig));
|
memset(&config, 0, sizeof(LocalConfig));
|
||||||
config.version = DEVICESTATE_CUR_VER;
|
config.version = DEVICESTATE_CUR_VER;
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
@@ -164,25 +170,28 @@ void NodeDB::installDefaultConfig()
|
|||||||
|
|
||||||
void NodeDB::installDefaultModuleConfig()
|
void NodeDB::installDefaultModuleConfig()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default ModuleConfig\n");
|
||||||
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
||||||
moduleConfig.version = DEVICESTATE_CUR_VER;
|
moduleConfig.version = DEVICESTATE_CUR_VER;
|
||||||
moduleConfig.has_canned_message = true;
|
|
||||||
moduleConfig.has_external_notification = true;
|
|
||||||
moduleConfig.has_mqtt = true;
|
moduleConfig.has_mqtt = true;
|
||||||
moduleConfig.has_range_test = true;
|
moduleConfig.has_range_test = true;
|
||||||
moduleConfig.has_serial = true;
|
moduleConfig.has_serial = true;
|
||||||
moduleConfig.has_store_forward = true;
|
moduleConfig.has_store_forward = true;
|
||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_telemetry = true;
|
||||||
|
moduleConfig.has_external_notification = true;
|
||||||
|
moduleConfig.has_canned_message = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultChannels()
|
void NodeDB::installDefaultChannels()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default ChannelFile\n");
|
||||||
memset(&channelFile, 0, sizeof(ChannelFile));
|
memset(&channelFile, 0, sizeof(ChannelFile));
|
||||||
channelFile.version = DEVICESTATE_CUR_VER;
|
channelFile.version = DEVICESTATE_CUR_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultDeviceState()
|
void NodeDB::installDefaultDeviceState()
|
||||||
{
|
{
|
||||||
|
DEBUG_MSG("Installing default DeviceState\n");
|
||||||
memset(&devicestate, 0, sizeof(DeviceState));
|
memset(&devicestate, 0, sizeof(DeviceState));
|
||||||
|
|
||||||
*numNodes = 0; // Forget node DB
|
*numNodes = 0; // Forget node DB
|
||||||
@@ -209,23 +218,17 @@ void NodeDB::installDefaultDeviceState()
|
|||||||
|
|
||||||
sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
sprintf(owner.id, "!%08x", getNodeNum()); // Default node ID now based on nodenum
|
||||||
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
memcpy(owner.macaddr, ourMacAddr, sizeof(owner.macaddr));
|
||||||
|
|
||||||
installDefaultChannels();
|
|
||||||
installDefaultConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::init()
|
void NodeDB::init()
|
||||||
{
|
{
|
||||||
installDefaultDeviceState();
|
DEBUG_MSG("Initializing NodeDB\n");
|
||||||
|
|
||||||
// saveToDisk();
|
// saveToDisk();
|
||||||
loadFromDisk();
|
loadFromDisk();
|
||||||
// saveToDisk();
|
|
||||||
|
|
||||||
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
||||||
|
|
||||||
myNodeInfo.error_code =
|
myNodeInfo.error_code = CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash)
|
||||||
CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash)
|
|
||||||
myNodeInfo.error_address = 0;
|
myNodeInfo.error_address = 0;
|
||||||
|
|
||||||
// likewise - we always want the app requirements to come from the running appload
|
// likewise - we always want the app requirements to come from the running appload
|
||||||
@@ -259,8 +262,8 @@ void NodeDB::init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
resetRadioConfig(); // If bogus settings got saved, then fix them
|
resetRadioConfig(); // If bogus settings got saved, then fix them
|
||||||
|
|
||||||
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
||||||
|
saveToDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We reserve a few nodenums for future use
|
// We reserve a few nodenums for future use
|
||||||
@@ -290,10 +293,10 @@ void NodeDB::pickNewNodeNum()
|
|||||||
myNodeInfo.my_node_num = r;
|
myNodeInfo.my_node_num = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *preffile = "/prefs/db.proto";
|
static const char *prefFileName = "/prefs/db.proto";
|
||||||
static const char *configfile = "/prefs/config.proto";
|
static const char *configFileName = "/prefs/config.proto";
|
||||||
static const char *moduleConfigfile = "/prefs/module.proto";
|
static const char *moduleConfigFileName = "/prefs/module.proto";
|
||||||
static const char *channelfile = "/prefs/channels.proto";
|
static const char *channelFileName = "/prefs/channels.proto";
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||||
@@ -330,7 +333,7 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
void NodeDB::loadFromDisk()
|
void NodeDB::loadFromDisk()
|
||||||
{
|
{
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
if (!loadProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate)) {
|
if (!loadProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate)) {
|
||||||
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -353,7 +356,7 @@ void NodeDB::loadFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
|
if (!loadProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
|
||||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (config.version < DEVICESTATE_MIN_VER) {
|
if (config.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -364,7 +367,7 @@ void NodeDB::loadFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(moduleConfigfile, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig)) {
|
if (!loadProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig)) {
|
||||||
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -375,7 +378,7 @@ void NodeDB::loadFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
if (!loadProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -428,7 +431,7 @@ void NodeDB::saveChannelsToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(channelfile, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
saveProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +441,7 @@ void NodeDB::saveToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(preffile, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
||||||
|
|
||||||
// save all config segments
|
// save all config segments
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
@@ -447,7 +450,7 @@ void NodeDB::saveToDisk()
|
|||||||
config.has_position = true;
|
config.has_position = true;
|
||||||
config.has_power = true;
|
config.has_power = true;
|
||||||
config.has_wifi = true;
|
config.has_wifi = true;
|
||||||
saveProto(configfile, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
|
saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
|
||||||
|
|
||||||
moduleConfig.has_canned_message = true;
|
moduleConfig.has_canned_message = true;
|
||||||
moduleConfig.has_external_notification = true;
|
moduleConfig.has_external_notification = true;
|
||||||
@@ -456,10 +459,9 @@ void NodeDB::saveToDisk()
|
|||||||
moduleConfig.has_serial = true;
|
moduleConfig.has_serial = true;
|
||||||
moduleConfig.has_store_forward = true;
|
moduleConfig.has_store_forward = true;
|
||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_telemetry = true;
|
||||||
saveProto(moduleConfigfile, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig);
|
saveProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig);
|
||||||
|
|
||||||
saveChannelsToDisk();
|
saveChannelsToDisk();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ class NodeDB
|
|||||||
newStatus.notifyObservers(&status);
|
newStatus.notifyObservers(&status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool factoryReset();
|
||||||
|
|
||||||
/// read our db from flash
|
/// read our db from flash
|
||||||
void loadFromDisk();
|
void loadFromDisk();
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,15 @@ const RegionInfo regions[] = {
|
|||||||
https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true
|
https://www.legislation.gov.uk/uksi/1999/930/schedule/6/part/III/made/data.xht?view=snippet&wrap=true
|
||||||
|
|
||||||
audio_permitted = false per regulation
|
audio_permitted = false per regulation
|
||||||
|
|
||||||
|
Special Note:
|
||||||
|
The link above describes LoRaWAN's band plan, stating a power limit of 16 dBm. This is their own suggested specification,
|
||||||
|
we do not need to follow it. The European Union regulations clearly state that the power limit for this frequency range is 500 mW, or 27 dBm.
|
||||||
|
It also states that we can use interference avoidance and spectrum access techniques to avoid a duty cycle.
|
||||||
|
(Please refer to section 4.21 in the following document)
|
||||||
|
https://ec.europa.eu/growth/tools-databases/tris/index.cfm/ro/search/?trisaction=search.detail&year=2021&num=528&dLang=EN
|
||||||
*/
|
*/
|
||||||
RDEF(EU868, 869.4f, 869.65f, 10, 0, 16, false, false),
|
RDEF(EU868, 869.4f, 869.65f, 10, 0, 27, false, false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
|
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
|
||||||
@@ -414,14 +421,18 @@ void RadioInterface::applyModemConfig()
|
|||||||
// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
|
// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
|
||||||
const char *channelName = channels.getName(channels.getPrimaryIndex());
|
const char *channelName = channels.getName(channels.getPrimaryIndex());
|
||||||
int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels;
|
int channel_num = channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelName) % numChannels;
|
||||||
float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
|
||||||
|
// Old frequency selection formula
|
||||||
|
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
||||||
|
|
||||||
|
// New frequency selection formula
|
||||||
|
float freq = myRegion->freqStart + (bw / 2) + ( channel_num * bw);
|
||||||
|
|
||||||
saveChannelNum(channel_num);
|
saveChannelNum(channel_num);
|
||||||
saveFreq(freq);
|
saveFreq(freq + config.lora.frequency_offset);
|
||||||
|
|
||||||
DEBUG_MSG("Set radio: name=%s, config=%u, ch=%d, power=%d\n", channelName, loraConfig.modem_preset, channel_num, power);
|
DEBUG_MSG("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset, channel_num, power);
|
||||||
DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd,
|
DEBUG_MSG("Radio myRegion->freqStart / myRegion->freqEnd: %f -> %f (%f mhz)\n", myRegion->freqStart, myRegion->freqEnd, myRegion->freqEnd - myRegion->freqStart);
|
||||||
myRegion->freqEnd - myRegion->freqStart);
|
|
||||||
DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels);
|
DEBUG_MSG("Radio myRegion->numChannels: %d\n", numChannels);
|
||||||
DEBUG_MSG("Radio channel_num: %d\n", channel_num);
|
DEBUG_MSG("Radio channel_num: %d\n", channel_num);
|
||||||
DEBUG_MSG("Radio frequency: %f\n", getFreq());
|
DEBUG_MSG("Radio frequency: %f\n", getFreq());
|
||||||
|
|||||||
@@ -171,23 +171,26 @@ int32_t PositionModule::runOnce()
|
|||||||
|
|
||||||
// Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear.
|
// Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear.
|
||||||
const float distanceTravelMath = 1203 / (sqrt(pow(myNodeInfo.bitrate, 1.5) / 1.1));
|
const float distanceTravelMath = 1203 / (sqrt(pow(myNodeInfo.bitrate, 1.5) / 1.1));
|
||||||
uint32_t distanceTravel =
|
uint32_t distanceTravelThreshold =
|
||||||
(distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum;
|
(distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum;
|
||||||
|
|
||||||
// Yes, this has a bunch of magic numbers. Sorry.
|
// Yes, this has a bunch of magic numbers. Sorry.
|
||||||
uint32_t timeTravel =
|
uint32_t timeTravel =
|
||||||
((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum;
|
((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum;
|
||||||
|
// If the distance traveled since the last update is greater than distanceTravelMinimum meters
|
||||||
// If the distance traveled since the last update is greater than 100 meters
|
// and it's been at least timeTravelMinimum seconds since the last update
|
||||||
// and it's been at least 60 seconds since the last update
|
if ((abs(distance) >= distanceTravelThreshold) && (now - lastGpsSend) >= (timeTravel * 1000)) {
|
||||||
if ((abs(distance) >= distanceTravel) && (now - lastGpsSend >= timeTravel * 1000)) {
|
|
||||||
bool requestReplies = currentGeneration != radioGeneration;
|
bool requestReplies = currentGeneration != radioGeneration;
|
||||||
currentGeneration = radioGeneration;
|
currentGeneration = radioGeneration;
|
||||||
|
|
||||||
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, dt=%d, tt=%d)\n", node2->position.pos_timestamp,
|
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, d=%d, dtt=%d, tt=%d)\n", node2->position.pos_timestamp,
|
||||||
requestReplies, distanceTravel, timeTravel);
|
requestReplies, distance, distanceTravelThreshold, timeTravel);
|
||||||
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
sendOurPosition(NODENUM_BROADCAST, requestReplies);
|
||||||
|
|
||||||
|
// Set the current coords as our last ones, after we've compared distance with current and decided to send
|
||||||
|
lastGpsLatitude = node->position.latitude_i;
|
||||||
|
lastGpsLongitude = node->position.longitude_i;
|
||||||
|
|
||||||
/* Update lastGpsSend to now. This means if the device is stationary, then
|
/* Update lastGpsSend to now. This means if the device is stationary, then
|
||||||
getPref_position_broadcast_secs will still apply.
|
getPref_position_broadcast_secs will still apply.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -196,11 +196,13 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
|
|||||||
}
|
}
|
||||||
display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)");
|
display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)");
|
||||||
display->drawString(x, y += fontHeight(FONT_SMALL) - 2,
|
display->drawString(x, y += fontHeight(FONT_SMALL) - 2,
|
||||||
"Temp/Hum: " + last_temp + " / " +
|
"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%");
|
||||||
String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%");
|
|
||||||
if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0)
|
if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0)
|
||||||
display->drawString(x, y += fontHeight(FONT_SMALL),
|
display->drawString(x, y += fontHeight(FONT_SMALL),
|
||||||
"Press: " + String(lastMeasurement.variant.environment_metrics.barometric_pressure, 0) + "hPA");
|
"Press: " + String(lastMeasurement.variant.environment_metrics.barometric_pressure, 0) + "hPA");
|
||||||
|
if (lastMeasurement.variant.environment_metrics.voltage != 0)
|
||||||
|
display->drawString(x, y += fontHeight(FONT_SMALL),
|
||||||
|
"Volt/Cur: " + String(lastMeasurement.variant.environment_metrics.voltage, 0) + "V / " + String(lastMeasurement.variant.environment_metrics.current, 0) + "mA");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnvironmentTelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *t)
|
bool EnvironmentTelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *t)
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ class RangeTestModuleRadio : public SinglePortModule
|
|||||||
uint32_t lastRxID = 0;
|
uint32_t lastRxID = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RangeTestModuleRadio() : SinglePortModule("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP) {}
|
RangeTestModuleRadio() : SinglePortModule("RangeTestModuleRadio", PortNum_TEXT_MESSAGE_APP)
|
||||||
|
{
|
||||||
|
loopbackOk = true; // Allow locally generated messages to loop back to the client
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our payload into the mesh
|
* Send our payload into the mesh
|
||||||
@@ -50,7 +53,8 @@ class RangeTestModuleRadio : public SinglePortModule
|
|||||||
|
|
||||||
/** Called to handle a particular incoming message
|
/** Called to handle a particular incoming message
|
||||||
|
|
||||||
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for it
|
@return ProcessMessage::STOP if you've guaranteed you've handled this message and no other handlers should be considered for
|
||||||
|
it
|
||||||
*/
|
*/
|
||||||
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
virtual ProcessMessage handleReceived(const MeshPacket &mp) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ String MQTT::downstreamPacketToJson(MeshPacket *mp)
|
|||||||
{"payload", msgPayload}};
|
{"payload", msgPayload}};
|
||||||
|
|
||||||
// serialize and return it
|
// serialize and return it
|
||||||
std::string jsonStr = jsonObj.dump();
|
static std::string jsonStr = jsonObj.dump();
|
||||||
DEBUG_MSG("serialized json message: %s\n", jsonStr.c_str());
|
DEBUG_MSG("serialized json message: %s\n", jsonStr.c_str());
|
||||||
|
|
||||||
return jsonStr.c_str();
|
return jsonStr.c_str();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 1
|
major = 1
|
||||||
minor = 3
|
minor = 3
|
||||||
build = 22
|
build = 26
|
||||||
|
|||||||
Reference in New Issue
Block a user