mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
disable bluetooth, show IPv6 in web, mqtt and console
This commit is contained in:
@@ -40,7 +40,22 @@ class NetworkStatusForm extends Component<NetworkStatusFormProps> {
|
||||
if (!status.dns_ip_1) {
|
||||
return 'none';
|
||||
}
|
||||
return status.dns_ip_1 + (status.dns_ip_2 ? ',' + status.dns_ip_2 : '');
|
||||
if (!status.dns_ip_2 || status.dns_ip_2 === '0.0.0.0') {
|
||||
return status.dns_ip_1;
|
||||
}
|
||||
return status.dns_ip_1 + ', ' + status.dns_ip_2;
|
||||
}
|
||||
IPs(status: NetworkStatus) {
|
||||
if (
|
||||
!status.local_ipv6 ||
|
||||
status.local_ipv6 === '0000:0000:0000:0000:0000:0000:0000:0000'
|
||||
) {
|
||||
return status.local_ip;
|
||||
}
|
||||
if (!status.local_ip || status.local_ip === '0.0.0.0') {
|
||||
return status.local_ipv6;
|
||||
}
|
||||
return status.local_ip + ', ' + status.local_ipv6;
|
||||
}
|
||||
|
||||
createListItems() {
|
||||
@@ -77,7 +92,7 @@ class NetworkStatusForm extends Component<NetworkStatusFormProps> {
|
||||
<ListItemAvatar>
|
||||
<Avatar>IP</Avatar>
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary="IP Address" secondary={data.local_ip} />
|
||||
<ListItemText primary="IP Address" secondary={this.IPs(data)} />
|
||||
</ListItem>
|
||||
<Divider variant="inset" component="li" />
|
||||
<ListItem>
|
||||
|
||||
@@ -21,6 +21,7 @@ export enum WiFiEncryptionType {
|
||||
export interface NetworkStatus {
|
||||
status: NetworkConnectionStatus;
|
||||
local_ip: string;
|
||||
local_ipv6: string;
|
||||
mac_address: string;
|
||||
rssi: number;
|
||||
ssid: string;
|
||||
|
||||
@@ -25,6 +25,7 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
||||
// for Wifi
|
||||
if (wifi_status == WL_CONNECTED) {
|
||||
root["local_ip"] = WiFi.localIP().toString();
|
||||
root["local_ipv6"] = WiFi.localIPv6().toString();
|
||||
root["mac_address"] = WiFi.macAddress();
|
||||
root["rssi"] = WiFi.RSSI();
|
||||
root["ssid"] = WiFi.SSID();
|
||||
@@ -47,6 +48,7 @@ void NetworkStatus::networkStatus(AsyncWebServerRequest * request) {
|
||||
} else if (ethernet_connected) {
|
||||
// Ethernet
|
||||
root["local_ip"] = ETH.localIP().toString();
|
||||
root["local_ipv6"] = ETH.localIPv6().toString();
|
||||
root["mac_address"] = ETH.macAddress();
|
||||
root["subnet_mask"] = ETH.subnetMask().toString();
|
||||
root["gateway_ip"] = ETH.gatewayIP().toString();
|
||||
|
||||
@@ -640,8 +640,14 @@ void Mqtt::on_connect() {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
if (EMSESP::system_.ethernet_connected()) {
|
||||
doc["ip"] = ETH.localIP().toString();
|
||||
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
doc["ipv6"] = ETH.localIPv6().toString();
|
||||
}
|
||||
} else {
|
||||
doc["ip"] = WiFi.localIP().toString();
|
||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
doc["ipv6"] = WiFi.localIPv6().toString();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
publish(F_(info), doc.as<JsonObject>()); // topic called "info"
|
||||
|
||||
@@ -279,6 +279,8 @@ void System::start(uint32_t heap_start) {
|
||||
get_settings();
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// disable bluetooth module
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
if (low_clock_) {
|
||||
setCpuFrequencyMhz(160);
|
||||
}
|
||||
@@ -305,12 +307,8 @@ void System::adc_init(bool refresh) {
|
||||
get_settings();
|
||||
}
|
||||
#ifndef EMSESP_STANDALONE
|
||||
// setCpuFrequencyMhz(160); // default is 240
|
||||
|
||||
// disable bluetooth & ADC
|
||||
// disable ADC
|
||||
/*
|
||||
btStop();
|
||||
esp_bt_controller_disable();
|
||||
if (!analog_enabled_) {
|
||||
adc_power_release(); // turn off ADC to save power if not needed
|
||||
}
|
||||
@@ -719,6 +717,9 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(F("IPv4 address: %s/%s"), uuid::printable_to_string(WiFi.localIP()).c_str(), uuid::printable_to_string(WiFi.subnetMask()).c_str());
|
||||
shell.printfln(F("IPv4 gateway: %s"), uuid::printable_to_string(WiFi.gatewayIP()).c_str());
|
||||
shell.printfln(F("IPv4 nameserver: %s"), uuid::printable_to_string(WiFi.dnsIP()).c_str());
|
||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
shell.printfln(F("IPv6 address: %s"), uuid::printable_to_string(WiFi.localIPv6()).c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case WL_CONNECT_FAILED:
|
||||
@@ -749,6 +750,9 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(F("IPv4 address: %s/%s"), uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str());
|
||||
shell.printfln(F("IPv4 gateway: %s"), uuid::printable_to_string(ETH.gatewayIP()).c_str());
|
||||
shell.printfln(F("IPv4 nameserver: %s"), uuid::printable_to_string(ETH.dnsIP()).c_str());
|
||||
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
shell.printfln(F("IPv6 address: %s"), uuid::printable_to_string(ETH.localIPv6()).c_str());
|
||||
}
|
||||
} else {
|
||||
shell.printfln(F("Ethernet: disconnected"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user