Skip to content

Commit

Permalink
fix #346 limit tx power in japan
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Sep 16, 2020
1 parent 7d4058f commit c6d93d1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mesh/RF95Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ bool RF95Interface::init()
if (power > MAX_POWER) // This chip has lower power limits than some
power = MAX_POWER;

limitPower();

iface = lora = new RadioLibRF95(&module);

#ifdef RF95_TCXO
Expand Down
19 changes: 19 additions & 0 deletions src/mesh/RadioInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ void RadioInterface::applyModemConfig()
power);
}

/**
* Some regulatory regions limit xmit power.
* This function should be called by subclasses after setting their desired power. It might lower it
*/
void RadioInterface::limitPower()
{
uint8_t maxPower = 255; // No limit

#ifdef HW_VERSION_JP
maxPower = 13; // See https://github.com/meshtastic/Meshtastic-device/issues/346
#endif
if (power > maxPower) {
DEBUG_MSG("Lowering transmit power because of regulatory limits\n");
power = maxPower;
}

DEBUG_MSG("Set radio: final power level=%d\n", power);
}

ErrorCode SimRadio::send(MeshPacket *p)
{
DEBUG_MSG("SimRadio.send\n");
Expand Down
6 changes: 6 additions & 0 deletions src/mesh/RadioInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class RadioInterface : protected concurrency::NotifiedWorkerThread

virtual void loop() {} // Idle processing

/**
* Some regulatory regions limit xmit power.
* This function should be called by subclasses after setting their desired power. It might lower it
*/
void limitPower();

/**
* Convert our modemConfig enum into wf, sf, etc...
*
Expand Down
3 changes: 3 additions & 0 deletions src/mesh/SX1262Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ bool SX1262Interface::init()

if (power > 22) // This chip has lower power limits than some
power = 22;

limitPower();

int res = lora.begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength, tcxoVoltage, useRegulatorLDO);
DEBUG_MSG("SX1262 init result %d\n", res);

Expand Down

0 comments on commit c6d93d1

Please sign in to comment.