Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aypac committed Jan 28, 2023
2 parents 4088917 + 930bff0 commit 7469e9e
Show file tree
Hide file tree
Showing 32 changed files with 1,663 additions and 641 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/arduino-test-compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test compile
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples
runs-on: ubuntu-latest
# env:
# PLATFORM_DEFAULT_URL: https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json
# REQUIRED_LIBRARIES: ConfigManager
strategy:
matrix:
arduino-boards-fqbn:
- esp8266:esp8266:generic
- esp8266:esp8266:nodemcu
- esp8266:esp8266:nodemcuv2
- esp8266:esp8266:huzzah
- esp32:esp32:nodemcu-32s
- esp32:esp32:esp32wrover
- esp32:esp32:m5stick-c

include:
- sketches-exclude: Laundry_Notifier
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://dl.espressif.com/dl/package_esp32_index.json
# Laundry_Notifier cannot currently be test-compiled, as it needs additional library (not in Arduino manager)
# - arduino-boards-fqbn: esp32:esp32:m5stick-c
# platform-url: https://dl.espressif.com/dl/package_esp32_index.json
# sketches-include: Telephone_Answering_Machine

fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile all examples using the bash script arduino-test-compile.sh
env:
# Passing parameters to the script by setting the appropriate ENV_* variables.
ENV_ARDUINO_BOARD_FQBN: ${{ matrix.arduino-boards-fqbn }}
ENV_PLATFORM_DEFAULT_URL: ${{ env.PLATFORM_DEFAULT_URL }}
ENV_PLATFORM_URL: ${{ matrix.platform-url }}
ENV_REQUIRED_LIBRARIES: ${{ env.REQUIRED_LIBRARIES }}
ENV_SKETCHES_EXCLUDE: ${{ matrix.sketches-exclude }}
ENV_BUILD_PROPERTIES: ${{ toJson(matrix.build-properties) }}
ENV_SKETCH_NAMES: ${{ matrix.sketch-names }}
# ENV_SKETCH_NAMES_FIND_START: examples/ # Not really required here, but serves as an usage example.
run: |
wget --quiet https://raw.githubusercontent.com/ArminJo/arduino-test-compile/master/arduino-test-compile.sh
chmod +x arduino-test-compile.sh
./arduino-test-compile.sh
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Linting
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: arduino/arduino-lint-action@v1
with:
# Configuration of the checks for libraries in the Arduino Library Manager index.
library-manager: update
# How strict the checks are.
compliance: strict
# The type of project to check.
project-type: library
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ Doxyfile.bak
doxygen_sqlite3.db
html
latex
arduino_secrets.h
.development
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<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 [![Linting](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/actions/workflows/lint.yml/badge.svg)](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/actions/workflows/lint.yml) ![Test compile](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/actions/workflows/arduino-test-compile.yml/badge.svg)
Arduino library to facilitate the use of the TR-064 SOAP protocol. With this you can get a lot of information from and control common routers and their peripherals, like the FRITZ!Box or some ZyXEL.

# 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.
A few examples of what you can do with it include:
- Retrieve devices currently connected to the WIFI or LAN
- Retrieve statistics on internet data usage
- Turn WiFi on or off (e.g. Guest WiFi)
- Make connected DECT phones ring (e.g. as a doorbell replacement)
- Turn on and off connected Telephone answering machines
- Get amount of power passing through connected smart plugs and take decisions on it
- Turn smart plugs on or off
- See more under examples and at the end of this README

This library has been developed on an ESP8266 and tested on an ESP32.
This library has been developed on an ESP8266 and tested on an ESP32 and with various hardware of [AVM FRITZ!OS](https://en.avm.de/).

To get started, I recommend to check out the [examples folder](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/tree/master/examples), the [Wiki](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/wiki) and the [instructable](http://www.instructables.com/id/Who-Is-Home-Indicator-aka-Weasley-Clock-Based-on-T/).

If you still have question please don't hesistate to [open an issue here on Github](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/new). If you made something cool with this library please provide it as an example. Please create a pull request (or, if you don't know how, [an issue](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/new)) to do that.

For details on the TR-064 SOAP 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)).

## Installation and usage
Simply go to `Tools → Manage Libraries...` in the Arduino IDE and search for `TR-064`. Press install. The examples can then also be found in the IDE under `Examples → TR-064 SOAP Library`.
Simply go to `Tools → Manage Libraries...` in the Arduino IDE and search for `TR064`. Press install. The examples can then also be found in the IDE under `Examples → TR064`.

Don't forget that you also need to [add the board you are using to the IDE](https://learn.adafruit.com/add-boards-arduino-v164/setup);
<details><summary>Example board URLs</summary>
Expand All @@ -27,15 +36,16 @@ Don't forget that you also need to [add the board you are using to the IDE](http
If you know more/have tested a device not on the list, please let me know!

<ul>
<li> Almost all Fritz!Box routers.
<li> Almost all FRITZ!Box routers.
<details><summary>Tested devices (click to expand)</summary>
<ul>
<li> Fritz!Box FON WLAN 7360</li>
<li> Fritz!Box 7490 (tested by Dirk Kaben)</li>
<li> Fritz!Box 7580</li>
<li> Fritz!Box 7590</li>
<li> FRITZ!Box 5590</li>
<li> FRITZ!Box FON WLAN 7360</li>
<li> FRITZ!Box 7490 (tested by Dirk Kaben)</li>
<li> FRITZ!Box 7580</li>
<li> FRITZ!Box 7590</li>
<li> FRITZ!Box 6590 Cable (tested by <a href='https://github.com/jipp'>Wolfgang (jipp)</a>)</li>
<li> Fritz!Box 5490 (<a href='https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/21'>not finally confirmed</a>, tested by <a href='https://github.com/Paul760'>Paul760</a>)</li>
<li> FRITZ!Box 5490 (<a href='https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/21'>not finally confirmed</a>, tested by <a href='https://github.com/Paul760'>Paul760</a>)</li>
<li> FRITZ!DECT 200 (tested by Oliver-André Urban)</li>
<li> FRITZ!DECT 210 (test by Thorsten Godau)</li>
</ul>
Expand All @@ -51,12 +61,13 @@ If you know more/have tested a device not on the list, please let me know!
- A similar article was also featured in Reichelt magazine (an electronics vendor) in [English](https://www.reichelt.com/magazin/en/build-smart-doorbell-arduino), [German](https://www.reichelt.de/magazin/how-to/smarte-tuerklingel) and [Dutch](https://www.reichelt.com/magazin/nl/zelf-een-slimme-deurbel-maken).


# TODO
## Contribute

Help is very welcome! For example:
- Check the [issue section on Github](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues) or the list below and see if you can help
- Please let me know if you came up with a cool use-case (I'd love to add more examples, see also list at the end of this file)
- Let me know if you tested it on hardware not listed here (i.e. other microcontroller and other routers)
- If you have any suggestions on how to improve the library code itself (I'm not particularily good with C++). I moved the TODO's mostly into the [issue section on Github](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues), or check out the list below.
- If you have any suggestions on how to improve the library code itself (I'm not particularily good with C++).
- Contributions to the [Wiki](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/wiki) are also very welcome!

Some of the old issues are:
Expand All @@ -65,22 +76,20 @@ Some of the old issues are:

* Add yield()'s (where sensible)
* 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?
* Get the DOXY to work again

### Examples

* Add yield()'s (where sensible)
* Add a few more nice examples (work in progress, see branch 'new_examples')
* turning on/off (guest) wifi
* read out connection speed
* Add a few more nice examples
* alternate WPS button
* emergency dial-up to relatives or emergency services
* recognize when devices (like washing machines) are done (along the lines of [this](https://github.com/dl9sec/ArduinoSIP/tree/master/examples/LaundryNotifier)
* 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
* Extend doorbell example to also send telegram messages :)
* Do something with the FRITZ!DECT Thermostats

<hr />

Expand Down
170 changes: 170 additions & 0 deletions examples/DECT_Caller/DECT_Caller.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/**
* DECT_Caller.ino
* Example code for placing internal DECT phone calls.
*
* Oliver-André Urban
* improved by
* Karsten Sauer (saak2820)
* updated by
* René Vollmer
*
* Please adjust your sensitive data in the file/tab `arduino_secrets.h`
*
* Created on: 07.06.2017
* Latest update: 11.01.2023
*/
#include "arduino_secrets.h"

#include <Arduino.h>
#if defined(ESP8266)
//Imports for ESP8266
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
ESP8266WiFiMulti WiFiMulti;
#elif defined(ESP32)
//Imports for ESP32
#include <WiFi.h>
#include <WiFiMulti.h>
#include <HTTPClient.h>
WiFiMulti WiFiMulti;
#endif

#include <tr064.h>

//-------------------------------------------------------------------------------------
// Hardware settings
//-------------------------------------------------------------------------------------
// BELL_BUTTON - you can connect a separate button to this pin or an opto-coupler
// (depends on the microcontroller and circuit you use)
// for example: use a resistor and an opto-coupler to connect to a doorbell
#define BELL_BUTTON 0

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

// TR-064 connection
TR064 connection(TR_PORT, TR_IP, TR_USER, TR_PASS);

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

//###########################################################################################
//############################ 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(BELL_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();

// Define button port as input
pinMode(BELL_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);

// 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() {
if (digitalRead(BELL_BUTTON) == LOW) {
if (Serial) {
Serial.println();
Serial.printf("Button pressed");
}
callWahlhilfe();
// callDect();
// char* status=getStatus();
delay(20000); // 20s
if(Serial) Serial.println("-------------------------------------------");
} else {
// 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("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("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("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.
*/
void ensureWIFIConnection() {
if ((WiFiMulti.run() != WL_CONNECTED)) {
WiFiMulti.addAP(WIFI_SSID, WIFI_PASS);
while ((WiFiMulti.run() != WL_CONNECTED)) {
delay(100);
}
}
}
File renamed without changes.
Loading

0 comments on commit 7469e9e

Please sign in to comment.