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

Function handleCommand

samples/Basic_Serial/app/application.cpp:212–232  ·  view source on GitHub ↗

SerialReadingDelegateDemo calls this function when a command line has been entered

Source from the content-addressed store, hash-verified

210
211// SerialReadingDelegateDemo calls this function when a command line has been entered
212void handleCommand(const String& command)
213{
214 if(command.equalsIgnoreCase(_F("cat"))) {
215 String filename = F("README.md");
216 FileStream* fileStream = new FileStream;
217 if(fileStream && fileStream->open(filename, File::ReadOnly)) {
218 Serial << _F("Sending \"") << filename << "\" (" << fileStream->available() << " bytes)" << endl;
219 auto demo = new SerialTransmitDemo(Serial1, fileStream);
220 demo->begin();
221 } else {
222 Serial << _F("Failed to open file \"") << filename << '"' << endl;
223 delete fileStream;
224 }
225 } else if(command.equalsIgnoreCase(_F("text"))) {
226 Serial << _F("Sending flash data, ") << testFlashData.length() << " bytes" << endl;
227 auto demo = new SerialTransmitDemo(Serial, new FlashMemoryStream(testFlashData));
228 demo->begin();
229 } else {
230 Serial << _F("I don't know what \"") << command << _F("\" means! Try typing: cat") << endl;
231 }
232}
233
234} // namespace
235

Callers

nothing calls this directly

Calls 6

FFunction · 0.50
equalsIgnoreCaseMethod · 0.45
openMethod · 0.45
availableMethod · 0.45
beginMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected