value of millis = unsigned long ini= 0 ;
value of millis =
value of millis = 0000void setup()
value of millis = {
value of millis = 0004 Serial.begin(115200);
value of millis = 0007 delay(10);
value of millis = 0017
value of millis = 0021 wifisecure.setInsecure();
value of millis = 0025 while (status != WL_CONNECTED) {
value of millis = 0027 Serial.print("Attempting to connect to SSID: ");
value of millis = 0029 Serial.println(ssid);
value of millis = // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
value of millis = 0031 status = WiFi.begin(ssid, pass);
value of millis =
value of millis = // wait 5 seconds for connection:
value of millis = 5031 delay(5000);
value of millis = }
value of millis =
value of millis = 10031 Serial.println("Connected to WiFi");
value of millis =
value of millis =
value of millis = //c8yclient.subscriptionCreate(username,password,host, device_id,"mo" ,SubscriptionName, APIs,typeFilter,fragmentsToCopy);
value of millis = 10033 unsigned long endtime=millis();
value of millis = 10034 if((endtime-ini)>5000)
// as ini has value 0 and endtime has value 10034
// the result of the calulcation is 10034 - 0 = 10034 which is greater than 5000
// The if-condition is instantly true
value of millis = Serial.println(endtime-ini);
value of millis = c8yclient.tokenCreate(host, SubscriptionName, SubscriberName, expiretime);
value of millis = c8yclient.tokenCreatePassword(username,password,host, SubscriptionName, SubscriberName, expiretime);
additionally your if-condition is outside the while-loop.
If you expected the code to wait this does not happen.
The if-condition
if((endtime-ini)>5000)
is executed once and then code-execution goes on
with
c8yclient.tokenCreate(host, SubscriptionName, SubscriberName, expiretime);
You should post your complete sketch using this method
best regards Stefan