mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
Merge branch 'master' into dev
This commit is contained in:
@@ -106,7 +106,7 @@ bool RadioInterface::init()
|
||||
* djb2 by Dan Bernstein.
|
||||
* http://www.cse.yorku.ca/~oz/hash.html
|
||||
*/
|
||||
unsigned long hash(char *str)
|
||||
unsigned long hash(const char *str)
|
||||
{
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
@@ -117,8 +117,6 @@ unsigned long hash(char *str)
|
||||
return hash;
|
||||
}
|
||||
|
||||
#define POWER_DEFAULT 17
|
||||
|
||||
/**
|
||||
* Pull our channel settings etc... from protobufs to the dumb interface settings
|
||||
*/
|
||||
@@ -128,8 +126,6 @@ void RadioInterface::applyModemConfig()
|
||||
// No Sync Words in LORA mode
|
||||
|
||||
power = channelSettings.tx_power;
|
||||
if (power == 0)
|
||||
power = POWER_DEFAULT;
|
||||
|
||||
// If user has manually specified a channel num, then use that, otherwise generate one by hashing the name
|
||||
int channel_num = (channelSettings.channel_num ? channelSettings.channel_num - 1 : hash(channelSettings.name)) % NUM_CHANNELS;
|
||||
@@ -139,6 +135,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");
|
||||
|
||||
Reference in New Issue
Block a user