#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
char* ssid = "TE-Data";
//your wifi name or ssid
char* password = "0544835550";
//your wifi password
int mine[400];
// arrey that contain mins
bool connectToWifi(char*,char*,IPAddress);
bool sendDATA(IPAddress sendip ,char* sendBuffer,int port);
int reseveDATA(IPAddress myip ,char* reseveBuffer,int port);
IPAddress myip(192, 168, 1, 7); // NETWORK: Static myip details... // myipAddress is object for ip so you can use ip in function
IPAddress sendip(192,168,1,4);
WiFiUDP Udp;
char* sendBuffer="hi";
char reseveBuffer[255];
void setup() {
Serial.begin(115200);
delay(10);
connectToWifi(ssid,password,myip);
}
void loop() {
//sendDATA(sendip ,sendBuffer,8015);
int tem =reseveDATA(myip,reseveBuffer,8015);
}
bool connectToWifi(char* ssid ,char* password,IPAddress myip)
{
// NETWORK: Static myip details...
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
// that function make connection to the rourter with bassfic myip
Serial.print("Connecting to ");
Serial.println(ssid);
//for dubbigig only
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("\"");
Serial.println("WiFi connected to ip :");
Serial.println(WiFi.localIP());
}
bool sendDATA(IPAddress sendip ,char* sendBuffer,int port)
{
Udp.beginPacket(sendip, port);
Udp.write(sendBuffer);
bool bol= Udp.endPacket();
return (bol);
}
int reseveDATA(IPAddress myip ,char* reseveBuffer,int port)
{
Udp.beginMulticast(WiFi.localIP(),sendip , port);
IPAddress remote = Udp.remoteIP();
int no;
if(no = Udp.parsePacket())
{
Udp.read(reseveBuffer, no);
for (int i=0;i<no;i++)
{
Serial.println(reseveBuffer[i-1]);
}
}
return (no);
}
Moderator: igrr
http://www.hackster.io/rayburne/tardis-time-esp8266-ap-webserver-gps-6b5d2a
Ray