Skip to content

Commit

Permalink
add ignore_direct radio testing option
Browse files Browse the repository at this point in the history
This allows to exercise the meshing at a hardware level while the devices are meters appart and I find that useful while testing.
  • Loading branch information
Jorropo committed Dec 5, 2024
1 parent c3d6034 commit bb5ab39
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,14 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p)
return;
}

for (int i = 0; i < config.lora.ignore_direct.size; i++) {
if (p->from & 0xff == config.lora.ignore_direct.bytes[i]) {
LOG_DEBUG("Ignore direct msg, 0x%x matches our direct ignore list", p->from);
packetPool.release(p);
return;
}
}

meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->from);
if (node != NULL && node->is_ignored) {
LOG_DEBUG("Ignore msg, 0x%x is ignored", p->from);
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/generated/meshtastic/apponly.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern const pb_msgdesc_t meshtastic_ChannelSet_msg;

/* Maximum encoded size of messages (where known) */
#define MESHTASTIC_MESHTASTIC_APPONLY_PB_H_MAX_SIZE meshtastic_ChannelSet_size
#define meshtastic_ChannelSet_size 679
#define meshtastic_ChannelSet_size 685

#ifdef __cplusplus
} /* extern "C" */
Expand Down
16 changes: 12 additions & 4 deletions src/mesh/generated/meshtastic/config.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ typedef struct _meshtastic_Config_DisplayConfig {
meshtastic_Config_DisplayConfig_CompassOrientation compass_orientation;
} meshtastic_Config_DisplayConfig;

typedef PB_BYTES_ARRAY_T(3) meshtastic_Config_LoRaConfig_ignore_direct_t;
/* Lora Config */
typedef struct _meshtastic_Config_LoRaConfig {
/* When enabled, the `modem_preset` fields will be adhered to, else the `bandwidth`/`spread_factor`/`coding_rate`
Expand Down Expand Up @@ -524,6 +525,11 @@ typedef struct _meshtastic_Config_LoRaConfig {
bool ignore_mqtt;
/* Sets the ok_to_mqtt bit on outgoing packets */
bool config_ok_to_mqtt;
/* For testing this simulate a node which cannot be heared directly.
All comunications received from this node will be dropped.
Due to space constraints in the header, only the last byte of
the relayer is transmited, thus only the last byte can be checked. */
meshtastic_Config_LoRaConfig_ignore_direct_t ignore_direct;
} meshtastic_Config_LoRaConfig;

typedef struct _meshtastic_Config_BluetoothConfig {
Expand Down Expand Up @@ -671,7 +677,7 @@ extern "C" {
#define meshtastic_Config_NetworkConfig_init_default {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_default, ""}
#define meshtastic_Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0}
#define meshtastic_Config_DisplayConfig_init_default {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0, _meshtastic_Config_DisplayConfig_CompassOrientation_MIN}
#define meshtastic_Config_LoRaConfig_init_default {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0}
#define meshtastic_Config_LoRaConfig_init_default {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, {0, {0}}}
#define meshtastic_Config_BluetoothConfig_init_default {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0}
#define meshtastic_Config_SecurityConfig_init_default {{0, {0}}, {0, {0}}, 0, {{0, {0}}, {0, {0}}, {0, {0}}}, 0, 0, 0, 0}
#define meshtastic_Config_SessionkeyConfig_init_default {0}
Expand All @@ -682,7 +688,7 @@ extern "C" {
#define meshtastic_Config_NetworkConfig_init_zero {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_zero, ""}
#define meshtastic_Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0}
#define meshtastic_Config_DisplayConfig_init_zero {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0, _meshtastic_Config_DisplayConfig_CompassOrientation_MIN}
#define meshtastic_Config_LoRaConfig_init_zero {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0}
#define meshtastic_Config_LoRaConfig_init_zero {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, {0, {0}}}
#define meshtastic_Config_BluetoothConfig_init_zero {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0}
#define meshtastic_Config_SecurityConfig_init_zero {{0, {0}}, {0, {0}}, 0, {{0, {0}}, {0, {0}}, {0, {0}}}, 0, 0, 0, 0}
#define meshtastic_Config_SessionkeyConfig_init_zero {0}
Expand Down Expand Up @@ -762,6 +768,7 @@ extern "C" {
#define meshtastic_Config_LoRaConfig_ignore_incoming_tag 103
#define meshtastic_Config_LoRaConfig_ignore_mqtt_tag 104
#define meshtastic_Config_LoRaConfig_config_ok_to_mqtt_tag 105
#define meshtastic_Config_LoRaConfig_ignore_direct_tag 106
#define meshtastic_Config_BluetoothConfig_enabled_tag 1
#define meshtastic_Config_BluetoothConfig_mode_tag 2
#define meshtastic_Config_BluetoothConfig_fixed_pin_tag 3
Expand Down Expand Up @@ -907,7 +914,8 @@ X(a, STATIC, SINGULAR, FLOAT, override_frequency, 14) \
X(a, STATIC, SINGULAR, BOOL, pa_fan_disabled, 15) \
X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \
X(a, STATIC, SINGULAR, BOOL, ignore_mqtt, 104) \
X(a, STATIC, SINGULAR, BOOL, config_ok_to_mqtt, 105)
X(a, STATIC, SINGULAR, BOOL, config_ok_to_mqtt, 105) \
X(a, STATIC, SINGULAR, BYTES, ignore_direct, 106)
#define meshtastic_Config_LoRaConfig_CALLBACK NULL
#define meshtastic_Config_LoRaConfig_DEFAULT NULL

Expand Down Expand Up @@ -964,7 +972,7 @@ extern const pb_msgdesc_t meshtastic_Config_SessionkeyConfig_msg;
#define meshtastic_Config_BluetoothConfig_size 10
#define meshtastic_Config_DeviceConfig_size 98
#define meshtastic_Config_DisplayConfig_size 30
#define meshtastic_Config_LoRaConfig_size 85
#define meshtastic_Config_LoRaConfig_size 91
#define meshtastic_Config_NetworkConfig_IpV4Config_size 20
#define meshtastic_Config_NetworkConfig_size 196
#define meshtastic_Config_PositionConfig_size 62
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/generated/meshtastic/localonly.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg;

/* Maximum encoded size of messages (where known) */
#define MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_MAX_SIZE meshtastic_LocalConfig_size
#define meshtastic_LocalConfig_size 735
#define meshtastic_LocalConfig_size 741
#define meshtastic_LocalModuleConfig_size 699

#ifdef __cplusplus
Expand Down

0 comments on commit bb5ab39

Please sign in to comment.