Skip to content

Commit

Permalink
[coco] Update Becker interface on ESP
Browse files Browse the repository at this point in the history
- On ESP, restart FujiNet after Becker enable/disable
  Serial port driver on ESP was not happy when loaded/unloaded from
  web server task.
- On ESP, no Becker host:port setting in WebUI
  Default settings is to listen on all IPs (i.e. WiFi IP on FN-ESP)
  • Loading branch information
a8jan committed Nov 19, 2024
1 parent e9b078c commit 2b6505d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
9 changes: 9 additions & 0 deletions data/webui/template/www/index.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,13 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
{% else %}
Enable emulator connection
{% endif %}
{% if not tweaks.fujinet_pc %}
<div class="tooltip">&#9432;
<span class="tooltiptext small-text">
Reboot FujiNet after changing this value.
</span>
</div>
{% endif %}
</label>
</div>
<div class="settings-value">
Expand All @@ -1354,6 +1361,7 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
</div>
</div>
</div>
{% if tweaks.fujinet_pc %}
<div class="set">
<div class="settings-label">
<label for="boip_host">Hostname or IP [:port]</label>
Expand All @@ -1362,6 +1370,7 @@ <h3 style="text-align: center;">Need help? Go to the <a href="https://github.com
<input type="text" name="boip_host" id="boip_host" value="<%FN_BOIP_HOST%>">
</div>
</div>
{% endif %}
<hr>
<div class="settings-text">
<div>
Expand Down
7 changes: 7 additions & 0 deletions lib/config/fnConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,14 @@ class fnConfig
struct boip_info
{
bool boip_enabled = false;
#ifdef ESP_PLATFORM
// CoCo: DriveWire server (listen) -> listen on all IPs by default
// Atari: NetSIO hub (connect to) -> hub host/IP must be specified
std::string host = "";
#else
// On PC, limit connections to/from local machine by default
std::string host = "localhost";
#endif
int port = CONFIG_DEFAULT_BOIP_PORT;
};

Expand Down
36 changes: 19 additions & 17 deletions lib/http/httpServiceConfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,50 +569,52 @@ void fnHttpServiceConfigurator::config_boip(std::string enable_boip, std::string
Debug_printf("Set Bus Over IP: %s,%s\n", enable_boip.c_str(), boip_host_port.c_str());

// Store our change in Config
if (!boip_host_port.empty())
if (boip_host_port.empty())
{
Config.store_boip_host("");
Config.store_boip_port(CONFIG_DEFAULT_BOIP_PORT);
}
else
{
std::size_t found = boip_host_port.find(':');
std::string host = boip_host_port;
int port = CONFIG_DEFAULT_BOIP_PORT;
if (found != std::string::npos)
{
host = boip_host_port.substr(0, found);
if (host.empty())
host = "localhost";
port = std::atoi(boip_host_port.substr(found+1).c_str());
if (port < 1 || port > 65535)
port = CONFIG_DEFAULT_BOIP_PORT;
}
Config.store_boip_port(port);
Config.store_boip_host(host.c_str());
Config.store_boip_port(port);
}

// Update settings
// Update settings (on ESP reboot is needed)
#ifndef ESP_PLATFORM
#if defined(BUILD_ATARI)
# ifndef ESP_PLATFORM
// fnSioCom is not available on Atari FN-ESP
fnSioCom.set_netsio_host(Config.get_boip_host().c_str(), Config.get_boip_port());
# endif
fnSioCom.set_netsio_host(Config.get_boip_host().c_str(), Config.get_boip_port());
#elif defined(BUILD_COCO)
fnDwCom.set_becker_host(Config.get_boip_host().c_str(), Config.get_boip_port());
fnDwCom.set_becker_host(Config.get_boip_host().c_str(), Config.get_boip_port());
#endif
}
#endif

if (!enable_boip.empty())
{
Config.store_boip_enabled(util_string_value_is_true(enable_boip));
}
// Save changes
Config.save();

// Apply settings
// Apply settings (on ESP reboot is needed)
#ifndef ESP_PLATFORM
#if defined(BUILD_ATARI)
# ifndef ESP_PLATFORM
// fnSioCom is not available on Atari FN-ESP
fnSioCom.reset_sio_port(Config.get_boip_enabled() ? SioCom::sio_mode::NETSIO : SioCom::sio_mode::SERIAL);
# endif
#elif defined(BUILD_COCO)
fnDwCom.reset_drivewire_port(Config.get_boip_enabled() ? DwCom::dw_mode::BECKER : DwCom::dw_mode::SERIAL);
#endif
#endif

// Save changes
Config.save();
}

void fnHttpServiceConfigurator::config_pclink_enabled(std::string enabled)
Expand Down

0 comments on commit 2b6505d

Please sign in to comment.