/* AllWize - Returns the module to factory settings Resets the module non-volatile memory to factory settings. Copyright (C) 2018-2021 by AllWize This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #include "AllWize.h" // ----------------------------------------------------------------------------- // Board definitions // ----------------------------------------------------------------------------- #if defined(ARDUINO_AVR_UNO) #define RESET_PIN 7 #define RX_PIN 8 #define TX_PIN 9 #define DEBUG_SERIAL Serial #endif // ARDUINO_AVR_UNO #if defined(ARDUINO_AVR_LEONARDO) #define RESET_PIN 7 #define MODULE_SERIAL Serial1 #define DEBUG_SERIAL Serial #endif // ARDUINO_AVR_LEONARDO #if defined(ARDUINO_ARCH_SAMD) #if defined(ARDUINO_ALLWIZE_K2) #define RESET_PIN PIN_WIZE_RESET #define MODULE_SERIAL SerialWize #define DEBUG_SERIAL SerialUSB #else #define RESET_PIN 7 #define MODULE_SERIAL Serial1 #define DEBUG_SERIAL SerialUSB #endif #endif // ARDUINO_ARCH_SAMD #if defined(ARDUINO_ARCH_ESP8266) #define RESET_PIN 14 #define RX_PIN 5 #define TX_PIN 4 #define DEBUG_SERIAL Serial #endif // ARDUINO_ARCH_ESP8266 #if defined(ARDUINO_ARCH_ESP32) #define RESET_PIN 14 #define RX_PIN 12 #define TX_PIN 13 #define DEBUG_SERIAL Serial #endif // ARDUINO_ARCH_ESP32 // ----------------------------------------------------------------------------- // Globals // ----------------------------------------------------------------------------- #if defined(MODULE_SERIAL) AllWize allwize(&MODULE_SERIAL, RESET_PIN); #else AllWize allwize(RX_PIN, TX_PIN, RESET_PIN); #endif // ----------------------------------------------------------------------------- // Main // ----------------------------------------------------------------------------- void setup() { DEBUG_SERIAL.begin(115200); while (!DEBUG_SERIAL && millis() < 5000); DEBUG_SERIAL.println(); DEBUG_SERIAL.println("AllWize - Factory reset"); DEBUG_SERIAL.println(); // Init AllWize object allwize.begin(); if (!allwize.waitForReady()) { DEBUG_SERIAL.println("Error connecting to the module, check your wiring!"); while (true); } allwize.factoryReset(); if (!allwize.waitForReady()) { DEBUG_SERIAL.println("Error reconnecting to the module after Factory Reset!"); while (true); } allwize.dump(DEBUG_SERIAL); } void loop() { delay(1); }