Interrupts Question

Hardware: Photon running 2.1.0
Objective: 3 inputs (D5,D6,D7) pulled down with 10k resistors and pulled up with dry contact closure of sensors.

The actions when inputs are detected needs to be different http.get (Triggering Synology API and Shelly modules)

Presently it compiles and flashes fine but seems to crash or flash the red SOS and then flash red 5 times upon input trigger.

The code is ugly and I am totally seeking better ways to accomplish the task. I did not see examples of having multiple different http.get requests so I assumed breaking them up by request1a, request1b would potentially work. Any suggestions would be appreciated.

// This #include statement was automatically added by the Particle IDE.
#include <HttpClient.h>
#include "application.h"
#include "Particle.h"


HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
//  { "Content-Type", "application/json" },
//  { "Accept" , "application/json" },
{ "Accept" , "*/*"},
{ NULL, NULL } // NOTE: Always terminate headers will NULL
};



http_request_t request1a;
http_request_t request1b;
http_request_t request2a;
http_request_t request2b;
http_request_t request3a;
http_request_t request3b;
http_request_t request4a;
http_request_t request4b;


http_response_t response;




void setup() {


   pinMode(D5, INPUT);
   attachInterrupt(D5, drivewayBeam, RISING, 10); // Highest priority interrupt
   
   pinMode(D6, INPUT);
   attachInterrupt(D6, gateBeam, RISING, 11); 
   
   pinMode(D7, INPUT);
   attachInterrupt(D7, housetoshopBeam, RISING, 12);
   
   pinMode(D4, INPUT);
   attachInterrupt(D4, auxTrigger1, RISING, 13); // Lowest priority interrupt

    

   // Shelly Control
   request1a.hostname = "192.168.1.70";
   request1a.port = 80;
   request1a.path = "/relay/0?turn=on&timer=10";
   
   // URL & authentication to connect to Synology Surveillance Station API & trigger event
   request1b.hostname = "192.168.1.45";
   request1b.port = 5000;
   request1b.path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=%22Trigger%22&version=1&eventId=1&eventName=%22Gate1%22&account=%22externaldev01%22&password=passwordhere";
   
   
   // Shelly Control
   request2a.hostname = "192.168.1.71";
   request2a.port = 80;
   request2a.path = "/relay/0?turn=on&timer=10";
   
   // URL & authentication to connect to Synology Surveillance Station API & trigger event
   request2b.hostname = "192.168.1.45";
   request2b.port = 5000;
   request2b.path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=%22Trigger%22&version=1&eventId=1&eventName=%22Gate2%22&account=%22externaldev01%22&password=passwordhere";
   
   
   // Shelly Control
   request3a.hostname = "192.168.1.72";
   request3a.port = 80;
   request3a.path = "/relay/0?turn=on&timer=10";
   
      // URL & authentication to connect to Synology Surveillance Station API & trigger event
   request3b.hostname = "192.168.1.45";
   request3b.port = 5000;
   request3b.path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=%22Trigger%22&version=1&eventId=1&eventName=%22Gate3%22&account=%22externaldev01%22&password=passwordhere";
   
   
   // Shelly Control
   request4a.hostname = "192.168.1.73";
   request4a.port = 80;
   request4a.path = "/relay/0?turn=on&timer=10";
   
      // URL & authentication to connect to Synology Surveillance Station API & trigger event
   request4b.hostname = "192.168.1.45";
   request4b.port = 5000;
   request4b.path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=%22Trigger%22&version=1&eventId=1&eventName=%22Gate4%22&account=%22externaldev01%22&password=passwordhere";
   
   
   

}


  
 

         
void loop()
{
  
  
}



void drivewayBeam(){                                
    http.get(request1a, response, headers);
//    http.get(request1b, response, headers);
}

void gateBeam(){                                
    http.get(request2a, response, headers);
//    http.get(request2b, response, headers);
}

void housetoshopBeam(){                                
    http.get(request3a, response, headers);
//    http.get(request3b, response, headers);
}

void auxTrigger1(){                                
    http.get(request4a, response, headers);
//    http.get(request4b, response, headers);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.