Aypac / Arduino-TR-064-SOAP-Library

Arduino library for the TR-064 protocol, most commonly used by the Fritz!Box router API
Other
63 stars 21 forks source link

Arduino doesn't call suddenly #42

Closed Jannomag closed 3 years ago

Jannomag commented 3 years ago

Hi, my Wemos D1 mini doesn't make calls anymore for some weeks. I didn't change anything, maybe it's cause by an update for my Fritzbox 7490? It's on 7.21.

Here's my code which worked for 2 years straight:

#include` <Arduino.h>
#include <ESP8266WiFi.h>

#include <ESP8266HTTPClient.h>
#include <tr064.h>

#define USE_SERIAL Serial
#define KLINGEL 0

const char WIFI_SSID[] = "NETWORK";
const char WIFI_PASSWORD[] = "PASSWORD";

const char USER[] = "esp";
const char PASSWORD[] = "PASS";
const char FRITZBOX_IP[] = "192.168.1.1";
const int FRITZBOX_PORT = 49000;

TR064 tr064_connection(FRITZBOX_PORT, FRITZBOX_IP, USER, PASSWORD);

const char DEVICE_NAME[] = "Klingel";

const IPAddress STATIC_IP(192, 168, 1, 230);
const IPAddress GATEWAY(192, 168, 1, 1);
const IPAddress SUBNET(255, 255, 255, 0);
const IPAddress DNS(GATEWAY);

void setup() {
  Serial.begin(115200);
  delay(1000);
  WiFi.hostname(DEVICE_NAME);
  WiFi.config(STATIC_IP, SUBNET, GATEWAY, DNS);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.println("Verbinde...");
    delay(100);
  }
  tr064_connection.init();
  Serial.println("Verbunden!");

  pinMode(KLINGEL, INPUT_PULLUP);
  digitalWrite(KLINGEL, HIGH);

}

void loop() {

  int klingel_stat = 0;
  klingel_stat = digitalRead(KLINGEL);
  if (klingel_stat == LOW) {
    Serial.println();
    Serial.printf("ANRUF!");
    makecall();
  }
}

int makecall() {
  String tr064_service = "urn:dslforum-org:service:X_VoIP:1";
  String call_params[][2] = {{"NewX_AVM-DE_PhoneNumber", "**799"}};
  String req[][2] = {{}};
  String params1[][2] = {{}};
  tr064_connection.action(tr064_service, "X_AVM-DE-DialNumber", call_params, 1, req, 0);
    delay(5000);
  tr064_connection.action(tr064_service, "X_AVM-DE_DialHangup", params1, 1, req, 0);
}

The sketch works. When the input gets triggered by the doorbell, Serial.printf("ANRUF!"); appears on serial monitor, so the function makecall() should be executed as well. The Arduino is also listed in network devices and configured as software phone.

EDIT: Found the issue in makecall(): X_AVM-DE**-**DialNumber has a typo, X_AVM-DE**_**DialNumber is correct. I don't know why this worked over 2 years, the code wasn't changed at all. Now it works