How can I build my own xdrv_xx.ino based on TR064 libary for esp8266

80 views
Skip to first unread message

Jan

unread,
Jan 12, 2020, 3:58:15 PM1/12/20
to TasmotaUsers
Dear Tasmota developer,

I would like to integrate René Vollmer's TR064 library so that I can address my router via TR064. The aim is to control the telephone dialing aid.
The example caller.ino (http://github.com/Aypac) works.

I have adapted an xdrv_98_tr064.ino from it. Unfortunately it does not work. I don't know when to make the TR064 connection (...) call.
The .ino currently looks like this:
/**
 * 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

It would be great if someone with a real idea could take a look at the integration of the tr064 library.
There is also an esp8266 SIP library, but I have the same problem here. When do I start the initialization? Which case will be activated after the wifi setup? In the SIP library, an udp port is also bound for incoming packets, but this seems to be incompatible with Tasmota.

Thank you in advance for your help.

Best wishes
Jan
tr064.cpp
tr064.h
Reply all
Reply to author
Forward
0 new messages