Skip to content

Commit

Permalink
Merge branch 'master' into macaddr-config
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett authored Dec 5, 2024
2 parents bd38ad3 + de77418 commit 5938278
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/mesh/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,11 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
{
meshtastic_Channel &ch = getByIndex(chIndex);
const meshtastic_ChannelSettings &channelSettings = ch.settings;
assert(ch.has_settings);

CryptoKey k;
memset(k.bytes, 0, sizeof(k.bytes)); // In case the user provided a short key, we want to pad the rest with zeros

if (ch.role == meshtastic_Channel_Role_DISABLED) {
if (!ch.has_settings || ch.role == meshtastic_Channel_Role_DISABLED) {
k.length = -1; // invalid
} else {
memcpy(k.bytes, channelSettings.psk.bytes, channelSettings.psk.size);
Expand Down
3 changes: 2 additions & 1 deletion src/mesh/FloodingRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
if (isRepeated) {
LOG_DEBUG("Repeated reliable tx");
if (!perhapsRebroadcast(p) && isToUs(p) && p->want_ack) {
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0);
// FIXME - channel index should be used, but the packet is still encrypted here
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, 0, 0);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
auto encodeResult = perhapsEncode(p);
if (encodeResult != meshtastic_Routing_Error_NONE) {
packetPool.release(p_decoded);
p->channel = 0; // Reset the channel to 0, so we don't use the failing hash again
abortSendAndNak(encodeResult, p);
return encodeResult; // FIXME - this isn't a valid ErrorCode
}
Expand Down
2 changes: 2 additions & 0 deletions src/mesh/api/ServerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "StreamAPI.h"

#define SERVER_API_DEFAULT_PORT 4403

/**
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/api/WiFiServerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ class WiFiServerPort : public APIServerPort<WiFiServerAPI, WiFiServer>
explicit WiFiServerPort(int port);
};

void initApiServer(int port = 4403);
void initApiServer(int port = SERVER_API_DEFAULT_PORT);
void deInitApiServer();
2 changes: 1 addition & 1 deletion src/mesh/api/ethServerAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class ethServerPort : public APIServerPort<ethServerAPI, EthernetServer>
explicit ethServerPort(int port);
};

void initApiServer(int port = 4403);
void initApiServer(int port = SERVER_API_DEFAULT_PORT);
6 changes: 3 additions & 3 deletions src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ static void onNetworkConnected()
LOG_ERROR("Error setting up MDNS responder!");
} else {
LOG_INFO("mDNS Host: Meshtastic.local");
MDNS.addService("meshtastic", "tcp", SERVER_API_DEFAULT_PORT);
#ifdef ARCH_ESP32
MDNS.addService("http", "tcp", 80);
MDNS.addService("https", "tcp", 443);
// ESP32 prints obtained IP address in WiFiEvent
#elif defined(ARCH_RP2040)
// ARCH_RP2040 does not support HTTPS, create a "meshtastic" service
MDNS.addService("meshtastic", "tcp", 4403);
// ESP32 handles this in WiFiEvent
// ARCH_RP2040 does not support HTTPS
LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str());
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <assert.h>

#include "PortduinoGlue.h"
#include "api/ServerAPI.h"
#include "linux/gpio/LinuxGPIOPin.h"
#include "yaml-cpp/yaml.h"
#include <filesystem>
Expand All @@ -34,7 +35,7 @@ void cpuDeepSleep(uint32_t msecs)

void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel");

int TCPPort = 4403;
int TCPPort = SERVER_API_DEFAULT_PORT;

static error_t parse_opt(int key, char *arg, struct argp_state *state)
{
Expand Down

0 comments on commit 5938278

Please sign in to comment.