mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 18:31:37 +00:00
Weight tx delay to prefer Repeaters as well
This commit is contained in:
parent
0188edb342
commit
dab2bb3bcc
@ -178,9 +178,12 @@ uint32_t RadioInterface::getPacketTime(uint32_t pl)
|
||||
uint32_t RadioInterface::getPacketTime(meshtastic_MeshPacket *p)
|
||||
{
|
||||
uint32_t pl = 0;
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag) {
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag)
|
||||
{
|
||||
pl = p->encrypted.size + sizeof(PacketHeader);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), &meshtastic_Data_msg, &p->decoded);
|
||||
pl = numbytes + sizeof(PacketHeader);
|
||||
}
|
||||
@ -227,10 +230,14 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
|
||||
// LOG_DEBUG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT) {
|
||||
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT ||
|
||||
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
|
||||
{
|
||||
delay = random(0, 2 * CWsize) * slotTimeMsec;
|
||||
LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||
LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d\n", delay);
|
||||
}
|
||||
@ -242,7 +249,8 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
||||
{
|
||||
LOG_DEBUG("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff,
|
||||
p->want_ack, p->hop_limit, p->channel);
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag)
|
||||
{
|
||||
auto &s = p->decoded;
|
||||
|
||||
LOG_DEBUG(" Portnum=%d", s.portnum);
|
||||
@ -264,17 +272,22 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
||||
LOG_DEBUG(" successId=%08x", s.ackVariant.success_id);
|
||||
else if (s.which_ackVariant == SubPacket_fail_id_tag)
|
||||
LOG_DEBUG(" failId=%08x", s.ackVariant.fail_id); */
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG(" encrypted");
|
||||
}
|
||||
|
||||
if (p->rx_time != 0) {
|
||||
if (p->rx_time != 0)
|
||||
{
|
||||
LOG_DEBUG(" rxtime=%u", p->rx_time);
|
||||
}
|
||||
if (p->rx_snr != 0.0) {
|
||||
if (p->rx_snr != 0.0)
|
||||
{
|
||||
LOG_DEBUG(" rxSNR=%g", p->rx_snr);
|
||||
}
|
||||
if (p->rx_rssi != 0) {
|
||||
if (p->rx_rssi != 0)
|
||||
{
|
||||
LOG_DEBUG(" rxRSSI=%i", p->rx_rssi);
|
||||
}
|
||||
if (p->priority != 0)
|
||||
@ -373,9 +386,11 @@ void RadioInterface::applyModemConfig()
|
||||
// Set up default configuration
|
||||
// No Sync Words in LORA mode
|
||||
meshtastic_Config_LoRaConfig &loraConfig = config.lora;
|
||||
if (loraConfig.use_preset) {
|
||||
if (loraConfig.use_preset)
|
||||
{
|
||||
|
||||
switch (loraConfig.modem_preset) {
|
||||
switch (loraConfig.modem_preset)
|
||||
{
|
||||
case meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST:
|
||||
bw = (myRegion->wideLora) ? 812.5 : 250;
|
||||
cr = 8;
|
||||
@ -417,7 +432,9 @@ void RadioInterface::applyModemConfig()
|
||||
sf = 12;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sf = loraConfig.spread_factor;
|
||||
cr = loraConfig.coding_rate;
|
||||
bw = loraConfig.bandwidth;
|
||||
@ -485,7 +502,8 @@ void RadioInterface::limitPower()
|
||||
if (myRegion->powerLimit)
|
||||
maxPower = myRegion->powerLimit;
|
||||
|
||||
if ((power > maxPower) && !devicestate.owner.is_licensed) {
|
||||
if ((power > maxPower) && !devicestate.owner.is_licensed)
|
||||
{
|
||||
LOG_INFO("Lowering transmit power because of regulatory limits\n");
|
||||
power = maxPower;
|
||||
}
|
||||
@ -517,7 +535,8 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
|
||||
h->to = p->to;
|
||||
h->id = p->id;
|
||||
h->channel = p->channel;
|
||||
if (p->hop_limit > HOP_MAX) {
|
||||
if (p->hop_limit > HOP_MAX)
|
||||
{
|
||||
LOG_WARN("hop limit %d is too high, setting to %d\n", p->hop_limit, HOP_MAX);
|
||||
p->hop_limit = HOP_MAX;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user