mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 18:22:32 +00:00
Enable telemetry and I2C sensors on STM32WL (except accelerometers) (#7008)
* Update platformio inis for stm32 platform and wio-e5 variant for enabling i2c * Don't reference timezone functions if MESHTASTIC_EXCLUDE_TZ is defined * Use custom pow_of_two in RadioInterface instead of floating-point pow() * First pass: enable sensors for STM32wL * Fix AirQualityTelemetryModule being created if the PM25AQI header is missing * Link in power sensor libraries * more ini tweaks * Add =1 to EXCLUDE defines, fix indentation. * Drop HAS_WIRE in ini, it's defined in architecture.h * Fix build when power sensor libraries are missing Make MAX sensor integration into Power.cpp optional based on its library header existing. Also make NullSensor expose a voltage and current sensor, because Power calls directly into these for INA sensors. This lets us remove all the deps for the STM32WL platform. * Change default I2C for RAK3172 to be I2C1, not I2C2 * Respect the laws of mathematics (oops)
This commit is contained in:
@@ -12,6 +12,12 @@
|
||||
#include <pb_decode.h>
|
||||
#include <pb_encode.h>
|
||||
|
||||
// Calculate 2^n without calling pow()
|
||||
uint32_t pow_of_2(uint32_t n)
|
||||
{
|
||||
return 1 << n;
|
||||
}
|
||||
|
||||
#define RDEF(name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, frequency_switching, wide_lora) \
|
||||
{ \
|
||||
meshtastic_Config_LoRaConfig_RegionCode_##name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, \
|
||||
@@ -246,7 +252,7 @@ uint32_t RadioInterface::getRetransmissionMsec(const meshtastic_MeshPacket *p)
|
||||
float channelUtil = airTime->channelUtilizationPercent();
|
||||
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||
// Assuming we pick max. of CWsize and there will be a client with SNR at half the range
|
||||
return 2 * packetAirtime + (pow(2, CWsize) + 2 * CWmax + pow(2, int((CWmax + CWmin) / 2))) * slotTimeMsec +
|
||||
return 2 * packetAirtime + (pow_of_2(CWsize) + 2 * CWmax + pow_of_2(int((CWmax + CWmin) / 2))) * slotTimeMsec +
|
||||
PROCESSING_TIME_MSEC;
|
||||
}
|
||||
|
||||
@@ -259,7 +265,7 @@ uint32_t RadioInterface::getTxDelayMsec()
|
||||
float channelUtil = airTime->channelUtilizationPercent();
|
||||
uint8_t CWsize = map(channelUtil, 0, 100, CWmin, CWmax);
|
||||
// LOG_DEBUG("Current channel utilization is %f so setting CWsize to %d", channelUtil, CWsize);
|
||||
return random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||
return random(0, pow_of_2(CWsize)) * slotTimeMsec;
|
||||
}
|
||||
|
||||
/** The CW size to use when calculating SNR_based delays */
|
||||
@@ -279,7 +285,7 @@ uint32_t RadioInterface::getTxDelayMsecWeightedWorst(float snr)
|
||||
{
|
||||
uint8_t CWsize = getCWsize(snr);
|
||||
// offset the maximum delay for routers: (2 * CWmax * slotTimeMsec)
|
||||
return (2 * CWmax * slotTimeMsec) + pow(2, CWsize) * slotTimeMsec;
|
||||
return (2 * CWmax * slotTimeMsec) + pow_of_2(CWsize) * slotTimeMsec;
|
||||
}
|
||||
|
||||
/** The delay to use when we want to flood a message */
|
||||
@@ -296,7 +302,7 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||
LOG_DEBUG("rx_snr found in packet. Router: setting tx delay:%d", delay);
|
||||
} else {
|
||||
// offset the maximum delay for routers: (2 * CWmax * slotTimeMsec)
|
||||
delay = (2 * CWmax * slotTimeMsec) + random(0, pow(2, CWsize)) * slotTimeMsec;
|
||||
delay = (2 * CWmax * slotTimeMsec) + random(0, pow_of_2(CWsize)) * slotTimeMsec;
|
||||
LOG_DEBUG("rx_snr found in packet. Setting tx delay:%d", delay);
|
||||
}
|
||||
|
||||
@@ -596,7 +602,7 @@ void RadioInterface::applyModemConfig()
|
||||
uint32_t RadioInterface::computeSlotTimeMsec()
|
||||
{
|
||||
float sumPropagationTurnaroundMACTime = 0.2 + 0.4 + 7; // in milliseconds
|
||||
float symbolTime = pow(2, sf) / bw; // in milliseconds
|
||||
float symbolTime = pow_of_2(sf) / bw; // in milliseconds
|
||||
|
||||
if (myRegion->wideLora) {
|
||||
// CAD duration derived from AN1200.22 of SX1280
|
||||
|
||||
Reference in New Issue
Block a user