char *
and os_sprintf
and friends.
beginPacketMulticast(IPAddress multicastAddress,
uint16_t port,
IPAddress interfaceAddress,
int ttl = 1);
@ficeto i delay 10ms after sending the packet and 1sec at the end of every loop()
@igrr I update at least once a day, i'm downloading the *-master.zip from github and copy the libraries directory. I wanted to git clone and recompile but due to slow connection that is not possible.
begin
with beginMulticast
beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port);
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <Ticker.h>
Ticker nameLookup;
char* packet = NULL;
unsigned short int packet_size;
WiFiUDP udp;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
generateDnsQuery();
Serial.println("");
Serial.println(WiFi.localIP());
udp.beginMulticast(WiFi.localIP(), IPAddress(224, 0, 0, 251), 5353);
}
void loop() {
// Send mDNS request
udp.beginPacketMulticast(IPAddress(224, 0, 0, 251), 5353, WiFi.localIP(),255);
udp.write(packet, packet_size);
udp.endPacket();
delay(1);
Serial.println("Sent: ");
int cb = udp.parsePacket();
if(cb>0){
Serial.print("got udp packet from ");
Serial.println(udp.remoteIP());
}
delay(1000);
}
void generateDnsQuery(){
char header[13] = { 0x00, 0x00, // ID
0x00, 0x00, // FLAGS
0x00, 0x01, // QDCOUNT
0x00, 0x00, // ANCOUNT
0x00, 0x00, // NSCOUNT
0x00, 0x00, // ARCOUNT
0x00 }; // hostname length
char trailer[11] = { 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, //local + null terminator
0x00, 0x01, // QDTYPE
0x00, 0x01}; // QCLASS
unsigned short int hostname_len = strlen(hostname);
packet_size = 24 + hostname_len;
packet = new char[packet_size];
// Forge the request packet
header[12] = hostname_len; // Set hostname length byte
memcpy(packet, header, 13);
memcpy(packet+13, hostname, hostname_len);
memcpy(packet+13+hostname_len, trailer, 11);
}
192.168.222.166
Sent:
Sent:
got udp packet from 192.168.222.100
Sent:
got udp packet from 192.168.222.100
Sent:
got udp packet from 192.168.222.136
got udp packet from 192.168.222.100
got udp packet from 192.168.222.100
got udp packet from 192.168.222.100
im getting a lot of:
scandone
no ssid-name found, reconnect after 1s
Sent:
LmacRxBlk:1
reconnect
connection is stable, i have ap at 10 centimeters from esp
no ssid-name found, reconnect after 1s
is not stabel infact its lost connection to AP
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
at the top of loop
Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9\bin\xtensa-lx106-elf-g++" (in directory "."): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
file not found
[igrokhotkov@igrokhot-mbp /tmp]$ tar -tzf win32-xtensa-lx106-elf.tar.gz | grep g++
xtensa-lx106-elf/xtensa-lx106-elf/bin/g++.exe
[igrokhotkov@igrokhot-mbp /tmp]$ tar -tzf win32-xtensa-lx106-elf.tar.gz | grep g++
xtensa-lx106-elf/xtensa-lx106-elf/bin/g++.exe
xtensa-lx106-elf/share/man/man1/xtensa-lx106-elf-g++.1
xtensa-lx106-elf/bin/xtensa-lx106-elf-g++.exe
$ sha1sum -b win32-xtensa-lx106-elf.tgz
07b7d398cc0ca9e863073a6558668fa0a510b8cd *win32-xtensa-lx106-elf.tgz
@igrr now I can build in Arduino-IDE: >Arduino: 1.6.4 (Windows 8.1), Platine: "Generic ESP8266 Module, 80 MHz, 115200, 512K (64K SPIFFS)"
In file included from D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\WiFiClient.h:24:0,
from D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFi.h:32,
from D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.h:30,
from D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi\src\ESP8266WiFiMulti.cpp:26:
d:\users\peter\documents\arduino\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_vector.h: In member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const':
D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Arduino.h:217:18: error: expected unqualified-id before '(' token
^
d:\users\peter\documents\arduino\hardware\esp8266com\esp8266\tools\xtensa-lx106-elf\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_bvector.h: In member function 'std::vector<bool, _Alloc>::size_type std::vector<bool, _Alloc>::_M_check_len(std::vector<bool, _Alloc>::size_type, const char*) const':
D:\Users\Peter\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Arduino.h:217:18: error: expected unqualified-id before '(' token
^
Fehler beim Kompilieren.