Skip to content

Commit

Permalink
Restart after one minute not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
heisenberg2980 committed Jun 16, 2022
1 parent a70056e commit be8a00a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ platform = espressif32
board = nodemcu-32s
framework = arduino
lib_deps = t-vk/ESP32 BLE Mouse@^0.3.1
monitor_speed = 115200
30 changes: 24 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,43 @@ void setup() {
Serial.begin(115200);
Serial.println("Starting BLE work!");
bleMouse.begin();
//pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {

static long mouseTick = millis();
static long resetTick = millis();

if(bleMouse.isConnected()) {

Serial.println("Move mouse pointer up");
bleMouse.move(0,-1);
//digitalWrite(LED_BUILTIN, HIGH);
bleMouse.move(0,-1);
//digitalWrite(LED_BUILTIN, LOW);
delay(1000);

Serial.println("Move mouse pointer down");
bleMouse.move(0,1);
//digitalWrite(LED_BUILTIN, LOW);
bleMouse.move(0,1);
//digitalWrite(LED_BUILTIN, HIGH);

delay(60000);
mouseTick = millis();
resetTick = millis();

}
else {
Serial.println("BLE not connected");
delay(1000);
//digitalWrite(LED_BUILTIN, LOW);
//delay(60000);
if (millis() - mouseTick > 10000) {
mouseTick = millis();
Serial.println("BLE not connected");
if (millis() - resetTick > 60000) {
resetTick = millis();
Serial.println("Restarting");
ESP.restart();
}
}
//digitalWrite(LED_BUILTIN, HIGH);
//delay(120000);
}
}

0 comments on commit be8a00a

Please sign in to comment.