Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with UDP Multicast – link to #74 #3702

Closed
JirinSV opened this issue Oct 10, 2017 · 4 comments
Closed

Issue with UDP Multicast – link to #74 #3702

JirinSV opened this issue Oct 10, 2017 · 4 comments
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@JirinSV
Copy link

JirinSV commented Oct 10, 2017

Hi,
I would like to reopen issue #74 . I'm facing the same issue described in this original issue. Thing is that it doesn't happen on all ESP8266 devices. I own Wemos D1 Mini Pro where the attached code runs perfectly fine (packets are sent to unicast and multicast). But if the same is loaded to the NodeMCU v3 or Wemos D1 Mini no packet is sent to multicast addresses. Both devices send successfully unicast packets to 192.168.1.x and both of them are able to receive multicast packets. Only sending doesn't work on some devices. I used the same network and same access point to run the tests. I tried to use also beginPacketMulticast instead of beginPacket, but it has no effect whatsoever. I have also to point out that beginPacket always end up with successful result (1) also in the case when no packet is sent.

It would be great if you could load attached file to some other devices and check with packet sniffer if packets are sent or not.

If needed I can do some deeper debug if required – just let me know how to do that.

Thanks for checking this,
Jiri

Project

UDPMulticast.zip

Basic Infos

Hardware

Hardware: Wemos D1 Mini / NodeMCU V3
Core Version: 2.3.0

Description

Unicast UDP packets cannot are not sent.

Settings in IDE

Module: Wemos D1 mini / NodeMCU V3

Source code

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiUDP.h>

char ssid[] = "XXXX";
char password[] = "12345678";

void setup() {
  //Init Serial
  Serial.begin(115200);
  Serial.println("");

  // MAC address info
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("WiFi adapter MAC address: ");
  Serial.print(mac[5], HEX); Serial.print(":"); Serial.print(mac[4], HEX); Serial.print(":");
  Serial.print(mac[3], HEX); Serial.print(":"); Serial.print(mac[2], HEX); Serial.print(":");
  Serial.print(mac[1], HEX); Serial.print(":"); Serial.print(mac[0], HEX); Serial.println(); 
  
  // Connect to Wifi
  Serial.print("Connecting to "); Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Print wifi info
  Serial.print("SSID: "); Serial.println(WiFi.SSID());
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: "); Serial.println(ip);
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI): "); Serial.print(rssi); Serial.println(" dBm");
}

void loop() {
  WiFiUDP udp;
  udp.beginMulticast(WiFi.localIP(), {224, 0, 0, 1}, 10000);
  
  for (int i = 1; i < 255; i++) {  
    Serial.print("Sending packet: 'HELLO' to "); Serial.print(IPAddress({192, 168, 1, i})); Serial.print(':'); Serial.println(10000);
    int result = udp.beginPacket({192, 168, 1, i}, 10000);
    if (result == 1) {
      udp.write("HELLO");
      udp.endPacket();
      Serial.println("Sending packet: 'HELLO' done");
    }
    else
      Serial.println("Cannot send packet");

    delay(100);
  }
  for (int i = 1; i < 255; i++) {
    Serial.print("Sending packet: 'HELLO' to "); Serial.print(IPAddress({224, 0, 0, i})); Serial.print(':'); Serial.println(10000);
    int result = udp.beginPacketMulticast({224, 0, 0, i}, 10000, WiFi.localIP());
    if (result == 1) {
      udp.write("HELLO");
      udp.endPacket();
      Serial.println("Sending packet: 'HELLO' done");
    }
    else
      Serial.println("Cannot send packet");

    delay(100);
  }
}
@devyte
Copy link
Collaborator

devyte commented Oct 10, 2017

@JirinSV please try:

@JirinSV
Copy link
Author

JirinSV commented Oct 10, 2017

@devyte Thanks for suggestions. When using version 2.1.0 it works fine both using NodeMCU and Wemos D1 Mini Pro.

@zllimit
Copy link

zllimit commented Oct 11, 2017

@JirinSV just as you said, the problem happned in the process of multicasting. The xiaomi gate is not recoginzed by wemos, so it's failed to send command to the gate(I modified the loxone IP to the real IP am using, so reading is ok), I am using Wemos D1.

@devyte
Copy link
Collaborator

devyte commented Oct 27, 2017

@igrr this is reportedly fixed by SDK 2.1.0. Should the issue be labeled. or just closed?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 27, 2017
@igrr igrr closed this as completed Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

4 participants