Files
Arduino-GSM-Chata/src/main.cpp
T
Ondrej Trochta 0caeec996e test chata
2024-09-26 20:58:31 +02:00

62 lines
1.7 KiB
C++

#include "GSMMobileDevice.h"
//#include "WebServer.h"
#include "PinTypeIn.h"
#include "PinTypeOut.h"
#include <Arduino.h>
//#include <IPAddress.h>
// #include <Ethernet.h>
// #include "WebServer.h"
// #include "WebServerData.h"
//#include "HTMLGenerator.h"
#include "avr8-stub.h"
//#define DEBUG
// PIN INPUT Initialization as OUTPUT
static const int COUNT_OUTPUTS_PIN_OUT = 2;
static PinTypeOut PinOutAlarm8 = PinTypeOut("PIN8", 8, "Electric Alarm");
static PinTypeOut PinOutCase7 = PinTypeOut("PIN7", 7, "Default Description");
static const PinTypeOut OUPUTS_PINS_ARRAY[COUNT_OUTPUTS_PIN_OUT] = {PinOutAlarm8, PinOutCase7};
// PIN INPUT Initialization as INPUT
static const int COUNT_INPUTS_PIN_IN = 2;
static PinTypeIn PinInEZSAlarm2 = PinTypeIn("PIN4", 4, 100, "Input EZS ALARM"); // 100ms debounce;
static PinTypeIn PinInCaseOpen3 = PinTypeIn("PIN3", 3, 100, "Input Contact Box");
static const PinTypeIn INPUTS_PINS_ARRAY[COUNT_INPUTS_PIN_IN] = {PinInEZSAlarm2, PinInCaseOpen3};
// // GSM Serial Port
//https://arduino.stackexchange.com/questions/44599/sim900a-mini-modem-imei-0-help-with-tx-rx-pins
static const uint8_t GSM_PIN_RX = 5;
static const uint8_t GSM_PIN_TX = 6;
static const long GSM_BAUD_RATE = 115200;
GSMMobileDevice gsmDevice = GSMMobileDevice(GSM_PIN_RX, GSM_PIN_TX, GSM_BAUD_RATE);
// // Pin Input
GSMMobileData gsmData = GSMMobileData("GSM");
void setup()
{
debug_init();
gsmData.MobileNumber = "+420608126674";
gsmData.Sms = "Alarm EZS CHATA";
}
void loop()
{
;
if (PinInEZSAlarm2.IsPinHigh())
{
PinOutAlarm8.setOutputSignalToHigh();
gsmDevice.sendSMS(gsmData);
}
else
{
PinOutAlarm8.setOutputSignalToLow();
}
delay(1000);
}