make clang-format happy again. Also fix assorted variable shrouding and logic bleeps

This commit is contained in:
Thomas Göttgens 2024-05-03 15:10:57 +02:00
parent 9fb6148aff
commit 13ad524538
9 changed files with 22 additions and 26 deletions

View File

@ -62,10 +62,10 @@ void GPS::CASChecksum(uint8_t *message, size_t length)
// Iterate over the payload as a series of uint32_t's and // Iterate over the payload as a series of uint32_t's and
// accumulate the cksum // accumulate the cksum
uint32_t *payload = (uint32_t *)(message + 6); uint32_t const *payload = (uint32_t *)(message + 6);
for (size_t i = 0; i < (length - 10) / 4; i++) { for (size_t i = 0; i < (length - 10) / 4; i++) {
uint32_t p = payload[i]; uint32_t pl = payload[i];
cksum += p; cksum += pl;
} }
// Place the checksum values in the message // Place the checksum values in the message

View File

@ -192,9 +192,7 @@ void MeshService::handleToRadio(meshtastic_MeshPacket &p)
return; return;
} }
#endif #endif
if (p.from != 0) { // We don't let phones assign nodenums to their sent messages p.from = 0; // We don't let phones assign nodenums to their sent messages
p.from = 0;
}
if (p.id == 0) if (p.id == 0)
p.id = generatePacketId(); // If the phone didn't supply one, then pick one p.id = generatePacketId(); // If the phone didn't supply one, then pick one

View File

@ -56,7 +56,7 @@ meshtastic_OEMStore oemStore;
bool meshtastic_DeviceState_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_iter_t *field) bool meshtastic_DeviceState_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_iter_t *field)
{ {
if (ostream) { if (ostream) {
std::vector<meshtastic_NodeInfoLite> *vec = (std::vector<meshtastic_NodeInfoLite> *)field->pData; std::vector<meshtastic_NodeInfoLite> const *vec = (std::vector<meshtastic_NodeInfoLite> *)field->pData;
for (auto item : *vec) { for (auto item : *vec) {
if (!pb_encode_tag_for_field(ostream, field)) if (!pb_encode_tag_for_field(ostream, field))
return false; return false;

View File

@ -95,12 +95,11 @@ template <class T> class ProtobufModule : protected SinglePortModule
*/ */
virtual void alterReceived(meshtastic_MeshPacket &mp) override virtual void alterReceived(meshtastic_MeshPacket &mp) override
{ {
auto &p = mp.decoded;
T scratch; T scratch;
T *decoded = NULL; T *decoded = NULL;
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) { if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
auto &p = mp.decoded;
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) { if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
decoded = &scratch; decoded = &scratch;
} else { } else {

View File

@ -116,9 +116,8 @@ Will be used for broadcast.
*/ */
int32_t NeighborInfoModule::runOnce() int32_t NeighborInfoModule::runOnce()
{ {
bool requestReplies = false;
if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) {
sendNeighborInfo(NODENUM_BROADCAST, requestReplies); sendNeighborInfo(NODENUM_BROADCAST, false);
} }
return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_broadcast_interval_secs); return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_broadcast_interval_secs);
} }

View File

@ -343,7 +343,7 @@ int32_t PositionModule::runOnce()
// The minimum time (in seconds) that would pass before we are able to send a new position packet. // The minimum time (in seconds) that would pass before we are able to send a new position packet.
auto smartPosition = getDistanceTraveledSinceLastSend(node->position); auto smartPosition = getDistanceTraveledSinceLastSend(node->position);
uint32_t msSinceLastSend = now - lastGpsSend; msSinceLastSend = now - lastGpsSend;
if (smartPosition.hasTraveledOverThreshold && if (smartPosition.hasTraveledOverThreshold &&
Throttle::execute( Throttle::execute(

View File

@ -5,15 +5,15 @@
class RCWL9620Sensor : public TelemetrySensor class RCWL9620Sensor : public TelemetrySensor
{ {
private: private:
uint8_t _addr; uint8_t _addr = 0x57;
TwoWire *_wire; TwoWire *_wire = &Wire;
uint8_t _scl; uint8_t _scl = -1;
uint8_t _sda; uint8_t _sda = -1;
uint8_t _speed; uint32_t _speed = 200000UL;
protected: protected:
virtual void setup() override; virtual void setup() override;
void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000L); void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000UL);
float getDistance(); float getDistance();
public: public:

View File

@ -75,7 +75,7 @@ void portduinoSetup()
{ {
printf("Setting up Meshtastic on Portduino...\n"); printf("Setting up Meshtastic on Portduino...\n");
int max_GPIO = 0; int max_GPIO = 0;
configNames GPIO_lines[] = {cs, const configNames GPIO_lines[] = {cs,
irq, irq,
busy, busy,
reset, reset,
@ -103,7 +103,7 @@ void portduinoSetup()
std::cout << "Using " << configPath << " as config file" << std::endl; std::cout << "Using " << configPath << " as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile(configPath); yamlConfig = YAML::LoadFile(configPath);
} catch (YAML::Exception e) { } catch (YAML::Exception &e) {
std::cout << "Could not open " << configPath << " because of error: " << e.what() << std::endl; std::cout << "Could not open " << configPath << " because of error: " << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -111,7 +111,7 @@ void portduinoSetup()
std::cout << "Using local config.yaml as config file" << std::endl; std::cout << "Using local config.yaml as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile("config.yaml"); yamlConfig = YAML::LoadFile("config.yaml");
} catch (YAML::Exception e) { } catch (YAML::Exception &e) {
std::cout << "*** Exception " << e.what() << std::endl; std::cout << "*** Exception " << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -119,7 +119,7 @@ void portduinoSetup()
std::cout << "Using /etc/meshtasticd/config.yaml as config file" << std::endl; std::cout << "Using /etc/meshtasticd/config.yaml as config file" << std::endl;
try { try {
yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml"); yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml");
} catch (YAML::Exception e) { } catch (YAML::Exception &e) {
std::cout << "*** Exception " << e.what() << std::endl; std::cout << "*** Exception " << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -276,7 +276,7 @@ void portduinoSetup()
settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as<int>(200); settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as<int>(200);
} catch (YAML::Exception e) { } catch (YAML::Exception &e) {
std::cout << "*** Exception " << e.what() << std::endl; std::cout << "*** Exception " << e.what() << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -347,7 +347,7 @@ void portduinoSetup()
return; return;
} }
int initGPIOPin(int pinNum, std::string gpioChipName) int initGPIOPin(int pinNum, const std::string& gpioChipName)
{ {
std::string gpio_name = "GPIO" + std::to_string(pinNum); std::string gpio_name = "GPIO" + std::to_string(pinNum);
try { try {

View File

@ -186,9 +186,9 @@ int File::available(void)
_fs->_lockFS(); _fs->_lockFS();
if (!this->_is_dir) { if (!this->_is_dir) {
uint32_t size = lfs_file_size(_fs->_getFS(), _file); uint32_t fsize = lfs_file_size(_fs->_getFS(), _file);
uint32_t pos = lfs_file_tell(_fs->_getFS(), _file); uint32_t pos = lfs_file_tell(_fs->_getFS(), _file);
ret = size - pos; ret = fsize - pos;
} }
_fs->_unlockFS(); _fs->_unlockFS();