I can’t get local time from char array in my terminal (V100)
It compiles and after that terminal displays only:
“Blynk v0.5.4: Serwer connected
----------”
but as supring for me it displays on putty terminal like this:
[0]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on Linux
[1] Connecting to xxx.xxx.x.xxx:xxxx
[12] Ready (ping: 11ms).
Now it's 06:21PM.
and this is code in main.cpp
//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
#include <BlynkApiWiringPi.h>
#else
#include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>
#include <Time/TimeLib.h>
static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
static const char *auth, *serv;
static uint16_t port;
#include <BlynkWidgets.h>
WidgetTerminal terminal(V100);
BlynkTimer tmr;
char* currentTime() {
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime(buffer,80,"Now it's %I:%M%p.",timeinfo);
puts(buffer);
return buffer;
}
bool boot = true;
BLYNK_CONNECTED() {
if (boot) {
Blynk.virtualWrite(V100, "clr");
Blynk.virtualWrite(V100, "Blynk v" BLYNK_VERSION ": Serwer connected\n");
Blynk.virtualWrite(V100, currentTime());
Blynk.virtualWrite(V100, "-------------\n");
boot = false;
} else {
Blynk.virtualWrite(V100, "Blynk v" BLYNK_VERSION ": Serwer reconnected\n");
Blynk.virtualWrite(V100, "-------------\n");
}
}
void setup() {
Blynk.begin(auth, serv, port);
tmr.setInterval(1000, [](){
Blynk.virtualWrite(V0, BlynkMillis()/1000);
});
}
void loop() {
Blynk.run();
tmr.run();
}
int main(int argc, char* argv[]) {
parse_options(argc, argv, auth, serv, port);
setup();
while (true) {
loop();
}
return 0;
}
I am very frustrated and also have a question why on raspberry pi there is no string support for virtualWrite?