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

Function onRx

samples/Basic_DateTime/app/application.cpp:76–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void onRx(Stream& source, char, uint16_t)
77{
78 static LineBuffer<32> buffer;
79
80 using Action = LineBufferBase::Action;
81 switch(buffer.process(source, Serial)) {
82 case Action::submit: {
83 if(!buffer) {
84 break;
85 }
86 String s(buffer);
87 buffer.clear();
88 char* p;
89 time_t timestamp = strtoll(s.c_str(), &p, 0);
90 if(p == s.end()) {
91 Serial << endl << _F("****Showing DateTime formatting options for Unix timestamp: ") << timestamp << endl;
92 showTime(timestamp);
93 break;
94 }
95
96 DateTime dt;
97 if(dt.fromHttpDate(s)) {
98 Serial << endl << _F("****Showing DateTime formatting options for Http time: ") << s << endl;
99 showTime(dt);
100 break;
101 }
102
103 if(dt.fromISO8601(s)) {
104 Serial << endl << _F("****Showing DateTime formatting options for ISO8601 date/time: ") << s << endl;
105 showTime(dt);
106 break;
107 }
108
109 Serial << endl << _F("Please enter a valid numeric timestamp, HTTP or ISO8601 date/time string!") << endl;
110 break;
111 }
112
113 case Action::clear:
114 break;
115
116 default:;
117 return;
118 }
119
120 Serial.print(commandPrompt);
121}
122
123} // namespace
124

Callers

nothing calls this directly

Calls 8

showTimeFunction · 0.85
fromHttpDateMethod · 0.80
fromISO8601Method · 0.80
processMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45
endMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected