From 0743b7d2b69a1f73a653ace672ae8d271f950e05 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sat, 21 Jan 2023 13:41:36 +0100 Subject: [PATCH] Berry add up flag to ``tasmota.wifi()`` and ``tasmota.eth()``, always return MAC (#17759) --- CHANGELOG.md | 1 + .../tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d30ad9a6c..72221d18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ## [12.3.1.4] ### Added - Berry ``crypto.EC_P256`` ECDSA signature (required by Matter protocol) +- Berry add up flag to ``tasmota.wifi()`` and ``tasmota.eth()``, always return MAC ### Breaking Changed diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino index 015d505e7..b31ed5b99 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_tasmota.ino @@ -211,6 +211,8 @@ extern "C" { int32_t top = be_top(vm); // Get the number of arguments if (top == 1) { // no argument (instance only) be_newobject(vm, "map"); + be_map_insert_str(vm, "mac", WiFi.macAddress().c_str()); + be_map_insert_bool(vm, "up", WifiHasIP()); if (Settings->flag4.network_wifi) { int32_t rssi = WiFi.RSSI(); bool show_rssi = false; @@ -227,7 +229,6 @@ extern "C" { } #endif // USE_IPV6 if (static_cast(WiFi.localIP()) != 0) { - be_map_insert_str(vm, "mac", WiFi.macAddress().c_str()); be_map_insert_str(vm, "ip", IPAddress((uint32_t)WiFi.localIP()).toString().c_str()); // quick fix for IPAddress bug show_rssi = true; } @@ -250,8 +251,12 @@ extern "C" { if (top == 1) { // no argument (instance only) be_newobject(vm, "map"); #ifdef USE_ETHERNET + be_map_insert_bool(vm, "up", EthernetHasIP()); + String eth_mac = EthernetMacAddress().c_str(); + if (eth_mac != "00:00:00:00:00:00") { + be_map_insert_str(vm, "mac", eth_mac.c_str()); + } if (static_cast(EthernetLocalIP()) != 0) { - be_map_insert_str(vm, "mac", EthernetMacAddress().c_str()); be_map_insert_str(vm, "ip", IPAddress((uint32_t)EthernetLocalIP()).toString().c_str()); // quick fix for IPAddress bug } #ifdef USE_IPV6 @@ -264,6 +269,8 @@ extern "C" { be_map_insert_str(vm, "ip6local", ipv6_addr.c_str()); } #endif // USE_IPV6 +#else // USE_ETHERNET + be_map_insert_bool(vm, "up", bfalse); #endif // USE_ETHERNET be_pop(vm, 1); be_return(vm);