Skip to content

Commit

Permalink
Merge branch 'master' into stm32wl
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Dec 14, 2023
2 parents fe90751 + ded1cbf commit 75e19a1
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/AccelerometerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace concurrency
class AccelerometerThread : public concurrency::OSThread
{
public:
AccelerometerThread(ScanI2C::DeviceType type = ScanI2C::DeviceType::NONE) : OSThread("AccelerometerThread")
explicit AccelerometerThread(ScanI2C::DeviceType type) : OSThread("AccelerometerThread")
{
if (accelerometer_found.port == ScanI2C::I2CPort::NO_I2C) {
LOG_DEBUG("AccelerometerThread disabling due to no sensors found\n");
Expand Down
2 changes: 1 addition & 1 deletion src/AmbientLightingThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace concurrency
class AmbientLightingThread : public concurrency::OSThread
{
public:
AmbientLightingThread(ScanI2C::DeviceType type) : OSThread("AmbientLightingThread")
explicit AmbientLightingThread(ScanI2C::DeviceType type) : OSThread("AmbientLightingThread")
{
// Uncomment to test module
// moduleConfig.ambient_lighting.led_state = true;
Expand Down
5 changes: 1 addition & 4 deletions src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,8 @@ bool Power::analogInit()
*/
bool Power::setup()
{
bool found = axpChipInit();
bool found = axpChipInit() || analogInit();

if (!found) {
found = analogInit();
}
enabled = found;
low_voltage_counter = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/PowerFSMThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PowerFSMThread : public OSThread

/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
/// cpu for serial rx - FIXME)
const auto state = powerFSM.getState();
const State *state = powerFSM.getState();
canSleep = (state != &statePOWER) && (state != &stateSERIAL);

if (powerStatus->getHasUSB()) {
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void Channels::onConfigChanged()
{
// Make sure the phone hasn't mucked anything up
for (int i = 0; i < channelFile.channels_count; i++) {
meshtastic_Channel &ch = fixupChannel(i);
const meshtastic_Channel &ch = fixupChannel(i);

if (ch.role == meshtastic_Channel_Role_PRIMARY)
primaryIndex = i;
Expand Down
3 changes: 3 additions & 0 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role)
} else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) {
moduleConfig.telemetry.environment_measurement_enabled = true;
moduleConfig.telemetry.environment_update_interval = 300;
} else if (role == meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND) {
config.position.position_broadcast_smart_enabled = false;
config.position.position_broadcast_secs = 300; // Every 5 minutes
} else if (role == meshtastic_Config_DeviceConfig_Role_TAK) {
config.device.node_info_broadcast_secs = ONE_DAY;
config.position.position_broadcast_smart_enabled = false;
Expand Down
7 changes: 4 additions & 3 deletions src/meshUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
*/
char *strnstr(const char *s, const char *find, size_t slen)
{
char c, sc;
size_t len;

char c;
if ((c = *find++) != '\0') {
char sc;
size_t len;

len = strlen(find);
do {
do {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/AdminModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,12 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r
#if HAS_BLUETOOTH
conn.has_bluetooth = true;
conn.bluetooth.pin = config.bluetooth.fixed_pin;
#endif
#ifdef ARCH_ESP32
conn.bluetooth.is_connected = nimbleBluetooth->isConnected();
conn.bluetooth.rssi = nimbleBluetooth->getRssi();
#elif defined(ARCH_NRF52)
conn.bluetooth.is_connected = nrf52Bluetooth->isConnected();
#endif
#endif
conn.has_serial = true; // No serial-less devices
conn.serial.is_connected = powerFSM.getState() == &stateSERIAL;
Expand Down Expand Up @@ -699,4 +699,4 @@ AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_AP
{
// restrict to the admin channel for rx
boundChannel = Channels::adminChannel;
}
}
4 changes: 2 additions & 2 deletions src/modules/NeighborInfoModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ uint32_t NeighborInfoModule::collectNeighborInfo(meshtastic_NeighborInfo *neighb
int num_neighbors = cleanUpNeighbors();

for (int i = 0; i < num_neighbors; i++) {
meshtastic_Neighbor *dbEntry = getNeighborByIndex(i);
const meshtastic_Neighbor *dbEntry = getNeighborByIndex(i);
if ((neighborInfo->neighbors_count < MAX_NUM_NEIGHBORS) && (dbEntry->node_id != my_node_id)) {
neighborInfo->neighbors[neighborInfo->neighbors_count].node_id = dbEntry->node_id;
neighborInfo->neighbors[neighborInfo->neighbors_count].snr = dbEntry->snr;
Expand Down Expand Up @@ -146,7 +146,7 @@ size_t NeighborInfoModule::cleanUpNeighbors()
// Find neighbors to remove
std::vector<int> indices_to_remove;
for (int i = 0; i < num_neighbors; i++) {
meshtastic_Neighbor *dbEntry = getNeighborByIndex(i);
const meshtastic_Neighbor *dbEntry = getNeighborByIndex(i);
// We will remove a neighbor if we haven't heard from them in twice the broadcast interval
if ((now - dbEntry->last_rx_time > dbEntry->node_broadcast_interval_secs * 2) && (dbEntry->node_id != my_node_id)) {
indices_to_remove.push_back(i);
Expand Down
18 changes: 18 additions & 0 deletions src/modules/PositionModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ int32_t PositionModule::runOnce()

LOG_INFO("Sending pos@%x:6 to mesh (wantReplies=%d)\n", localPosition.timestamp, requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
if (config.device.role == meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND) {
sendLostAndFoundText();
}
}
} else if (config.position.position_broadcast_smart_enabled) {
const meshtastic_NodeInfoLite *node2 = service.refreshLocalMeshNode(); // should guarantee there is now a position
Expand Down Expand Up @@ -261,6 +264,21 @@ int32_t PositionModule::runOnce()
return RUNONCE_INTERVAL; // to save power only wake for our callback occasionally
}

void PositionModule::sendLostAndFoundText()
{
meshtastic_MeshPacket *p = allocDataPacket();
p->to = NODENUM_BROADCAST;
char *message = new char[60];
sprintf(message, "🚨I'm lost! Lat / Lon: %f, %f\a", (lastGpsLatitude * 1e-7), (lastGpsLongitude * 1e-7));
p->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP;
p->want_ack = false;
p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);

service.sendToMesh(p, RX_SRC_LOCAL, true);
delete[] message;
}

struct SmartPosition PositionModule::getDistanceTraveledSinceLastSend(meshtastic_PositionLite currentPosition)
{
// The minimum distance to travel before we are able to send a new position packet.
Expand Down
1 change: 1 addition & 0 deletions src/modules/PositionModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class PositionModule : public ProtobufModule<meshtastic_Position>, private concu

/** Only used in power saving trackers for now */
void clearPosition();
void sendLostAndFoundText();
};

struct SmartPosition {
Expand Down
2 changes: 1 addition & 1 deletion src/mqtt/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp)
// the created jsonObj is immutable after creation, so
// we need to do the heavy lifting before assembling it.
std::string msgType;
JSONObject msgPayload;
JSONObject jsonObj;

if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
JSONObject msgPayload;
switch (mp->decoded.portnum) {
case meshtastic_PortNum_TEXT_MESSAGE_APP: {
msgType = "text";
Expand Down
5 changes: 4 additions & 1 deletion suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ virtualCallInConstructor
passedByValue:*/RedirectablePrint.h

internalAstError:*/CrossPlatformCryptoEngine.cpp
uninitMemberVar:*/AudioThread.h
uninitMemberVar:*/AudioThread.h
// False positive
constVariableReference:*/Channels.cpp
constParameterPointer:*/unishox2.c

0 comments on commit 75e19a1

Please sign in to comment.