कैसे किया Alexa की शक्तियों का गलत इस्तेमाल ?

 कैसे किया Alexa की शक्तियों का गलत इस्तेमाल ? 





#include <WiFi.h>
#include <SinricPro.h>
#include <SinricProSwitch.h>

#define WIFI_SSID        "WIFI_SSID"
#define WIFI_PASS        "WIFI_PASS"
#define APP_KEY          "APP_KEY"
#define APP_SECRET       "APP_SECRET "
#define SWITCH_ID        "SWITCH_ID"

const int ledPin = 2; // GPIO number where the LED is connected

// Callback function to handle power state changes
bool onPowerState(const String &deviceId, bool state) {
  if (deviceId == SWITCH_ID) {
    digitalWrite(ledPin, state ? HIGH : LOW);
    return true; // Indicate that the state change was handled
  }
  return false; // Indicate that the state change was not handled
}

void setup() {
  Serial.begin(115200);
 
  // Initialize LED pin
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
 
  // Connect to Wi-Fi
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Connected to Wi-Fi");

  // Initialize Sinric Pro
  SinricProSwitch &mySwitch = SinricPro[SWITCH_ID];
  mySwitch.onPowerState(onPowerState);

  SinricPro.begin(APP_KEY, APP_SECRET);
  Serial.println("Sinric Pro initialized");
}

void loop() {
  SinricPro.handle();
}

Comments

Popular Posts