Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch up #2282

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b1677e0
Rebroadcast mode to local_only for hams
thebentern Feb 9, 2023
4375a01
Remove setOwner's business logic for licensed operation
thebentern Feb 9, 2023
aaba99f
Add changed back
thebentern Feb 9, 2023
dc6f6af
Update to Espressif32 Platform 6.0 and ESP-IDF 5.0
caveman99 Feb 9, 2023
83e309f
label boards as secondary to split the core firmware archive by suppo…
caveman99 Feb 10, 2023
7100416
Add short_name
thebentern Feb 10, 2023
fcbeeac
[create-pull-request] automated change
thebentern Feb 10, 2023
09f2ea8
Portduino isn't extra. It's extra special
thebentern Feb 10, 2023
a280d7f
Guard simulator handling with HAS_RADIO flag
GUVWAF Feb 11, 2023
680550b
Add HAS_SENSOR flag
GUVWAF Feb 11, 2023
03f584a
Add HAS_TELEMETRY to portduino
GUVWAF Feb 11, 2023
97c1cf6
SimRadio in separate thread
GUVWAF Feb 11, 2023
7063acd
Ignore syslog on portduino
GUVWAF Feb 11, 2023
abf3a58
trunk fmt
GUVWAF Feb 11, 2023
4061870
Don't need a Portduino guard clause here as it will not be compiled
GUVWAF Feb 11, 2023
f95061b
Merge branch 'master' into create-pull-request/patch
thebentern Feb 11, 2023
dbb827e
Merge pull request #2271 from meshtastic/create-pull-request/patch
thebentern Feb 11, 2023
0f47584
Merge branch 'master' into portduinoDeviceTelemetry
thebentern Feb 11, 2023
40d98b9
Merge pull request #2272 from GUVWAF/portduinoDeviceTelemetry
GUVWAF Feb 11, 2023
5cadcd3
Send DeviceTelemetry only after NodeInfo is sent
GUVWAF Feb 11, 2023
5f28ef6
When hearing a node we don't know, send NodeInfo and ask for response
GUVWAF Feb 11, 2023
2d2633d
Increase default NodeInfo broadcast to 3 hours
GUVWAF Feb 11, 2023
16852da
Set node_info_broadcast_secs to 3 hours instead of default_broadcast_…
GUVWAF Feb 11, 2023
c834252
Check if nodeInfoModule exists (e.g. for Repeater)
GUVWAF Feb 11, 2023
5ca3d91
Only set node_info_broadcast_secs when not a Router
GUVWAF Feb 11, 2023
3f47804
Merge pull request #2274 from GUVWAF/roleFixes
thebentern Feb 12, 2023
b7895f7
Sanity check for sending NodeInfo
GUVWAF Feb 15, 2023
2aabeaf
Merge branch 'master' into NodeInfoSanityCheck
thebentern Feb 15, 2023
cbfa2dc
Merge pull request #2276 from GUVWAF/NodeInfoSanityCheck
thebentern Feb 16, 2023
3ae1fdf
Add metadata to phone api want config messages
thebentern Feb 16, 2023
b78e0dc
Merge branch 'master' into metadata-phone-api
thebentern Feb 16, 2023
2e6e064
Move it around and kill old device metadata gen
thebentern Feb 16, 2023
b3fac71
Missed some stuff
thebentern Feb 16, 2023
221a145
Whoops
thebentern Feb 16, 2023
07b90a6
For science
thebentern Feb 16, 2023
8aede61
Fix setting preambleLength for SX127x
GUVWAF Feb 16, 2023
5c72967
Merge pull request #2278 from meshtastic/metadata-phone-api
thebentern Feb 17, 2023
cef1196
Merge branch 'master' into preamble-halving
thebentern Feb 17, 2023
6432371
Regen protos
thebentern Feb 17, 2023
6f4ac90
Merge branch 'master' into preamble-halving
thebentern Feb 17, 2023
c396454
Merge pull request #2279 from meshtastic/preamble-halving
thebentern Feb 17, 2023
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
4 changes: 2 additions & 2 deletions arch/esp32/esp32.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Common settings for ESP targes, mixin with extends = esp32_base
[esp32_base]
extends = arduino_base
platform = platformio/espressif32@^5.2.0
platform = platformio/espressif32@^6.0.0
build_src_filter =
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
upload_speed = 921600
Expand All @@ -26,7 +26,7 @@ build_flags =
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
-DDEBUG_HEAP
;-DDEBUG_HEAP

lib_deps =
${arduino_base.lib_deps}
Expand Down
4 changes: 2 additions & 2 deletions arch/esp32/esp32s2.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[esp32s2_base]
extends = arduino_base
platform = platformio/espressif32@^5.2.0
platform = platformio/espressif32@^6.0.0
build_src_filter =
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/> -<nimble/>
upload_speed = 961200
Expand All @@ -27,7 +27,7 @@ build_flags =
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
-DHAS_BLUETOOTH=0
-DDEBUG_HEAP
;-DDEBUG_HEAP

lib_deps =
${arduino_base.lib_deps}
Expand Down
4 changes: 2 additions & 2 deletions arch/esp32/esp32s3.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[esp32s3_base]
extends = arduino_base
platform = platformio/espressif32@^5.2.0
platform = platformio/espressif32@^6.0.0
build_src_filter =
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
upload_speed = 961200
Expand All @@ -26,7 +26,7 @@ build_flags =
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
-DDEBUG_HEAP
;-DDEBUG_HEAP

lib_deps =
${arduino_base.lib_deps}
Expand Down
4 changes: 3 additions & 1 deletion arch/portduino/portduino.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ build_src_filter =
-<mesh/http/>
-<mesh/eth/>
-<modules/esp32>
-<modules/Telemetry>
-<modules/Telemetry/EnvironmentTelemetry.cpp>
-<modules/Telemetry/AirQualityTelemetry.cpp>
-<modules/Telemetry/Sensor>
+<../variants/portduino>
lib_deps =
${env.lib_deps}
Expand Down
2 changes: 1 addition & 1 deletion src/RedirectablePrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
}
r += vprintf(format, arg);

#if HAS_WIFI || HAS_ETHERNET
#if (HAS_WIFI || HAS_ETHERNET) && !defined(ARCH_PORTDUINO)
// if syslog is in use, collect the log messages and send them to syslog
if (syslog.isEnabled()) {
int ll = 0;
Expand Down
41 changes: 28 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ void setup()

// radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init)

#if !HAS_RADIO && defined(ARCH_PORTDUINO)
if (!rIf) {
rIf = new SimRadio;
if (!rIf->init()) {
LOG_WARN("Failed to find simulated radio\n");
delete rIf;
rIf = NULL;
} else {
LOG_INFO("Using SIMULATED radio!\n");
}
}
#endif

#if defined(RF95_IRQ)
if (!rIf) {
rIf = new RF95Interface(RF95_NSS, RF95_IRQ, RF95_RESET, SPI);
Expand Down Expand Up @@ -459,19 +472,6 @@ void setup()
}
#endif

#ifdef ARCH_PORTDUINO
if (!rIf) {
rIf = new SimRadio;
if (!rIf->init()) {
LOG_WARN("Failed to find simulated radio\n");
delete rIf;
rIf = NULL;
} else {
LOG_INFO("Using SIMULATED radio!\n");
}
}
#endif

// check if the radio chip matches the selected region

if ((config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())) {
Expand Down Expand Up @@ -537,6 +537,21 @@ uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to s
// This will supress the current delay and instead try to run ASAP.
bool runASAP;

extern meshtastic_DeviceMetadata getDeviceMetadata()
{
meshtastic_DeviceMetadata deviceMetadata;
strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18);
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN;
deviceMetadata.hasBluetooth = HAS_BLUETOOTH;
deviceMetadata.hasWifi = HAS_WIFI;
deviceMetadata.hasEthernet = HAS_ETHERNET;
deviceMetadata.role = config.device.role;
deviceMetadata.position_flags = config.position.position_flags;
deviceMetadata.hw_model = HW_VENDOR;
return deviceMetadata;
}

void loop()
{
runASAP = false;
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ extern uint32_t serialSinceMsec;
extern bool runASAP;

void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds();

meshtastic_DeviceMetadata getDeviceMetadata();
10 changes: 7 additions & 3 deletions src/mesh/MeshModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)

currentReply = NULL; // No reply yet

bool ignoreRequest = false; // No module asked to ignore the request yet

// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
auto ourNodeNum = nodeDB.getNodeNum();
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
Expand Down Expand Up @@ -135,7 +137,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
// any other node.
if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) {
pi.sendResponse(mp);
LOG_INFO("Module '%s' sent a response\n", pi.name);
ignoreRequest = ignoreRequest || pi.ignoreRequest; // If at least one module asks it, we may ignore a request
LOG_INFO("Asked module '%s' to send a response\n", pi.name);
} else {
LOG_DEBUG("Module '%s' considered\n", pi.name);
}
Expand All @@ -162,8 +165,9 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src)
printPacket("Sending response", currentReply);
service.sendToMesh(currentReply);
currentReply = NULL;
} else if (mp.from != ourNodeNum) {
// Note: if the message started with the local node we don't want to send a no response reply
} else if (mp.from != ourNodeNum && !ignoreRequest) {
// Note: if the message started with the local node or a module asked to ignore the request, we don't want to send a
// no response reply

// No one wanted to reply to this requst, tell the requster that happened
LOG_DEBUG("No one responded, send a nak\n");
Expand Down
3 changes: 3 additions & 0 deletions src/mesh/MeshModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class MeshModule
* flag */
bool encryptedOk = false;

/* We allow modules to ignore a request without sending an error if they have a specific reason for it. */
bool ignoreRequest = false;

/** If a bound channel name is set, we will only accept received packets that come in on that channel.
* A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface
* are allowed on any channel (this lets the local user do anything).
Expand Down
8 changes: 6 additions & 2 deletions src/mesh/MeshService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
{
powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping

printPacket("Forwarding to phone", mp);
nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio
if (!nodeDB.getNode(mp->from)->has_user && nodeInfoModule) {
LOG_INFO("Heard a node we don't know, sending NodeInfo and asking for a response.\n");
nodeInfoModule->sendOurNodeInfo(mp->from, true);
}

printPacket("Forwarding to phone", mp);
sendToPhone((meshtastic_MeshPacket *)mp);

return 0;
Expand Down Expand Up @@ -132,7 +136,7 @@ void MeshService::reloadOwner(bool shouldSave)
*/
void MeshService::handleToRadio(meshtastic_MeshPacket &p)
{
#ifdef ARCH_PORTDUINO
#if defined(ARCH_PORTDUINO) && !HAS_RADIO
// Simulates device is receiving a packet via the LoRa chip
if (p.decoded.portnum == meshtastic_PortNum_SIMULATOR_APP) {
// Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/MeshService.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "MeshTypes.h"
#include "Observer.h"
#include "PointerQueue.h"
#ifdef ARCH_PORTDUINO
#if defined(ARCH_PORTDUINO) && !HAS_RADIO
#include "../platform/portduino/SimRadio.h"
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ void NodeDB::installDefaultConfig()
config.lora.hop_limit = HOP_RELIABLE;
config.position.gps_enabled = true;
config.position.position_broadcast_smart_enabled = true;
if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER)
config.device.node_info_broadcast_secs = 3 * 60 * 60;
config.device.serial_enabled = true;
resetRadioConfig();
strncpy(config.network.ntp_server, "0.pool.ntp.org", 32);
Expand Down
11 changes: 9 additions & 2 deletions src/mesh/PhoneAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "PowerFSM.h"
#include "RadioInterface.h"
#include "configuration.h"
#include "main.h"
#include "xmodem.h"

#if FromRadio_size > MAX_TO_FROM_RADIO_SIZE
Expand Down Expand Up @@ -120,6 +121,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
* STATE_SEND_NODEINFO, // states progress in this order as the device sends to the client
STATE_SEND_CONFIG,
STATE_SEND_MODULE_CONFIG,
STATE_SEND_METADATA,
STATE_SEND_COMPLETE_ID,
STATE_SEND_PACKETS // send packets or debug strings
*/
Expand Down Expand Up @@ -277,11 +279,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
config_state++;
// Advance when we have sent all of our ModuleConfig objects
if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) {
state = STATE_SEND_COMPLETE_ID;
state = STATE_SEND_METADATA;
config_state = 0;
}
break;

case STATE_SEND_METADATA:
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_metadata_tag;
fromRadioScratch.metadata = getDeviceMetadata();
state = STATE_SEND_COMPLETE_ID;
break;
case STATE_SEND_COMPLETE_ID:
LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n");
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
Expand Down Expand Up @@ -361,6 +367,7 @@ bool PhoneAPI::available()
case STATE_SEND_CHANNELS:
case STATE_SEND_CONFIG:
case STATE_SEND_MODULECONFIG:
case STATE_SEND_METADATA:
case STATE_SEND_COMPLETE_ID:
return true;

Expand Down
1 change: 1 addition & 0 deletions src/mesh/PhoneAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PhoneAPI
STATE_SEND_CHANNELS, // Send all channels
STATE_SEND_CONFIG, // Replacement for the old Radioconfig
STATE_SEND_MODULECONFIG, // Send Module specific config
STATE_SEND_METADATA,
STATE_SEND_COMPLETE_ID,
STATE_SEND_PACKETS // send packets or debug strings
};
Expand Down
9 changes: 1 addition & 8 deletions src/mesh/RF95Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,12 @@ bool RF95Interface::init()
#endif
setTransmitEnable(false);

int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength);
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
LOG_INFO("RF95 init result %d\n", res);

LOG_INFO("Frequency set to %f\n", getFreq());
LOG_INFO("Bandwidth set to %f\n", bw);
LOG_INFO("Power output set to %d\n", power);

// current limit was removed from module' ctor
// override default value (60 mA)
res = lora->setCurrentLimit(currentLimit);
LOG_DEBUG("Current limit set to %f\n", currentLimit);
LOG_DEBUG("Current limit set result %d\n", res);

if (res == RADIOLIB_ERR_NONE)
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);

Expand Down
2 changes: 1 addition & 1 deletion src/mesh/RadioInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RadioInterface
- Tx/Rx turnaround time (maximum of SX126x and SX127x);
- MAC processing time (measured on T-beam) */
uint32_t slotTimeMsec = 8.5 * pow(2, sf) / bw + 0.2 + 0.4 + 7;
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
uint16_t preambleLength = 16; // 8 is default, but we use longer to increase the amount of sleep time when receiving
const uint32_t PROCESSING_TIME_MSEC =
4500; // time to construct, process and construct a packet again (empirically determined)
const uint8_t CWmin = 2; // minimum CWsize
Expand Down
13 changes: 8 additions & 5 deletions src/mesh/generated/meshtastic/admin.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <pb.h>
#include "meshtastic/channel.pb.h"
#include "meshtastic/config.pb.h"
#include "meshtastic/device_metadata.pb.h"
#include "meshtastic/mesh.pb.h"
#include "meshtastic/module_config.pb.h"
#include "meshtastic/connection_status.pb.h"
Expand Down Expand Up @@ -67,6 +66,8 @@ typedef struct _meshtastic_HamParameters {
Please respect your local laws, regulations, and band plans.
Ensure your radio is capable of operating of the selected frequency before setting this. */
float frequency;
/* Optional short name of user */
char short_name[6];
} meshtastic_HamParameters;

/* This message is handled by the Admin module and is responsible for all settings/channel read/write operations.
Expand Down Expand Up @@ -169,14 +170,15 @@ extern "C" {

/* Initializer values for message structs */
#define meshtastic_AdminMessage_init_default {0, {0}}
#define meshtastic_HamParameters_init_default {"", 0, 0}
#define meshtastic_HamParameters_init_default {"", 0, 0, ""}
#define meshtastic_AdminMessage_init_zero {0, {0}}
#define meshtastic_HamParameters_init_zero {"", 0, 0}
#define meshtastic_HamParameters_init_zero {"", 0, 0, ""}

/* Field tags (for use in manual encoding/decoding) */
#define meshtastic_HamParameters_call_sign_tag 1
#define meshtastic_HamParameters_tx_power_tag 2
#define meshtastic_HamParameters_frequency_tag 3
#define meshtastic_HamParameters_short_name_tag 4
#define meshtastic_AdminMessage_get_channel_request_tag 1
#define meshtastic_AdminMessage_get_channel_response_tag 2
#define meshtastic_AdminMessage_get_owner_request_tag 3
Expand Down Expand Up @@ -259,7 +261,8 @@ X(a, STATIC, ONEOF, INT32, (payload_variant,nodedb_reset,nodedb_reset),
#define meshtastic_HamParameters_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, STRING, call_sign, 1) \
X(a, STATIC, SINGULAR, INT32, tx_power, 2) \
X(a, STATIC, SINGULAR, FLOAT, frequency, 3)
X(a, STATIC, SINGULAR, FLOAT, frequency, 3) \
X(a, STATIC, SINGULAR, STRING, short_name, 4)
#define meshtastic_HamParameters_CALLBACK NULL
#define meshtastic_HamParameters_DEFAULT NULL

Expand All @@ -272,7 +275,7 @@ extern const pb_msgdesc_t meshtastic_HamParameters_msg;

/* Maximum encoded size of messages (where known) */
#define meshtastic_AdminMessage_size 234
#define meshtastic_HamParameters_size 25
#define meshtastic_HamParameters_size 32

#ifdef __cplusplus
} /* extern "C" */
Expand Down
12 changes: 0 additions & 12 deletions src/mesh/generated/meshtastic/device_metadata.pb.c

This file was deleted.

Loading