Compare commits

...

3 Commits

Author SHA1 Message Date
Jason P
359a9e9c75 Don't Mute DMs just because we mute a channel 2026-01-18 08:53:35 -06:00
Catalin Patulea
33ae3777a3 toradio, fromradio OPTIONS handler: fix sending proper HTTP response. (#9322)
Before this (missing response):
$ curl -v -X OPTIONS http://meshtastic.local/api/v1/fromradio
* Host meshtastic.local:80 was resolved.
* IPv6: (none)
* IPv4: 192.168.0.19
*   Trying 192.168.0.19:80...
* Connected to meshtastic.local (192.168.0.19) port 80
* using HTTP/1.x
> OPTIONS /api/v1/fromradio HTTP/1.1
> Host: meshtastic.local
> User-Agent: curl/8.14.1
> Accept: */*
>
* Request completely sent off
* Empty reply from server
* shutting down connection #0
curl: (52) Empty reply from server

After this (proper HTTP 204 response):
$ curl -v -X OPTIONS http://meshtastic.local/api/v1/fromradio
* Host meshtastic.local:80 was resolved.
* IPv6: (none)
* IPv4: 192.168.0.19
*   Trying 192.168.0.19:80...
* Connected to meshtastic.local (192.168.0.19) port 80
* using HTTP/1.x
> OPTIONS /api/v1/fromradio HTTP/1.1
> Host: meshtastic.local
> User-Agent: curl/8.14.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 204 OK
< Content-Type: application/x-protobuf
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET
< X-Protobuf-Schema: https://raw.githubusercontent.com/meshtastic/protobufs/master/meshtastic/mesh.proto
<
* Connection #0 to host meshtastic.local left intact

This is related to https://github.com/meshtastic/firmware/issues/5385.

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-18 07:41:24 -06:00
Ted W.
021106dfe5 Add support for setting API port from the config file (#8435)
* Add support for setting API port from the config file

* Update PortduinoGlue.cpp

Fix typo in var identifier

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-17 15:23:16 -06:00
4 changed files with 30 additions and 9 deletions

View File

@@ -173,7 +173,7 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
if (req->getMethod() == "OPTIONS") { if (req->getMethod() == "OPTIONS") {
res->setStatusCode(204); // Success with no content res->setStatusCode(204); // Success with no content
// res->print(""); @todo remove res->print("");
return; return;
} }
@@ -223,7 +223,7 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res)
if (req->getMethod() == "OPTIONS") { if (req->getMethod() == "OPTIONS") {
res->setStatusCode(204); // Success with no content res->setStatusCode(204); // Success with no content
// res->print(""); @todo remove res->print("");
return; return;
} }

View File

@@ -465,6 +465,17 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
mutedNode = (sender->bitfield & NODEINFO_BITFIELD_IS_MUTED_MASK); mutedNode = (sender->bitfield & NODEINFO_BITFIELD_IS_MUTED_MASK);
} }
meshtastic_Channel ch = channels.getByIndex(mp.channel ? mp.channel : channels.getPrimaryIndex()); meshtastic_Channel ch = channels.getByIndex(mp.channel ? mp.channel : channels.getPrimaryIndex());
bool is_muted;
if (!isBroadcast(mp.to) && isToUs(&mp)) {
// if we mute channel 0 (e.g. longfast), do not inherently mute direct message.
is_muted = false;
} else {
if (ch.settings.has_module_settings) {
is_muted = ch.settings.module_settings.is_muted;
} else {
is_muted = false;
}
}
if (moduleConfig.external_notification.alert_bell) { if (moduleConfig.external_notification.alert_bell) {
if (containsBell) { if (containsBell) {
@@ -516,8 +527,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
} }
} }
if (moduleConfig.external_notification.alert_message && !mutedNode && if (moduleConfig.external_notification.alert_message && !mutedNode && !is_muted) {
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
LOG_INFO("externalNotificationModule - Notification Module"); LOG_INFO("externalNotificationModule - Notification Module");
isNagging = true; isNagging = true;
setExternalState(0, true); setExternalState(0, true);
@@ -528,8 +538,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
} }
} }
if (moduleConfig.external_notification.alert_message_vibra && !mutedNode && if (moduleConfig.external_notification.alert_message_vibra && !mutedNode && !is_muted) {
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
LOG_INFO("externalNotificationModule - Notification Module (Vibra)"); LOG_INFO("externalNotificationModule - Notification Module (Vibra)");
isNagging = true; isNagging = true;
setExternalState(1, true); setExternalState(1, true);
@@ -540,8 +549,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
} }
} }
if (moduleConfig.external_notification.alert_message_buzzer && !mutedNode && if (moduleConfig.external_notification.alert_message_buzzer && !mutedNode && !is_muted) {
(!ch.settings.has_module_settings || !ch.settings.module_settings.is_muted)) {
LOG_INFO("externalNotificationModule - Notification Module (Buzzer)"); LOG_INFO("externalNotificationModule - Notification Module (Buzzer)");
if (config.device.buzzer_mode != meshtastic_Config_DeviceConfig_BuzzerMode_DIRECT_MSG_ONLY || if (config.device.buzzer_mode != meshtastic_Config_DeviceConfig_BuzzerMode_DIRECT_MSG_ONLY ||
(!isBroadcast(mp.to) && isToUs(&mp))) { (!isBroadcast(mp.to) && isToUs(&mp))) {

View File

@@ -55,6 +55,7 @@ void cpuDeepSleep(uint32_t msecs)
void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel"); void updateBatteryLevel(uint8_t level) NOT_IMPLEMENTED("updateBatteryLevel");
int TCPPort = SERVER_API_DEFAULT_PORT; int TCPPort = SERVER_API_DEFAULT_PORT;
bool checkConfigPort = true;
static error_t parse_opt(int key, char *arg, struct argp_state *state) static error_t parse_opt(int key, char *arg, struct argp_state *state)
{ {
@@ -63,6 +64,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
if (sscanf(arg, "%d", &TCPPort) < 1) if (sscanf(arg, "%d", &TCPPort) < 1)
return ARGP_ERR_UNKNOWN; return ARGP_ERR_UNKNOWN;
else else
checkConfigPort = false;
printf("Using config file %d\n", TCPPort); printf("Using config file %d\n", TCPPort);
break; break;
case 'c': case 'c':
@@ -870,6 +872,14 @@ bool loadConfig(const char *configPath)
std::cout << "Cannot set both MACAddress and MACAddressSource!" << std::endl; std::cout << "Cannot set both MACAddress and MACAddressSource!" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (checkConfigPort) {
portduino_config.api_port = (yamlConfig["General"]["APIPort"]).as<int>(-1);
if (portduino_config.api_port != -1 &&
portduino_config.api_port > 1023 &&
portduino_config.api_port < 65536) {
TCPPort = (portduino_config.api_port);
}
}
portduino_config.mac_address = (yamlConfig["General"]["MACAddress"]).as<std::string>(""); portduino_config.mac_address = (yamlConfig["General"]["MACAddress"]).as<std::string>("");
if (portduino_config.mac_address != "") { if (portduino_config.mac_address != "") {
portduino_config.mac_address_explicit = true; portduino_config.mac_address_explicit = true;

View File

@@ -175,6 +175,7 @@ extern struct portduino_config_struct {
std::string mac_address = ""; std::string mac_address = "";
bool mac_address_explicit = false; bool mac_address_explicit = false;
std::string mac_address_source = ""; std::string mac_address_source = "";
int api_port = -1;
std::string config_directory = ""; std::string config_directory = "";
std::string available_directory = "/etc/meshtasticd/available.d/"; std::string available_directory = "/etc/meshtasticd/available.d/";
int maxtophone = 100; int maxtophone = 100;
@@ -508,6 +509,8 @@ extern struct portduino_config_struct {
out << YAML::Key << "General" << YAML::Value << YAML::BeginMap; out << YAML::Key << "General" << YAML::Value << YAML::BeginMap;
if (config_directory != "") if (config_directory != "")
out << YAML::Key << "ConfigDirectory" << YAML::Value << config_directory; out << YAML::Key << "ConfigDirectory" << YAML::Value << config_directory;
if (api_port != -1)
out << YAML::Key << "TCPPort" << YAML::Value << api_port;
if (mac_address_explicit) if (mac_address_explicit)
out << YAML::Key << "MACAddress" << YAML::Value << mac_address; out << YAML::Key << "MACAddress" << YAML::Value << mac_address;
if (mac_address_source != "") if (mac_address_source != "")
@@ -519,4 +522,4 @@ extern struct portduino_config_struct {
out << YAML::EndMap; // General out << YAML::EndMap; // General
return out.c_str(); return out.c_str();
} }
} portduino_config; } portduino_config;