Skip to content

Commit

Permalink
Merge pull request #4930 from TD-er/bugfix/p2p_IPv6
Browse files Browse the repository at this point in the history
[IPv6] Fix node with IPv6 not seen by other p2p nodes with only IPv4
  • Loading branch information
TD-er authored Jan 3, 2024
2 parents 45b7130 + 72b197a commit 69184ff
Show file tree
Hide file tree
Showing 40 changed files with 376 additions and 238 deletions.
2 changes: 1 addition & 1 deletion lib/Itho/CC1101Packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <Arduino.h>

#define CC1101_BUFFER_LEN 64
#define CC1101_DATA_LEN CC1101_BUFFER_LEN - 3
#define CC1101_DATA_LEN (CC1101_BUFFER_LEN - 3)


class CC1101Packet {
Expand Down
7 changes: 3 additions & 4 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ build_flags = ${esp82xx_2_7_x.build_flags}
-DLIBRARIES_NO_LOG=1
lib_ignore = ${esp82xx_2_7_x.lib_ignore}
build_unflags = ${esp82xx_2_7_x.build_unflags}
extra_scripts =
extra_scripts = ${esp82xx_common.extra_scripts}


[core_stage]
Expand All @@ -138,8 +138,7 @@ build_flags = ${esp82xx_3_0_x.build_flags}
-DPHASE_LOCKED_WAVEFORM
build_unflags = ${esp82xx_3_0_x.build_unflags}
lib_ignore = ${esp82xx_defaults.lib_ignore}
;extra_scripts = ${esp82xx_3_0_x.extra_scripts}
extra_scripts =
extra_scripts = ${esp82xx_common.extra_scripts}



Expand All @@ -157,7 +156,7 @@ build_flags = ${esp82xx_3_0_x.build_flags}
-DUSE_SECOND_HEAP
build_unflags = ${esp82xx_3_0_x.build_unflags}
lib_ignore = ${core_stage.lib_ignore}
extra_scripts = ${esp82xx_3_0_x.extra_scripts}
extra_scripts = ${esp82xx_common.extra_scripts}



Expand Down
7 changes: 7 additions & 0 deletions platformio_esp32_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ extends = env:custom_ESP32_4M316k
build_flags = ${env:custom_ESP32_4M316k.build_flags}
-DFEATURE_ETHERNET=1

[env:custom_ESP32_4M316k_LittleFS_ETH]
extends = esp32_custom_base_LittleFS
board = esp32_4M
build_flags = ${esp32_custom_base_LittleFS.build_flags}
-DFEATURE_ETHERNET=1


[env:custom_IR_ESP32_4M316k_ETH]
extends = env:custom_IR_ESP32_4M316k
build_flags = ${env:custom_ESP32_4M316k.build_flags}
Expand Down
7 changes: 4 additions & 3 deletions platformio_esp82xx_base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ platform = ${core_2_7_4.platform}
platform_packages = ${core_2_7_4.platform_packages}
lib_ignore = ${core_2_7_4.lib_ignore}
build_unflags = ${core_2_7_4.build_unflags}
extra_scripts =
extra_scripts = ${core_2_7_4.extra_scripts}


[core312_platform]
Expand All @@ -26,6 +26,7 @@ platform = ${core_2_7_4.platform}
platform_packages = ${core_2_7_4.platform_packages}
lib_ignore = ${core_2_7_4.lib_ignore}
build_unflags = ${core_2_7_4.build_unflags}
extra_scripts = ${core_2_7_4.extra_scripts}


[beta_platform_2ndheap]
Expand Down Expand Up @@ -76,8 +77,8 @@ build_flags = ${minimal_size.build_flags}
build_unflags = -DDEBUG_ESP_PORT
-fexceptions
monitor_filters = esp8266_exception_decoder
extra_scripts = pre:tools/pio/pre_default_check.py
${extra_scripts_esp8266.extra_scripts}
extra_scripts = ${extra_scripts_esp8266.extra_scripts}
pre:tools/pio/pre_default_check.py
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<*/Commands/> -<*/ControllerQueue/> -<*/DataStructs/> -<*/DataTypes/> -<*/ESPEasyCore/> -<*/Globals/> -<*/Helpers/> -<*/PluginStructs/> -<*/WebServer/>


Expand Down
19 changes: 4 additions & 15 deletions platformio_esp82xx_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build_flags = ${core_stage.build_flags}
-DPLUGIN_BUILD_CUSTOM
-DFEATURE_DEFINE_SERIAL_CONSOLE_PORT=0
extra_scripts = ${extra_scripts_esp8266.extra_scripts}
${core_stage.extra_scripts}



[esp8266_custom_common_274]
Expand Down Expand Up @@ -47,7 +47,7 @@ lib_ignore = ESP32_ping
I2C AXP192 Power management
extra_scripts = pre:tools/pio/pre_custom_esp82xx.py
${extra_scripts_esp8266.extra_scripts}
${core_stage.extra_scripts}



; Custom: 4M1M version --------------------------
Expand Down Expand Up @@ -307,54 +307,41 @@ extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_domoticz.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
extra_scripts = ${core274_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}


[env:minimal_core_274_ESP8266_1M_OTA_Domoticz_MQTT]
extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_domoticz_MQTT.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
extra_scripts = ${core274_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}


[env:minimal_core_274_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_FHEM_HA.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
extra_scripts = ${core274_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}



[env:minimal_core_312_ESP8266_1M_OTA_Domoticz]
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}


[env:minimal_core_312_ESP8266_1M_OTA_Domoticz_MQTT]
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz_MQTT.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}


[env:minimal_core_312_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_FHEM_HA.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}



Expand Down Expand Up @@ -537,13 +524,15 @@ extends = esp8266_4M1M, regular_platform
build_flags = ${regular_platform.build_flags}
${esp8266_4M1M.build_flags}
-D PLUGIN_ENERGY_COLLECTION
-D LIMIT_BUILD_SIZE
-D WEBSERVER_USE_CDN_JS_CSS
lib_ignore = ${regular_platform.lib_ignore}
ESP8266SdFat
SD(esp8266)
SD
SDFS
LittleFS(esp8266)
extra_scripts = ${regular_platform.extra_scripts}


; display : 4096k version ----------------------------
Expand Down
7 changes: 1 addition & 6 deletions src/_P122_SHT2x.ino
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ boolean Plugin_122(uint8_t function, struct EventStruct *event, String& string)
break;
}

case PLUGIN_ONCE_A_SECOND:
{
// code to be executed once a second. Tasks which do not require fast response can be added here
success = true;
}

case PLUGIN_TEN_PER_SECOND:
{
// code to be executed 10 times per second. Tasks which require fast response can be added here
Expand All @@ -251,6 +245,7 @@ boolean Plugin_122(uint8_t function, struct EventStruct *event, String& string)
P122_data->update(); // SHT2x FSM evaluation
}
success = true;
break;
}
} // switch
return success;
Expand Down
2 changes: 1 addition & 1 deletion src/src/CustomBuild/define_plugin_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ To create/register a plugin, you have to :
#if !defined(USES_P138) && defined(ESP32)
#define USES_P138 // IP5306
#endif
#ifndef USES_P148
#if !defined(USES_P148) && defined(ESP32)
#define USES_P148 // Sonoff POWR3xxD and THR3xxD display
#endif

Expand Down
3 changes: 2 additions & 1 deletion src/src/DataStructs/DeviceStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ DeviceStruct::DeviceStruct() :
TimerOption(false), TimerOptional(false), DecimalsOnly(false),
DuplicateDetection(false), ExitTaskBeforeSave(true), ErrorStateValues(false),
PluginStats(false), PluginLogsPeaks(false), PowerManager(false),
TaskLogsOwnPeaks(false), I2CNoDeviceCheck(false) {}
TaskLogsOwnPeaks(false), I2CNoDeviceCheck(false),
I2CMax100kHz(false) {}

bool DeviceStruct::connectedToGPIOpins() const {
switch(Type) {
Expand Down
10 changes: 9 additions & 1 deletion src/src/DataStructs/NodeStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ IPAddress NodeStruct::IP() const {
}

#if FEATURE_USE_IPV6
IPAddress NodeStruct::IPv6_link_local() const
IPAddress NodeStruct::IPv6_link_local(bool stripZone) const
{
if (hasIPv6_mac_based_link_local) {
// Base IPv6 on MAC address
IPAddress ipv6;
if (IPv6_link_local_from_MAC(sta_mac, ipv6)) {
if (stripZone) {
return IPAddress(IPv6, &ipv6[0], 0);
}
return ipv6;
}
}
Expand All @@ -172,6 +175,11 @@ IPAddress NodeStruct::IPv6_global() const
}
return IN6ADDR_ANY;
}

bool NodeStruct::hasIPv6() const {
return hasIPv6_mac_based_link_local ||
hasIPv6_mac_based_link_global;
}
#endif


Expand Down
4 changes: 3 additions & 1 deletion src/src/DataStructs/NodeStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ struct __attribute__((__packed__)) NodeStruct
IPAddress IP() const;

#if FEATURE_USE_IPV6
IPAddress IPv6_link_local() const;
IPAddress IPv6_link_local(bool stripZone = false) const;
IPAddress IPv6_global() const;

bool hasIPv6() const;
#endif

MAC_address STA_MAC() const;
Expand Down
11 changes: 2 additions & 9 deletions src/src/DataStructs/NodesHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ const NodeStruct* NodesHandler::getPreferredNode_notMatching(uint8_t unit_nr) co
}

const NodeStruct * NodesHandler::getPreferredNode_notMatching(const MAC_address& not_matching) const {
MAC_address this_mac;

WiFi.macAddress(this_mac.mac);
MAC_address this_mac = NetworkMacAddress();
const NodeStruct *thisNode = getNodeByMac(this_mac);
const NodeStruct *reject = getNodeByMac(not_matching);

Expand Down Expand Up @@ -353,14 +351,10 @@ void NodesHandler::updateThisNode() {
NodeStruct thisNode;

// Set local data
#if FEATURE_ETHERNET
{
MAC_address mac = NetworkMacAddress();
mac.get(thisNode.sta_mac);
}
#else
WiFi.macAddress(thisNode.sta_mac);
#endif
WiFi.softAPmacAddress(thisNode.ap_mac);
{
const bool addIP = NetworkConnected();
Expand Down Expand Up @@ -494,8 +488,7 @@ void NodesHandler::updateThisNode() {
const NodeStruct * NodesHandler::getThisNode() {
node_time.now();
updateThisNode();
MAC_address this_mac;
WiFi.macAddress(this_mac.mac);
MAC_address this_mac = NetworkMacAddress();
return getNodeByMac(this_mac.mac);
}

Expand Down
33 changes: 21 additions & 12 deletions src/src/DataStructs/PluginStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ bool PluginStats_array::webformLoad_show_stats(struct EventStruct *event) const
}

# if FEATURE_CHART_JS
void PluginStats_array::plot_ChartJS() const
void PluginStats_array::plot_ChartJS(bool onlyJSON) const
{
const size_t nrSamples = nrSamplesPresent();

Expand Down Expand Up @@ -577,29 +577,35 @@ void PluginStats_array::plot_ChartJS() const
500 + (70 * (scales.nr_Y_scales() - 1)),
500,
scales.toString(),
nrSamples);
nrSamples,
onlyJSON);
}


// Add labels
addHtml(F("labels:["));
addHtml(F("\"labels\":["));

for (size_t i = 0; i < nrSamples; ++i) {
if (i != 0) {
addHtml(',');
}
addHtmlInt(i);
}
addHtml(F("],datasets:["));
addHtml(F("],\n\"datasets\":["));


// Data sets
bool first = true;
for (size_t i = 0; i < VARS_PER_TASK; ++i) {
if (_plugin_stats[i] != nullptr) {
if (!first) {
addHtml(',');
}
first = false;
_plugin_stats[i]->plot_ChartJS_dataset();
}
}
add_ChartJS_chart_footer();
add_ChartJS_chart_footer(onlyJSON);
}

void PluginStats_array::plot_ChartJS_scatter(
Expand All @@ -611,7 +617,8 @@ void PluginStats_array::plot_ChartJS_scatter(
int width,
int height,
bool showAverage,
const String & options) const
const String & options,
bool onlyJSON) const
{
const PluginStats *stats_X = getPluginStats(values_X_axis_index);
const PluginStats *stats_Y = getPluginStats(values_Y_axis_index);
Expand Down Expand Up @@ -643,18 +650,19 @@ void PluginStats_array::plot_ChartJS_scatter(
width,
height,
axisOptions,
nrSamples);
nrSamples,
onlyJSON);

// Add labels, which will be shown in a tooltip when hovering with the mouse over a point.
addHtml(F("labels:["));
addHtml(F("\"labels\":["));

for (size_t i = 0; i < nrSamples; ++i) {
if (i != 0) {
addHtml(',');
}
addHtmlInt(i);
}
addHtml(F("],datasets:["));
addHtml(F("],\n\"datasets\":["));

// Long/Lat Coordinates
add_ChartJS_dataset_header(datasetConfig);
Expand All @@ -666,10 +674,11 @@ void PluginStats_array::plot_ChartJS_scatter(
add_ChartJS_scatter_data_point(valX, valY, 6);
}

add_ChartJS_dataset_footer(F("showLine:true"));
add_ChartJS_dataset_footer(F("\"showLine\":true"));

if (showAverage) {
// Add single point showing the average
addHtml(',');
add_ChartJS_dataset_header(
{
F("Average"),
Expand All @@ -680,9 +689,9 @@ void PluginStats_array::plot_ChartJS_scatter(
const float valY = stats_Y->getSampleAvg();
add_ChartJS_scatter_data_point(valX, valY, 6);
}
add_ChartJS_dataset_footer(F("pointRadius:6,pointHoverRadius:10"));
add_ChartJS_dataset_footer(F("\"pointRadius\":6,\"pointHoverRadius\":10"));
}
add_ChartJS_chart_footer();
add_ChartJS_chart_footer(onlyJSON);
}

# endif // if FEATURE_CHART_JS
Expand Down
Loading

0 comments on commit 69184ff

Please sign in to comment.