Skip to content

Commit 102b9b4

Browse files
authored
Merge pull request #41 from coelner/master
Add TAM status example
2 parents 9a5ee03 + 2902180 commit 102b9b4

File tree

5 files changed

+190
-12
lines changed

5 files changed

+190
-12
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
Hi and welcome!
11+
Before opening a bug-related issue, please check on the [wiki](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/wiki) if you can resolve the bug yourself. A surprising number of problems ultimately turn out not to be related to this library, in that case it is wasting everyone's time to open an issue here. (This should not keep you from opening one, once you checked all you options in the wiki!)
12+
13+
**Describe the bug**
14+
A clear and concise description of what the bug is.
15+
16+
**Expected/Attempted behavior**
17+
A clear and concise description of what you wanted to achieve/expected to happen.
18+
19+
**To Reproduce**
20+
Shot relevant code segments. Use the (code-formatting markdown)[https://guides.github.com/features/mastering-markdown/] please!
21+
22+
**Logs**
23+
If applicable, add logs to help explain your problem. Use
24+
`<details><summary>(Click to show)</summary>```looooong log```</details>`
25+
to keep it readable.
26+
27+
**µController**
28+
- Which chip and board are you using?
29+
30+
**Router model and firmware version**
31+
- Brand, model and firmware version of the router you are using.
32+
33+
**Related issues**
34+
Please check if you can find any other [issues here](https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues) that might be related to this one.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ git:
1313
quiet: true
1414
env:
1515
global:
16-
- ARDUINO_IDE_VERSION="1.8.11"
16+
- ARDUINO_IDE_VERSION="1.8.13"
1717
- PRETTYNAME="Arduino TR-064 Library"
1818
# Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile"
1919
# - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Arduino-TR-064-SOAP-Library [![Build Status](https://travis-ci.com/Aypac/Arduino-TR-064-SOAP-Library.svg?branch=master)](https://travis-ci.com/Aypac/Arduino-TR-064-SOAP-Library)
2-
Arduino library to facilitate the use of the TR-064 protocol ([definition](https://www.broadband-forum.org/technical/download/TR-064.pdf) and [description](https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_TR-064_first_steps.pdf)), most commonly used by Fritz!Box.
2+
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.
33

44
This library has been developed on an ESP8266 and tested on an ESP32.
55

@@ -8,7 +8,7 @@ To get started, I recommend to check out the [examples folder](https://github.co
88
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.
99

1010
## Installation and usage
11-
Simply go to `ToolsManage Libraries...` in the Arduino IDE and search for `TR-064`. Press install. The examples can then also be found in the IDE under `ExamplesTR-064 SOAP Library`.
11+
Simply go to `ToolsManage Libraries...` in the Arduino IDE and search for `TR-064`. Press install. The examples can then also be found in the IDE under `ExamplesTR-064 SOAP Library`.
1212

1313
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);
1414
<details><summary>Example board URLs</summary>
@@ -31,6 +31,7 @@ If you know more/have tested a device not on the list, please let me know!
3131
<li> Fritz!Box 7490 (tested by Dirk Kaben)</li>
3232
<li> Fritz!Box 7580</li>
3333
<li> Fritz!Box 7590</li>
34+
<li> FRITZ!Box 6590 Cable (tested by <a href='https://github.com/jipp'>Wolfgang (jipp)</a>)</li>
3435
<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>
3536
<li> FRITZ!DECT 200 (tested by Oliver-André Urban)</li>
3637
<li> FRITZ!DECT 210 (test by Thorsten Godau)</li>
@@ -60,21 +61,20 @@ Some of the old issues are:
6061
### Library
6162

6263
* Add yield()'s (where sensible)
63-
* figure out the occasional crashes (might be fixed, but please report if still encountered)
64-
* Make code more efficient
6564
* Do some (better) error-handeling
6665
* Return proper errors
67-
* Add some more comments
68-
* Create a sophisticated debug/verbose mode (and silence the non-debug mode!)
66+
* Reduce occasional crashes (should be fixed, but please report if still encountered)
67+
* Should some of the calls of the examples be included into the library?
6968

7069
### Examples
7170

7271
* Add yield()'s (where sensible)
72+
* Try to find a way to externalize the settings (WIFI etc)
7373
* Add a few more nice examples
7474
* turning on/off (guest) wifi
75-
* read out and display connection speed
75+
* read out connection speed
7676
* alternate WPS button
77-
* Emergency dial-up to relatives or emergency services
77+
* emergency dial-up to relatives or emergency services
7878
* recognize when devices (like washing machines) are done (along the lines of [this](https://github.com/dl9sec/ArduinoSIP/tree/master/examples/LaundryNotifier)
7979
* Start devices through e.g. telegram messages (e.g. coffee machine, washing machine, ...)
8080
* WhoIsHomeIndicator
@@ -83,10 +83,11 @@ Some of the old issues are:
8383
* Extend doorbell example to also send telegram messages :)
8484

8585
<hr />
86-
<center>
87-
<table>
86+
87+
<p align="justify" style="text-align:justify;">
88+
<table style="text-align:center;">
8889
<tr><td>◽</td><td>◾</td><td>◽</td></tr>
8990
<tr><td>◾</td><td>◽</td><td>◽</td></tr>
9091
<tr><td>◾</td><td>◾</td><td>◾</td></tr>
9192
</table>
92-
</center>
93+
</p>
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
M5StickC as simple ON/OFF switch for the TAM
3+
4+
https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf
5+
https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/x_tam.pdf
6+
7+
*/
8+
//#define M5Stick_C //uncomment this line if the board match
9+
#if defined(M5Stick_C)
10+
11+
#include <M5StickC.h>
12+
#include <tr064.h>
13+
14+
15+
const char* WIFI_SSID = "your SSID here";
16+
const char* WIFI_PASS = "the wifi password";
17+
const char* FRITZBOX_AIN = "admin"; //admin if no username is used
18+
const char* FRITZBOX_PASS = "einsElfELF!!11";
19+
const String FRITZBOX_DOMAIN = "fritz.box";
20+
const int PORT = 49000;
21+
const unsigned long UPDATE_INTERVAL = 10000UL; //Check TAM switch every 10 seconds
22+
23+
unsigned long lastConnection = 0;
24+
25+
TR064 connection(PORT, FRITZBOX_DOMAIN, FRITZBOX_AIN, FRITZBOX_PASS);
26+
27+
void setup() {
28+
M5.begin();
29+
pinMode(M5_BUTTON_HOME, INPUT);
30+
31+
Serial.begin( 115200 );
32+
if (Serial) Serial.print("ESP Board MAC Address: ");
33+
if (Serial) Serial.println(WiFi.macAddress());
34+
M5.Lcd.fillScreen(WHITE);
35+
36+
M5.Lcd.setRotation(3);
37+
M5.Lcd.setCursor(2, 10);
38+
M5.Lcd.setTextColor(BLACK);
39+
M5.Lcd.setTextSize(2);
40+
M5.Lcd.print(WiFi.macAddress());
41+
M5.Lcd.setTextSize(12);
42+
43+
if (connectWiFi()) {
44+
if (Serial) Serial.println( "WiFi connection established" );
45+
M5.Lcd.fillScreen(ORANGE);
46+
M5.Lcd.setCursor(15, 15);
47+
M5.Lcd.print("---");
48+
delay(100);
49+
if (Serial) Serial.println("Initialize TR-064 connection");
50+
connection.debug_level = DEBUG_WARNING; //DEBUG_VERBOSE; //0: None, 1: Errors, 2: Warning, 3: Info, 4: Verbose
51+
connection.init();
52+
}
53+
}
54+
55+
void loop() {
56+
M5.update();
57+
yield();
58+
connectWiFi();
59+
unsigned long int now = millis();
60+
if ( (now - lastConnection) > UPDATE_INTERVAL ) {
61+
if (Serial) Serial.print("Routine TAM check: ");
62+
if (Serial) Serial.println(refreshScreen(getABStatus() == 1) ? "ON" : "OFF");
63+
lastConnection = millis();
64+
}
65+
if (M5.BtnA.wasPressed()) {
66+
ButtonACallback();
67+
}
68+
}
69+
70+
71+
bool connectWiFi() {
72+
if ( WiFi.status() == WL_CONNECTED ) {
73+
return true;
74+
}
75+
else {
76+
WiFi.mode( WIFI_STA );
77+
WiFi.begin( WIFI_SSID, WIFI_PASS );
78+
79+
if ( WiFi.waitForConnectResult() != WL_CONNECTED ) {
80+
if (Serial) Serial.println( "WiFi connection failed" );
81+
M5.Lcd.fillScreen(ORANGE);
82+
M5.Lcd.setTextColor(WHITE);
83+
M5.Lcd.setCursor(15, 15);
84+
M5.Lcd.print("ERR");
85+
return false;
86+
}
87+
return true;
88+
}
89+
}
90+
91+
int getABStatus() {
92+
String params[][2] = {"NewIndex", "0"};
93+
int a = 1;
94+
String req[][2] = {"NewEnable", "0"};
95+
int b = 1;
96+
connection.action("urn:dslforum-org:service:X_AVM-DE_TAM:1", "GetInfo", params, a, req, b);
97+
return req[0][1].toInt();
98+
}
99+
100+
bool switchABStatus() {
101+
int currentValue = getABStatus();
102+
int newValue = (currentValue == 1) ? 0 : 1;
103+
String params[][2] = {{"NewIndex", "0"}, {"NewEnable", String(newValue)}};
104+
int a = 2;
105+
connection.action("urn:dslforum-org:service:X_AVM-DE_TAM:1", "SetEnable", params, a);
106+
return (getABStatus() == newValue) ? true : false;
107+
}
108+
109+
void ButtonACallback() {
110+
if (Serial) Serial.print("Switch TAM Status: ");
111+
if (Serial) Serial.println((switchABStatus()) ? "success" : "fail");
112+
refreshScreen(getABStatus());
113+
return;
114+
}
115+
116+
int refreshScreen(int value) {
117+
if (value == 1) {
118+
M5.Lcd.setTextColor(BLACK);
119+
M5.Lcd.fillScreen(TFT_DARKGREEN);
120+
M5.Lcd.setCursor(15, 15);
121+
M5.Lcd.print("ON");
122+
}
123+
else {
124+
M5.Lcd.setTextColor(WHITE);
125+
M5.Lcd.fillScreen(TFT_RED);
126+
M5.Lcd.setCursor(15, 15);
127+
M5.Lcd.print("OFF");
128+
}
129+
return value;
130+
}
131+
132+
#else
133+
void setup() {
134+
135+
}
136+
void loop() {
137+
yield();
138+
}
139+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Further information on the usage of M5StickC-fritzbox-TAM.ino
2+
3+
Yes, out of the box it just runs on a M5StickC. Yes, you can adopt it easily but you need to integrate a display/LED and button. Furthermore it is based on a ESP32-PICO.
4+
The idea behind this was the challenge for elderly people to recognize easily the status of the TAM. However the fritz!fon buttons are small and the menu too complex. Therefore some Gigasets E290HX were used, because the HD feature is pretty good for those people, the buttons are big and it has an loudness amplifier. But there is no TAM station like the E290A, this would be ideal.

0 commit comments

Comments
 (0)