Thanks for answer but I show what is problem, it is not so simple.
In first example is RemoteXY_button_led.ino. That is my RemoteXY program where is only button and LED.
RemoteXY generates mainly all. There is nothing for WiFiManager because normal program has hard cored SSID and PASSWORD which are my own, of course. That program works fine, of course. OK.
Second example is named RemoteXY_button_led_ssid_password_2.ino.
That try to use WiFimanager.h and your example code and includes library remotexy_custom.h.
Main fuction is exact as normal button-led-program. This doesn't work.
If SSID or PASSWORD was same than before in ESP8266 mobile app will be open with the button and LED. OK.
If SSID or PASSWORD has been changed to unknown, WiFiManager makes ESP8266 to hotspot. OK.
Now I can see new hot spot SSID and I connect my mobile to it using correct password. OK.
After that system is connecting back to RemoteXT mobile app succeeds too. I can see button and LED.
Then there is my problem.
When pushing the button nothing happens. No see red LED on screen of mobile, no LED light on ESP8266.
I can see that it is impossble to work bercause normal RemoteXY needs library RemoteXY.h.
May be problem is in different struct RemoteXY and your remotexyStruct
Please, help me and other on the right path here in difficult RemoteXY / WiFiManager world.
// ******************************************************************************
// RemoteXY_button_led.ino
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_CLOUD
#include <ESP8266WiFi.h>
#include <RemoteXY.h> // Must be here for RemoteXY
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "YOUR_SSID"
#define REMOTEXY_WIFI_PASSWORD "YOUR_PASS"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "ac5228930e1355372225655f4a9a46f6"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255, 1, 0, 1, 0, 19, 0, 10, 13, 1,
1, 0, 27, 26, 12, 12, 2, 31, 88, 0,
65, 4, 30, 9, 9, 9
};
// this structure defines all the variables and events of your control interface
struct
{
// input variables
uint8_t button_1; // =1 if button pressed, else =0
// output variables
uint8_t led_1_r; // =0..255 LED Red brightness
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
}
RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_BUTTON_1 D4 // Sisäinen LED GPIO2
byte pushed = 0;
//======================================================================
void setup()
{
Serial.begin(115200);
RemoteXY_Init ();
pinMode (PIN_BUTTON_1, OUTPUT); // Builtin LED
}
//======================================================================
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1 == 0) ? HIGH : LOW);
if ((RemoteXY.button_1 == 1) && (pushed == 0)) // Push button of mobile screen
{
RemoteXY.led_1_r = 255;
pushed = 1;
}
if (RemoteXY.button_1 == 0) // Release button of mobile screen
{
pushed = 0;
RemoteXY.led_1_r = 0; // LED is dark on the screen and builtin LED
}
}
// ******************************************************************************
// RemoteXY_button_led_ssid_password_2.ino
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
//#include <RemoteXY.h> // If this is used:
// // #error RemoteXY mode does not defined or
// // defined error: REMOTEXY_MODE__XXXXXXX
#include <remotexy_custom.h> // tämä pitää olla lisättynä
CRemoteXY_Cloud remotexy;
const char * remotexyCloudToken = "ac5228930e1355372225655f4a9a46f6";
#pragma pack(push, 1)
uint8_t remotexyConfig[] =
{ 255, 1, 0, 1, 0, 19, 0, 10, 13, 1,
1, 0, 27, 26, 12, 12, 2, 31, 88, 0,
65, 4, 30, 9, 9, 9
};
struct
{
uint8_t connect_flag;
uint8_t button_1; // =1 if button pressed, else =0
uint8_t led_1_r; // =0..255 LED Red brightness
} remotexyStruct;
#pragma pack(pop)
#define PIN_BUTTON_1 D4 // Builtin LED pin GPIO2 in ESP8266
byte pushed = 0;
//======================================================================
void setup()
{
Serial.begin(115200);
WiFiManager wifiManager;
wifiManager.autoConnect("AutoConnectAP");
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
// Start remotexy now
remotexy.begin( remotexyConfig, &remotexyStruct, "", remotexyCloudToken );
// remotexy.begin( RemoteXY_CONF, &remotexyStruct, "", remotexyCloudToken ); // NORMAALI
pinMode (PIN_BUTTON_1, OUTPUT); // Builtin LED
}
//======================================================================
void loop()
{
remotexy.handler();
digitalWrite(PIN_BUTTON_1, (remotexyStruct.button_1 == 0) ? HIGH : LOW);
if ((remotexyStruct.button_1 == 1) && (pushed == 0)) // Push button of mobile screen
{
remotexyStruct.led_1_r = 255; // LED is red on the screen and builtin LED
pushed = 1;
}
if (remotexyStruct.button_1 == 0) // Release button of mobile screen
{
pushed = 0;
remotexyStruct.led_1_r = 0; // LED is dark on the screen and builtin LED
}
}