Topic: WifiManager
Hello
I'm trying to implement the features of WiFiManager in a simple RemoteXY project.
I found an example that I adapted to my case, but even if Wifimanager does its job RemoteXY doesn't.
Something is incorrect in my listing.
I am attaching the project and I hope someone can tell me what is wrong.
thanks
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
//#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT // per creare un AP
#define REMOTEXY_MODE__ESP8266WIFI_LIB // per collegarti attraverso la LAN
#include <ESP8266WiFi.h>
#include <RemoteXY.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiManager.h>
ESP8266WiFiMulti WiFiMulti;
char con_ssid[32]; //will hold the ssid of the wlan to which it is connectd
char con_psk[64]; // ^^ private shared key for the wlan (password)
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID ""
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_SERVER_PORT 6377 // dell'app
#define REMOTEXY_ACCESS_PASSWORD "1"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,1,0,1,0,26,0,8,13,1,
2,0,20,13,22,11,2,26,31,31,
79,78,0,79,70,70,0,65,4,25,
33,9,9 };
// this structure defines all the variables of your control interface
struct
{
// input variable
uint8_t switch_1; // =1 if switch ON and =0 if OFF
// output variable
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_SWITCH_1 BUILTIN_LED
void setup()
{
RemoteXY_Init ();
pinMode (PIN_SWITCH_1, OUTPUT);
Serial.begin(115200);
WiFiManager wifiManager;
// wifiManager.setSTAStaticIPConfig(ip, gw, mask);
if (!wifiManager.autoConnect("WiFi", "12345678"))
{
Serial.println("failed to connect, we should reset as see if it connects");
delay(3000);
ESP.reset();
delay(5000);
}
//if you get here you have connected to the WiFi
Serial.printf("connected to %s\n", con_ssid);
Serial.println("local ip");
Serial.println(WiFi.localIP());
WiFi.SSID().toCharArray(con_ssid, 32);
WiFi.psk().toCharArray(con_psk, 64);
remotexy = new CRemoteXY (RemoteXY_CONF_PROGMEM, &RemoteXY, REMOTEXY_ACCESS_PASSWORD, con_ssid , con_psk, REMOTEXY_SERVER_PORT );
Serial.println("Setup Done.");
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
RemoteXY.led_1_r = (digitalRead(PIN_SWITCH_1)==HIGH)?255:0;
}