-
Notifications
You must be signed in to change notification settings - Fork 0
/
loopBindingMode.ino
31 lines (31 loc) · 1.2 KB
/
loopBindingMode.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void loopBindingMode(){
blinkLED(100);
if(digitalRead(BindPin) == LOW) {
// Serial.println("Get your finger off the bind button");
}
if (SendBindingComplete == false) SendBindingInfo();
waitingForBindingMessage();
if (SendBindingComplete == true && ReceiveBindingComplete == true){
Serial.println("resetting");
ESP.restart();
}
}
//**********************************************************************************************
void SendBindingInfo(){
static unsigned long previousMillis;
if( (millis() - previousMillis) > 200){ // send binding request every 200 milliseconds
previousMillis = millis();
uint8_t Data[sizeof(SendingBindingData)];
memcpy(Data, &SendingBindingData, sizeof(SendingBindingData));
esp_now_send(NULL, Data, sizeof(Data)); // NULL means send to all peers
}
}
// print message every 3 seconds that we are waiting for binding info
//**********************************************************************************************
void waitingForBindingMessage(){
static uint32_t previousMillis;
if( (millis() - previousMillis) > 3000){
previousMillis = millis();
Serial.println("waiting binding info");
}
}