|
| 1 | +/* |
| 2 | + Copyright (c) 2025 Arduino SA |
| 3 | +
|
| 4 | + This Source Code Form is subject to the terms of the Mozilla Public |
| 5 | + License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 | + file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 | +*/ |
| 8 | + |
| 9 | +/* |
| 10 | + * This sketch wipes out the stored network configuration |
| 11 | + * using the NetworkConfigurator library. |
| 12 | + * This sketch doesn't use the reconfiguration procedure. |
| 13 | +*/ |
| 14 | + |
| 15 | +#include <Arduino_ConnectionHandler.h> |
| 16 | +#include <GenericConnectionHandler.h> |
| 17 | +#include <Arduino_KVStore.h> |
| 18 | +#include <Arduino_NetworkConfigurator.h> |
| 19 | +#include <configuratorAgents/agents/BLEAgent.h> |
| 20 | +#include <configuratorAgents/agents/SerialAgent.h> |
| 21 | + |
| 22 | +KVStore kvstore; |
| 23 | +BLEAgentClass BLEAgent; |
| 24 | +SerialAgentClass SerialAgent; |
| 25 | +GenericConnectionHandler conMan; |
| 26 | +NetworkConfiguratorClass NetworkConfigurator(conMan); |
| 27 | + |
| 28 | +void setup() { |
| 29 | + /* Initialize serial debug port and wait up to 5 seconds for port to open */ |
| 30 | + Serial.begin(9600); |
| 31 | + for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { } |
| 32 | + |
| 33 | + /* Set the debug message level: |
| 34 | + * - DBG_ERROR: Only show error messages |
| 35 | + * - DBG_WARNING: Show warning and error messages |
| 36 | + * - DBG_INFO: Show info, warning, and error messages |
| 37 | + * - DBG_DEBUG: Show debug, info, warning, and error messages |
| 38 | + * - DBG_VERBOSE: Show all messages |
| 39 | + */ |
| 40 | + setDebugMessageLevel(DBG_INFO); |
| 41 | + |
| 42 | + /* Set the KVStore */ |
| 43 | + NetworkConfigurator.setStorage(kvstore); |
| 44 | + /* Wipe out the network configuration */ |
| 45 | + if (NetworkConfigurator.resetStoredConfiguration()) { |
| 46 | + Serial.println("Network configuration reset successfully."); |
| 47 | + } else { |
| 48 | + Serial.println("Failed to reset network configuration."); |
| 49 | + } |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | +void loop() { |
| 54 | +} |
0 commit comments