1 (edited by reaz87 2024-03-12 19:30:38)

Topic: How to set custom Access Password? ESP8266

I developed a project. Client want to change GUI access password time to time. How it is possible. Please help.
My code is



/*
      
   This source code of graphical user interface 
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 3.1.10 or later version 
   download by link [url]http://remotexy.com/en/library/[/url]
   To connect using RemoteXY mobile app by link [url]http://remotexy.com/en/download/[/url]                   
     - for ANDROID 4.13.1 or later version;
     - for iOS 1.10.1 or later version;
    
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.    
*/

//////////////////////////////////////////////
//        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__ESP8266WIFI_LIB_CLOUD
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_WIFI_SSID "Ibnat"
#define REMOTEXY_WIFI_PASSWORD "0171724xxxxx"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#define REMOTEXY_ACCESS_PASSWORD "123"



// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 325 bytes
  { 255,26,0,25,0,62,1,17,0,0,0,24,1,126,200,1,1,29,0,130,
  254,28,136,169,0,181,1,92,133,27,24,1,2,31,68,73,83,80,76,65,
  89,0,1,8,130,32,32,0,1,31,67,76,79,83,69,0,1,50,130,32,
  32,0,12,31,79,80,69,78,0,70,21,119,6,6,16,26,37,0,70,63,
  119,6,6,16,26,135,0,69,50,163,8,8,1,69,4,160,8,8,1,69,
  89,162,8,8,1,130,254,242,140,20,0,205,130,246,198,140,22,0,205,129,
  82,198,36,4,31,68,101,118,101,108,111,112,101,100,32,66,121,32,82,101,
  97,122,0,129,40,252,52,8,31,49,49,75,86,32,65,67,82,45,48,49,
  0,130,2,75,62,12,0,41,130,66,75,58,12,0,139,70,46,78,6,6,
  16,26,37,0,70,114,78,6,6,16,26,136,0,129,4,77,37,8,8,80,
  111,119,101,114,32,79,78,0,129,70,77,40,8,8,80,111,119,101,114,32,
  79,70,70,0,130,254,8,130,18,0,209,3,72,10,25,14,130,2,26,129,
  2,12,59,10,24,83,69,76,69,67,84,32,65,67,82,0,67,94,117,24,
  10,5,2,26,4,129,3,43,3,4,147,0,130,2,50,122,16,0,19,67,
  5,52,117,13,5,37,19,11,7,61,33,61,11,1,8,181,11,129,6,35,
  55,8,8,70,101,101,100,101,114,32,78,97,109,101,58,0,7,0,28,59,
  4,0,12,26,11 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t display_button; // =1 if button pressed, else =0
  uint8_t close_button; // =1 if button pressed, else =0
  uint8_t button_2; // =1 if button pressed, else =0
  uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
  char edit_01[11]; // string UTF8 end zero
  char edit_02[11]; // string UTF8 end zero

    // output variables
  uint8_t incm_2_close_led; // led state
  uint8_t incm_2_open_led; // led state
  int16_t incm_2_open_sound; // =0 no sound, else ID of sound, =1001 for example, look sound list in app
  int16_t incm_2_close_sound; // =0 no sound, else ID of sound, =1001 for example, look sound list in app
  int16_t incm_2_display_sound; // =0 no sound, else ID of sound, =1001 for example, look sound list in app
  uint8_t elec_close_led; // led state
  uint8_t elecIncm_2_open_led; // led state
  char text_display[4]; // string UTF8 end zero
  char status_text[11]; // string UTF8 end zero

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)
 
/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_DISPLAY_BUTTON D7
#define PIN_CLOSE_BUTTON D5
#define PIN_BUTTON_2 D6


void setup() 
{
  RemoteXY_Init (); 
  
  pinMode (PIN_DISPLAY_BUTTON, OUTPUT);
  pinMode (PIN_CLOSE_BUTTON, OUTPUT);
  pinMode (PIN_BUTTON_2, OUTPUT);
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_DISPLAY_BUTTON, (RemoteXY.display_button==0)?LOW:HIGH);
  digitalWrite(PIN_CLOSE_BUTTON, (RemoteXY.close_button==0)?LOW:HIGH);
  digitalWrite(PIN_BUTTON_2, (RemoteXY.button_2==0)?LOW:HIGH);
  
  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay(), use instead RemoteXY_delay() 


}

Advance thanks to all.

2

Re: How to set custom Access Password? ESP8266

Example of changing the RemoteXY access password.
Use EEPROM to store the password when the power is turned off.
Use the physical button to reset your password. You can forget it.

//////////////////////////////////////////////
//        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__ESP8266WIFI_LIB_CLOUD
#include <ESP8266WiFi.h>
#include <EEPROM.h>


// RemoteXY connection settings 
#define REMOTEXY_WIFI_SSID "myHomeWiFiPoint"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxx"

// redirect to global variable accessPassword
#define REMOTEXY_ACCESS_PASSWORD accessPassword

#include <RemoteXY.h>


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 79 bytes
  { 255,27,0,0,0,64,0,17,0,0,0,31,1,106,200,1,1,3,0,1,
  16,99,73,13,2,28,31,83,101,116,32,110,101,119,32,112,97,115,115,0,
  7,17,80,72,12,4,30,26,26,129,17,71,46,6,27,65,99,99,101,115,
  115,32,112,97,115,119,111,114,100,58,0 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t changePasswordButton; // =1 if button pressed, else =0
  char accessPassword[26]; // string UTF8 end zero

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)
 
/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

// change access password settings
char accessPassword[26];  // this variable stores the access password
#define PIN_BUTTON_RESET_SWTTINGS 3   // pin of button to reset the password
// EEPROM addresses
#define addrEPPROM_Check 0x0000  
#define addrEPPROM_AccessPassword 0x0001
#define checkValueForEPPROM 0x55  // sign of data validity in EEPROM 
uint8_t prevChangePasswordButton = 0; // to catch a button click in the GUI


void setup() 
{
  EEPROM.begin(sizeof(accessPassword)+1);
  pinMode (PIN_BUTTON_RESET_SWTTINGS, INPUT);

  boolean EEPROMisValid = readAccessPasswordFromEEPROM ();
  if (!EEPROMisValid) {
    setAccessPassword (""); // set defoult access password - NO PASSWORD
  }
  
  RemoteXY_Init (); 
  
  strcpy  (RemoteXY.accessPassword, accessPassword); // copy password to GUI

  // TODO you setup code
  
}

boolean readAccessPasswordFromEEPROM () {
  if (EEPROM.read(addrEPPROM_Check) == checkValueForEPPROM) {
    for (uint8_t i = 0; i<sizeof(accessPassword); i++) accessPassword[i] = EEPROM.read(addrEPPROM_AccessPassword+i); 
    return true;
  }
  return false;  
}

void writeAccessPasswordToEEPROM () {
  for (uint8_t i = 0; i<sizeof(accessPassword); i++) EEPROM.write (addrEPPROM_AccessPassword+i, accessPassword[i]);  
  EEPROM.write (addrEPPROM_Check, checkValueForEPPROM);    
  EEPROM.commit ();  
}

void setAccessPassword (char * newpAccessPssword) {
  strcpy  (accessPassword, newpAccessPssword);
  remotexy->setPassword (accessPassword);
  writeAccessPasswordToEEPROM ();     
}


void loop() 
{ 
  RemoteXY_Handler ();

  if ((prevChangePasswordButton == 0) && (RemoteXY.changePasswordButton !=0)) {
    setAccessPassword (RemoteXY.accessPassword);
  }
  prevChangePasswordButton = RemoteXY.changePasswordButton;

  // if need reset password then uncomment this code
  // This is an example code, it's not very good. 
  // Because the EEPROM will be recorded in every loop cycle while the button is pressed, which is not very good for the EEPROM 
  // You need to catch the moment the button is pressed.
  // You can also wait that the button has been pressed for 3-5 seconds
  /*
  if (digitalRead(PIN_BUTTON_RESET_SWTTINGS)) {
    setAccessPassword (""); // reset access password - NO PASSWORD
  }
  */

}

3

Re: How to set custom Access Password? ESP8266

Thank you very much to Administrator of RemoteXY.

4

Re: How to set custom Access Password? ESP8266

"#define PIN_BUTTON_RESET_SWTTINGS 3"

Is it GPIO3  pin? means RX pin?

5 (edited by reaz87 2024-03-13 17:17:36)

Re: How to set custom Access Password? ESP8266

remotexy wrote:

Example of changing the RemoteXY access password.
Use EEPROM to store the password when the power is turned off.
Use the physical button to reset your password. You can forget it.

//////////////////////////////////////////////
//        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__ESP8266WIFI_LIB_CLOUD
#include <ESP8266WiFi.h>
#include <EEPROM.h>


// RemoteXY connection settings 
#define REMOTEXY_WIFI_SSID "myHomeWiFiPoint"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxx"

// redirect to global variable accessPassword
#define REMOTEXY_ACCESS_PASSWORD accessPassword

#include <RemoteXY.h>


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 79 bytes
  { 255,27,0,0,0,64,0,17,0,0,0,31,1,106,200,1,1,3,0,1,
  16,99,73,13,2,28,31,83,101,116,32,110,101,119,32,112,97,115,115,0,
  7,17,80,72,12,4,30,26,26,129,17,71,46,6,27,65,99,99,101,115,
  115,32,112,97,115,119,111,114,100,58,0 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t changePasswordButton; // =1 if button pressed, else =0
  char accessPassword[26]; // string UTF8 end zero

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)
 
/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

// change access password settings
char accessPassword[26];  // this variable stores the access password
#define PIN_BUTTON_RESET_SWTTINGS 3   // pin of button to reset the password
// EEPROM addresses
#define addrEPPROM_Check 0x0000  
#define addrEPPROM_AccessPassword 0x0001
#define checkValueForEPPROM 0x55  // sign of data validity in EEPROM 
uint8_t prevChangePasswordButton = 0; // to catch a button click in the GUI


void setup() 
{
  EEPROM.begin(sizeof(accessPassword)+1);
  pinMode (PIN_BUTTON_RESET_SWTTINGS, INPUT);

  boolean EEPROMisValid = readAccessPasswordFromEEPROM ();
  if (!EEPROMisValid) {
    setAccessPassword (""); // set defoult access password - NO PASSWORD
  }
  
  RemoteXY_Init (); 
  
  strcpy  (RemoteXY.accessPassword, accessPassword); // copy password to GUI

  // TODO you setup code
  
}

boolean readAccessPasswordFromEEPROM () {
  if (EEPROM.read(addrEPPROM_Check) == checkValueForEPPROM) {
    for (uint8_t i = 0; i<sizeof(accessPassword); i++) accessPassword[i] = EEPROM.read(addrEPPROM_AccessPassword+i); 
    return true;
  }
  return false;  
}

void writeAccessPasswordToEEPROM () {
  for (uint8_t i = 0; i<sizeof(accessPassword); i++) EEPROM.write (addrEPPROM_AccessPassword+i, accessPassword[i]);  
  EEPROM.write (addrEPPROM_Check, checkValueForEPPROM);    
  EEPROM.commit ();  
}

void setAccessPassword (char * newpAccessPssword) {
  strcpy  (accessPassword, newpAccessPssword);
  remotexy->setPassword (accessPassword);
  writeAccessPasswordToEEPROM ();     
}


void loop() 
{ 
  RemoteXY_Handler ();

  if ((prevChangePasswordButton == 0) && (RemoteXY.changePasswordButton !=0)) {
    setAccessPassword (RemoteXY.accessPassword);
  }
  prevChangePasswordButton = RemoteXY.changePasswordButton;

  // if need reset password then uncomment this code
  // This is an example code, it's not very good. 
  // Because the EEPROM will be recorded in every loop cycle while the button is pressed, which is not very good for the EEPROM 
  // You need to catch the moment the button is pressed.
  // You can also wait that the button has been pressed for 3-5 seconds
  /*
  if (digitalRead(PIN_BUTTON_RESET_SWTTINGS)) {
    setAccessPassword (""); // reset access password - NO PASSWORD
  }
  */

}


@ remotexy,
I can connect Wifi Access point using examples-> Setup Connection-> ESP_WiFiSetupUsingAP. But I am unable to find WiFi Access Point using above code. Please help me. Thank you.

6

Re: How to set custom Access Password? ESP8266

reaz87 wrote:

"#define PIN_BUTTON_RESET_SWTTINGS 3"

Is it GPIO3  pin? means RX pin?

You can replace it with any pin to which you connect the password reset button. You can also not use it at all.

7

Re: How to set custom Access Password? ESP8266

reaz87 wrote:

@ remotexy,
I can connect Wifi Access point using examples-> Setup Connection-> ESP_WiFiSetupUsingAP. But I am unable to find WiFi Access Point using above code. Please help me. Thank you.

The example code I posted allows you to change only the RemoteXY access password. It does not contain Wi-Fi connection settings.