/**
* xdrv_98_tr064.ino
* based on
* caller.ino
* Oliver-André Urban
* based on
* home-indicator.ino
* by René Vollmer
* Example code for the home-indicator-project
*
* created on: 07.06.2017
* latest update: 10.12.2018
*
* many thanks to René for his TR-064 library
*/
#ifdef USE_TR064
#define XDRV_98 98
#include <tr064.h>
TR064 *connection;
// The username and password for the API of your router
// The username if you created and account, "admin" otherwise
// ("Anmeldung aus dem Heimnetz mit Benutzername und Passwort")
const char* fuser = "admin";
const char* fpass = "password";
// IP address of your router. This should be "192.168.178.1" for most FRITZ!Boxes
const char* RouterIP = "192.168.178.1";
// Port of the API of your router. This should be 49000 for all TR-064 devices.
const int RouterPort = 49000;
//TR064 connection(RouterPort, RouterIP, fuser, fpass);
TR064 connection(RouterPort, RouterIP, fuser, fpass);
// -------------------------------------------------------------------------------------
/*
* Commands
*/
#define D_PRFX_TR064 "TR064"
#define D_CMND_TR064_INIT "Init"
#define D_CMND_TR064_DIAL "Dial"
const char kTR064Commands[] PROGMEM = D_PRFX_TR064 "|"
D_CMND_TR064_INIT "|" D_CMND_TR064_DIAL;
void (* const TR064Command[])(void) PROGMEM = {
&CmndTR064Init, &CmndTR064Dial };
void CmndTR064Init(void)
{
// Do not mess with these :)
// TR-064 connection
// add to Rule after WifiConnect
connection.init();
AddLog_P2(LOG_LEVEL_INFO, PSTR("TR064 Verbindung initialisiert zu FritzBox %s:%d"), RouterIP, RouterPort);
ResponseCmndDone();
}
void CmndTR064Dial(void)
{
// Die Telefonnummer **9 ist der Fritzbox-Rundruf.
String params[][2] = {{"NewX_AVM-DE_PhoneNumber", "**9"}};
String req[][2] = {{}};
//String params1[][2] = {{}};
connection.action("urn:dslforum-org:service:X_VoIP:1","X_AVM-DE_DialNumber", params, 1, req, 0);
//Hier können Sie die Zeit, die das Telefon klingelt, in Millisekunden einstellen
//delay(4000);
//connection.action("urn:dslforum-org:service:X_VoIP:1","X_AVM-DE_DialHangup", params1, 1, req, 0);
AddLog_P2(LOG_LEVEL_INFO, PSTR("TR064: Anwahl gestartet"));
ResponseCmndDone();
}
/*
* Interface
*/
bool Xdrv98(uint8_t function)
{
bool result = false;
switch (function)
{
//case FUNC_PRE_INIT:
//yourCodeHere
//break;
//case FUNC_LOOP:
//yourCodeHere
//break;
//case FUNC_INIT:
//TR064Init();
//break;
case FUNC_COMMAND:
result = DecodeCommand(kTR064Commands, TR064Command);
break;
}
return result;
}
#endif //USE_TR064