| 132 | } |
| 133 | |
| 134 | void handleCommand(const String& str) |
| 135 | { |
| 136 | if(F("connect") == str) { |
| 137 | Serial << _F("Connecting to '") << WIFI_SSID << "'..." << endl; |
| 138 | WifiStation.config(WIFI_SSID, WIFI_PWD); |
| 139 | WifiStation.enable(true); |
| 140 | WifiStation.connect(); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | if(F("ip") == str) { |
| 145 | Serial << "ip: " << WifiStation.getIP() << ", mac: " << WifiStation.getMacAddress() << endl; |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | if(F("ota") == str) { |
| 150 | doUpgrade(); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | if(F("switch") == str) { |
| 155 | doSwitch(); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | if(F("restart") == str) { |
| 160 | System.restart(); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | if(F("ls") == str) { |
| 165 | Directory dir; |
| 166 | if(dir.open()) { |
| 167 | while(dir.next()) { |
| 168 | Serial << " " << dir.stat().name << endl; |
| 169 | } |
| 170 | } |
| 171 | Serial << _F("filecount ") << dir.count() << endl; |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | if(F("cat") == str) { |
| 176 | Directory dir; |
| 177 | if(dir.open() && dir.next()) { |
| 178 | auto filename = dir.stat().name.c_str(); |
| 179 | Serial << "dumping file " << filename << ": " << endl; |
| 180 | // We don't know how big the is, so streaming it is safest |
| 181 | FileStream fs; |
| 182 | fs.open(filename); |
| 183 | Serial.copyFrom(&fs); |
| 184 | Serial.println(); |
| 185 | } else { |
| 186 | Serial.println(F("Empty spiffs!")); |
| 187 | } |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | if(F("info") == str) { |