facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.4k stars 1.82k forks source link

unable to control relay with push button #4263

Open meet-kp opened 1 year ago

meet-kp commented 1 year ago

Creating issues for Relay

Questions regarding how to use Relay and/or GraphQL

We want to keep signal strong in the GitHub issue tracker – to make sure that it remains the best place to track issues that affect the development of Relay.

If you have a question on how to use Relay, please get in touch with community members through one of the channels listed here instead.

Reporting issues with Relay

We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new issue, make sure an issue for your problem doesn't already exist.

The best way to get your bug fixed is to provide a reduced test case. To make reproduction simple for you, and set-up simple for Relay's maintainers, you can use Glitch: https://glitch.com/edit/#!/remix/relay-starter-kit

You can also provide a public repository with a runnable example.

Security bugs

Facebook has a bounty program for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.

meet-kp commented 1 year ago

//global boolean varialable bool relayStatus = false;

if (digitalRead(BUTTON_PIN) == LOW) { // Button is pressed, toggle relay status relayStatus = !relayStatus;

// Send update to server
DynamicJsonDocument doc(1024);
JsonArray array = doc.to<JsonArray>();
array.add("relay_status");
JsonObject param1 = array.createNestedObject();
param1["status"] = relayStatus;
String output;
serializeJson(doc, output);
socketIO.sendEVENT(output);

}

if(now - messageTimestamp > 20000) { messageTimestamp = now; // Send update on relay status to the server DynamicJsonDocument doc(1024); JsonArray array = doc.to(); array.add("relay_status"); JsonObject param1 = array.createNestedObject(); param1["status"] = relayStatus; String output; serializeJson(doc, output); socketIO.sendEVENT(output); }

if (relayStatus) { digitalWrite(RELAY_PIN, HIGH); } else { digitalWrite(RELAY_PIN, LOW); }

levibuzolic commented 1 year ago

This issue doesn't appear to be for the Relay project and instead looks to be working with physical relays.

meet-kp commented 1 year ago

This issue doesn't appear to be for the Relay project and instead looks to be working with physical relays.

i wish to operate the relay when I receive a ping from server {status=1} relay should unlock and update the status in serial monitor as well as the push button should also be able to connect the relay
what cahnges do i make in this code https://github.com/meet-kp/project1/blob/df822c3efe876cc7f723147d609f86ea0fa3ea0b/sketch_mar14b%20button_as_input.ino

levibuzolic commented 1 year ago

Sorry @meet-kp this is not the correct place to be asking about anything to do with Arduino. This repository is not about physical relays or anything to do with Arduino, we will not be able to help you.

Maybe Stack Overflow would be a better place for your question.