Skip to content

Commit aa3c527

Browse files
authored
Initial release
1 parent c9ee40e commit aa3c527

File tree

4 files changed

+777
-0
lines changed

4 files changed

+777
-0
lines changed
+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/* ====================================================================
2+
3+
Copyright (c) 2018 Juergen Liegner All rights reserved.
4+
(https://www.mikrocontroller.net/topic/444994)
5+
6+
Copyright (c) 2019 Florian Wernze
7+
(https://wernze-home.net/wordpress/hobbys/arduino-esp8266-tuerklingel/)
8+
9+
Copyright (c) 2019 Thorsten Godau (dl9sec)
10+
(Did some optimizations, extensions and beautification of Florian's code)
11+
12+
13+
Redistribution and use in source and binary forms, with or without
14+
modification, are permitted provided that the following conditions
15+
are met:
16+
17+
1. Redistributions of source code must retain the above copyright
18+
notice, this list of conditions and the following disclaimer.
19+
20+
2. Redistributions in binary form must reproduce the above copyright
21+
notice, this list of conditions and the following disclaimer in
22+
the documentation and/or other materials provided with the
23+
distribution.
24+
25+
3. Neither the name of the author(s) nor the names of any contributors
26+
may be used to endorse or promote products derived from this software
27+
without specific prior written permission.
28+
29+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
30+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
33+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39+
SUCH DAMAGE.
40+
41+
====================================================================*/
42+
43+
#include <ESP8266WiFi.h>
44+
#include <ArduinoSIP.h>
45+
46+
//#define DEBUGLOG
47+
48+
#define LED_ESP12E 2
49+
#define LED_NODEMCU 16
50+
51+
//------------------------------------------------
52+
// Configuration with static IP
53+
//------------------------------------------------
54+
55+
// WiFi parameters
56+
const char* WiFiSSID = "myWiFiSSID"; // WiFi SSID
57+
const char* WiFiPSK = "myWiFiPreSharedKey"; // WiFi WPA2 preshared key
58+
59+
const char *WiFiIP = "192.168.2.69"; // WiFi IP of the ESP
60+
const char *WiFiGW = "192.168.2.1"; // WiFi GW
61+
const char *WiFiNM = "255.255.255.0"; // WiFi NM
62+
const char *WiFiDNS = "192.168.2.1"; // WiFi DNS
63+
64+
65+
// Sip parameters
66+
const char *SipIP = "192.168.2.1"; // IP of the FRITZ!Box
67+
const int SipPORT = 5060; // SIP port of the FRITZ!Box
68+
const char *SipUSER = "Doorbell"; // SIP-Call username at the FRITZ!Box
69+
const char *SipPW = "SIP-Password"; // SIP-Call password at the FRITZ!Box
70+
71+
// Dial parameters
72+
const char *SipDIAL = "**9"; // Dial number
73+
const char *SipTEXT_1 = "Doorbell #1"; // Dial text 1 for doorbell #1
74+
const char *SipTEXT_2 = "Doorbell #2"; // Dial text 2 for doorbell #2
75+
76+
//------------------------------------------------
77+
78+
79+
char acSipIn[2048];
80+
char acSipOut[2048];
81+
82+
Sip aSip(acSipOut, sizeof(acSipOut));
83+
84+
void setup()
85+
{
86+
int i = 0;
87+
88+
IPAddress myIP;
89+
IPAddress myGW;
90+
IPAddress myNM;
91+
IPAddress myDNS;
92+
93+
ESP.wdtDisable();
94+
ESP.wdtEnable(WDTO_8S);
95+
96+
Serial.begin(115200);
97+
Serial.setDebugOutput(false);
98+
delay(10);
99+
100+
pinMode(LED_ESP12E, OUTPUT);
101+
pinMode(LED_NODEMCU, OUTPUT);
102+
103+
pinMode(12, INPUT_PULLUP);
104+
pinMode(13, INPUT_PULLUP);
105+
106+
digitalWrite(LED_ESP12E, 1); // LED off
107+
digitalWrite(LED_NODEMCU, 1); // LED off
108+
109+
Serial.printf("\r\n\r\nConnecting to %s\r\n", WiFiSSID);
110+
111+
WiFi.setAutoConnect (true);
112+
WiFi.setAutoReconnect (true);
113+
WiFi.softAPdisconnect (true);
114+
115+
myIP.fromString(WiFiIP);
116+
myGW.fromString(WiFiGW);
117+
myNM.fromString(WiFiNM);
118+
myDNS.fromString(WiFiDNS);
119+
120+
WiFi.config(myIP, myGW, myNM, myDNS);
121+
122+
if ( String(WiFiSSID) != WiFi.SSID() )
123+
{
124+
Serial.print("Wifi initializing...\r\n");
125+
WiFi.begin(WiFiSSID, WiFiPSK);
126+
}
127+
128+
while ( WiFi.status() != WL_CONNECTED )
129+
{
130+
delay(500);
131+
Serial.print(".");
132+
}
133+
134+
WiFi.persistent(true);
135+
136+
Serial.printf("\r\nWiFi connected to: %s\r\n", WiFi.localIP().toString().c_str());
137+
digitalWrite(LED_ESP12E, 0);
138+
139+
aSip.Init(SipIP, SipPORT, WiFiIP, SipPORT, SipUSER, SipPW, 15);
140+
141+
}
142+
143+
144+
void loop(void)
145+
{
146+
int packetSize;
147+
148+
// SIP processing
149+
aSip.Processing(acSipIn, sizeof(acSipIn));
150+
151+
152+
// Doorbell handling begin ===========================
153+
154+
if ( digitalRead(4) == LOW )
155+
{
156+
aSip.Dial(SipDIAL, SipTEXT_1);
157+
}
158+
159+
if ( digitalRead(5) == LOW )
160+
{
161+
aSip.Dial(SipDIAL, SipTEXT_2);
162+
}
163+
164+
// Doorbell handling end =============================
165+
166+
ESP.wdtFeed(); // Retrigger watchdog
167+
168+
}

library.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=ArduinoSIP
2+
version=0.1.0
3+
author=Thorsten Godau (dl9sec)
4+
license=BSD-3-clause
5+
maintainer=Thorsten Godau <[email protected]>
6+
sentence=Arduino SIP library with UDP communications
7+
paragraph=Original class and methods authored by Juergen Liegner (SIP protocoll not fully implemented)
8+
category=Device Control
9+
url=https://github.com/dl9sec/ArduinoSIP
10+
architectures=*
11+
includes=ArduinoSIP.h

0 commit comments

Comments
 (0)