I know I'm talking to myself here, but...
I'm using the example in the manual and I still can't get back a real time from the Arduino.
What am I missing?
/*
-- Testing time 1 --
For MEGA2560 and BT on Serial port 2
To compile this code using RemoteXY library 4.1.8 or later version
download by link http://remotexy.com/en/library/
To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- for ANDROID 4.18.03 or later version;
- for iOS 1.14.1 or later version;
To interact with the GUI, please refer to the manual:
https://remotexy.com/ru/help/code/interaction/
This source code was automatically generated by the RemoteXY editor and
is an example for the RemoteXY library.
Licensed under the MIT License. See the LICENSE file in the RemoteXY library
root (https://github.com/RemoteXY/RemoteXY-Arduino-library) for full license
details.
*/
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial2
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_ACCESS_PASSWORD "1234"
#include <RemoteXY.h>
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t const PROGMEM RemoteXY_CONF_PROGMEM[] = // 44 bytes V21
{ 254,0,0,0,0,1,0,0,0,33,0,21,0,0,0,72,80,32,77,101,
116,101,114,32,66,117,100,100,121,0,31,1,200,112,1,1,1,0,193,92,
31,11,11,3 };
// this structure defines all the variables and events of your control interface
struct {
// complex variables
RemoteXYType_RealTime realTime_01; // use .getTimeStamp(), .getTime()
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
int doOnce = 0; //Flag to getting App Time once
void setup(){
RemoteXY_Init (); //Initialization by macros
Serial.begin(115200); //Serial monitor debug
}
void loop(){ //Main loop
RemoteXYEngine.handler ();
checkAppConnected(); //Time testing in this function
RemoteXYEngine.delay(1000); //Simulate meter loop cycle speed
}
/*---------------------------------------------------------------------------------------------
===================== checkAppConnected() ===================================================
---------------------------------------------------------------------------------------------*/
void checkAppConnected(){
if (!RemoteXYEngine.appConnected()) return; //Wait for app to connect...
if (doOnce == 0){ //...then get app time ONCE
RemoteXYEngine.delay(1000); //Getting time too soon after
// connection is unstable
RemoteXYTime time = RemoteXYTime(RemoteXY.realTime_01.getAppTime()); //THIS WORKS - will set time to app time
doOnce = 1; //Set flag (done once)
Serial.println (time.format("d MMM YYYY, HH:mm:ss")); //THIS WORKS - Prints the current time
Serial.println("Done once..."); //Debug - made it through once
return; //Return after done once
}
// The following (verbatim) from the manual on the website does not work.
// It never print any time, because time = Epoch time. I commented out .isEmpty line to be sure.
int timeZone = 5 * 60; // UTC+5
RemoteXYTime time = RemoteXY.realTime_01.getTime(timeZone);
//if (!time.isEmpty ()) { //Commented out to 'see' what time was
Serial.println (time.format("d MMM YYYY, HH:mm:ss")); //Prints "1 Jan 1970, 00:00:00"
}
With the .isEmpty line commented out, this is what I get:
2 Feb 2026, 19:05:49
Done once...
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00
1 Jan 1970, 00:00:00