1

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; 
 
}

2

Re: WifiManager

RemoteXY completely takes control of the wifi library. If you use RemoteXY library then you can not use wifi library.

3

Re: WifiManager

in practice it was enough to delete RemoteXY_init () from void setup () and insert:

//--- settaggi di Wifimanager-------
   WiFiManager wifiManager;
//  resetta la memoria cancellando le credenziali precedentemente memorizzate
// wifiManager.resetSettings();

WiFi.mode(WIFI_STA);
   
wifiManager.setTimeout(180); // resto inizialmente 180 secondi in modalità AP
 
  if (!wifiManager.autoConnect("WiFi-ESP", "12345678")) // credenziali per accedere alla modalità AP
  {
     delay(3000);
    ESP.reset();
    delay(5000);
  }
 

  //sono connesso alla WiFi locale....

  // recupero delle credenziali salvate da mandare a Remotexy
  WiFi.SSID().toCharArray(con_ssid, 32);
  WiFi.psk().toCharArray(con_psk, 64);

  // invio delle credenziali a RemoteXY - questa stringa cambia in funzione del tipo di interfaccia di comunicazione scelta

  remotexy = new CRemoteXY (RemoteXY_CONF_PROGMEM, &RemoteXY, REMOTEXY_ACCESS_PASSWORD,  con_ssid , con_psk, REMOTEXY_CLOUD_SERVER, REMOTEXY_CLOUD_PORT, REMOTEXY_CLOUD_TOKEN );

and it worked... (if configured cloud)

4

Re: WifiManager

hello pete68
i am searching for integration remotexy with wifimanager for the last 6 months without success!
thank God you solved it.
i tried your brief guidance but still, can't get it running..
= WOULD YOU PLEASE A.. POST A full working example, so once it is running then i can modify to adapt to my need .. but at least to have a working platform example base.
would u please?
thanks a lot

5 (edited by Guillaume 2019-11-25 10:06:20)

Re: WifiManager

This problem is easily solved if you follow my recommendation here and here. The goal is to make the RemoteXY library not mess with WiFi functions at all.