MCPcopy Create free account
hub / github.com/SmingHub/Sming / handleCommand

Function handleCommand

samples/Basic_Ota/app/application.cpp:134–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void 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) {

Callers 2

serialCallBackFunction · 0.70

Calls 15

doUpgradeFunction · 0.85
doSwitchFunction · 0.85
printlnMethod · 0.80
showInfoFunction · 0.70
FFunction · 0.50
configMethod · 0.45
enableMethod · 0.45
connectMethod · 0.45
getIPMethod · 0.45
getMacAddressMethod · 0.45
restartMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected