1

Topic: two users

Hi
This is my sketch setting
How do i add the correct command that will work with two users
Thanks for the help




// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RAMPA1"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 8080


// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,4,0,0,0,114,0,11,16,1,
  1,0,16,2,33,33,2,31,226,172,
  134,239,184,143,215,148,215,168,215,158,
  215,148,226,172,134,239,184,143,0,1,
  0,2,37,26,26,2,31,226,172,133,
  239,184,143,215,164,215,170,215,153,215,
  151,215,148,0,1,0,36,37,26,26,
  2,31,215,166,215,153,215,147,215,149,
  215,147,32,226,158,161,239,184,143,0,
  1,0,17,64,31,31,2,31,226,172,
  135,239,184,143,215,148,215,149,215,168,
  215,147,215,148,226,172,135,239,184,143,
  0 };

// 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
  uint8_t button_2; // =1 if button pressed, else =0
  uint8_t button_3; // =1 if button pressed, else =0
  uint8_t button_4; // =1 if button pressed, else =0

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

} RemoteXY;
#pragma pack(pop)

2 (edited by Gunner 2021-07-25 08:24:41)

Re: two users

radaizzhrea wrote:

How do i add the correct command that will work with two users

I don't think you need any special "command" or code... I can use the same project (at least via WiFi) with multiple devices (phones/tablets) simultaneously.

"And voila, which is French for.......'and then I found out.'"

3

Re: two users

When I connect two phones then the operation of the relay stops when I disconnect the other phone everything works great

4

Re: two users

Well... your code posted above (and unformatted - Use the <> button in the post editor) wont do anything with the partial code shown, so not sure how anyone can assist further.

"And voila, which is French for.......'and then I found out.'"

5 (edited by radaizzhrea 2021-08-04 12:13:52)

Re: two users

This is the full sketch

*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_WIFI_SSID "RAMPA3"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 8080


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,4,0,0,0,114,0,13,16,1,
  1,0,16,2,33,33,2,31,226,172,
  134,239,184,143,215,148,215,168,215,158,
  215,148,226,172,134,239,184,143,0,1,
  0,2,37,26,26,2,31,226,172,133,
  239,184,143,215,164,215,170,215,153,215,
  151,215,148,0,1,0,36,37,26,26,
  2,31,215,166,215,153,215,147,215,149,
  215,147,32,226,158,161,239,184,143,0,
  1,0,17,64,31,31,2,31,226,172,
  135,239,184,143,215,148,215,149,215,168,
  215,147,215,148,226,172,135,239,184,143,
  0 };
  
// 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 
  uint8_t button_2; // =1 if button pressed, else =0 
  uint8_t button_3; // =1 if button pressed, else =0 
  uint8_t button_4; // =1 if button pressed, else =0 

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

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_BUTTON_1 D1
#define PIN_BUTTON_2 D6
#define PIN_BUTTON_3 D5
#define PIN_BUTTON_4 D2


void setup() 
{
  RemoteXY_Init (); 
  
  pinMode (PIN_BUTTON_1, OUTPUT);
  pinMode (PIN_BUTTON_2, OUTPUT);
  pinMode (PIN_BUTTON_3, OUTPUT);
  pinMode (PIN_BUTTON_4, OUTPUT);
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
  digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?HIGH:LOW);
  digitalWrite(PIN_BUTTON_2, (RemoteXY.button_2==0)?HIGH:LOW);
  digitalWrite(PIN_BUTTON_3, (RemoteXY.button_3==0)?HIGH:LOW);
  digitalWrite(PIN_BUTTON_4, (RemoteXY.button_4==0)?HIGH:LOW);
  
  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay() 


} 

6 (edited by Gunner 2021-08-05 09:53:33)

Re: two users

OK, I think I see the issue.  Buttons do not appear properly synced across multiple "users/phones".  So since your code is seeing that all buttons are 0 unless pressed, then if a button is pressed on one phone, thus sending a 1 to a pin, it is immediately set back to 0 by the 2nd phone.

If both "users/phones" press the same button then it will work as expected... but that is not an ideal solution smile

So unless the developer can add that button sync into a future version, you can either use switches instead of buttons (they do sync from my experience).

Or if you don't need a response from button release, you can use a button press to toggle a digital pin state.  EG. each button press (from same or 2nd phone) changes the pin state.

void loop() { 
  RemoteXY_Handler ();

  if (RemoteXY.button_1 == 1){ // Only trigger when button pressed
    digitalWrite(PIN_BUTTON_1, !digitalRead(PIN_BUTTON_1));  // Toggle pin state
  }
    if (RemoteXY.button_2 == 1){ // Only trigger when button pressed
    digitalWrite(PIN_BUTTON_2, !digitalRead(PIN_BUTTON_2));  // Toggle pin state
  }
    if (RemoteXY.button_3 == 1){ // Only trigger when button pressed
    digitalWrite(PIN_BUTTON_3, !digitalRead(PIN_BUTTON_3));  // Toggle pin state
  }
    if (RemoteXY.button_4 == 1){ // Only trigger when button pressed
    digitalWrite(PIN_BUTTON_4, !digitalRead(PIN_BUTTON_4));  // Toggle pin state
  }
} 
"And voila, which is French for.......'and then I found out.'"

7

Re: two users

I understood a lot of thanks for the help

8

Re: two users

Yes, this is an unpleasant feature of synchronization, it is better not to use buttons. We need to think about how this can be solved.

9

Re: two users

I checked now does not work well