- Wed Jul 26, 2017 3:47 am
#68583
Hi Rudy, thanks for the quick reply!
I'm posting the code below, as you'll see it's very basic.
When measuring the time between incoming UDP messages on my computer (with WireShark) I can tell that are transmitted irregularly, in intervals of 400-700 milliseconds, but the timer I put in the code reports 501-502 ms between transmissions.
Thanks so much for any help!
ith
here's the code:
-----------------------------------------------------------------------------------
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <OSCBundle.h>
//*** Soft Ap variables ***
const char *APssid = "ESPbase";
const char *APpassword = ""; // No password for the AP
IPAddress APlocal_IP(192, 168, 4, 1);
IPAddress APgateway(192, 168, 4, 1);
IPAddress APsubnet(255, 255, 255, 0);
int counter = 0;
long timer;
long timerPrev;
int timeDiff;
WiFiUDP udp;
void setup() {
Serial.begin(115200); //fire up the serial port
delay(5000);
WiFi.mode(WIFI_AP);
Serial.println("ESP8266 AP & Station & UDP System test");
Serial.print("Soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(APlocal_IP, APgateway, APsubnet) ? "OK" : "Failed!"); // configure network
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP(APssid, APpassword) ? "OK" : "Failed!"); // Setup the Access Point
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP()); // Confirm AP IP address
udp.begin(4210);
}
void loop() {
timer = millis();
timeDiff = (int)(timer - timerPrev);
OSCBundle bndl;
bndl.add("counter: ").add(counter).add(" difference: ").add(timeDiff);
udp.beginPacket("192.168.4.100",4210);
bndl.send(udp);
udp.endPacket();
Serial.println("counter:" + counter + " difference: " + timerDiff);
counter++;
timerPrev = timer;
delay(500);
}