Aypac / Arduino-TR-064-SOAP-Library

Arduino library for the TR-064 protocol, most commonly used by the Fritz!Box router API
Other
63 stars 21 forks source link

How to use other urls? #5

Closed qwe900 closed 4 years ago

qwe900 commented 6 years ago

Hey, how about other urls? i want to use this from php on arduino:

$client = new SoapClient(
    null,
    array(
        'location'   => "http://fritz.box:49000/igdupnp/control/WANCommonIFC1",
        'uri'        => "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
        'noroot'     => True,
        'login'      => $fritz_login_user, 
        'password'   => $fritz_login_passwort 
    )
);

$result = $client->GetAddonInfos(); 

Because this traffic is accurat, I can use this but its not accurat and very slow on changing.

String params[][2] = {{"NewSyncGroupIndex"}};
String req[][2] = {{"Newds_current_bps", ""}, {"Newus_current_bps", ""}, {"Newmax_ds",""}, {"Newmax_us",""}};
connection.action("urn:dslforum-org:service:WANCommonInterfaceConfig:1", "X_AVM-DE_GetOnlineMonitor", params, 1, req, 4);
qwe900 commented 6 years ago

I ended up adding the service url and control manually to the libary, then it works.

tr064.cpp

void TR064::initServiceURLs() {
   String inStr = httpRequest(_detectPage, "", "");
   int CountChar=7; //length of word "service"
   int i = 0;
    while (inStr.indexOf("<service>") > 0 || inStr.indexOf("</service>") > 0) {
       int indexStart=inStr.indexOf("<service>");
       int indexStop= inStr.indexOf("</service>");
       String serviceXML = inStr.substring(indexStart+CountChar+2, indexStop);
       String servicename = xmlTakeParam(serviceXML, "serviceType");
       String controlurl = xmlTakeParam(serviceXML, "controlURL");
       _services[i][0] = servicename;
       _services[i][1] = controlurl;
       ++i;
       USE_SERIAL.printf("Service no %d:\t", i);
       USE_SERIAL.flush();
       USE_SERIAL.println(servicename + " @ " + controlurl);
       inStr = inStr.substring(indexStop+CountChar+3);
    }
      ++i;
           _services[i][0] = "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1";
            _services[i][1] = "/igdupnp/control/WANCommonIFC1";
              USE_SERIAL.printf("Service no %d:\t", i);
       USE_SERIAL.println(_services[i][0] + " @ " + _services[i][1]);

}

and my action

String params[][2] = {{""}};
String req[][2] = {{"NewByteSendRate", ""}, {"NewByteReceiveRate", ""}, {"Newmax_ds",""}, {"Newmax_us",""}};
connection.action("urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1", "GetAddonInfos", params, 1, req, 4);
Aypac commented 6 years ago

Hi @qwe900,

glad to hear you found a solution.

I would however like to fix this problem a bit more permanently - in principle the service should have been detected automatically. I would like to understand why not and fix it if possible. The obvious reason would be, that it does it not show up on the page 'http://fritz.box:49000/tr64desc.xml'. Could you check, if that is the case for you? Where did you find documentation about this service?

qwe900 commented 6 years ago

These function are the old ones, which are still implemented. AVM implemented the new protocoll after 6.50 fritz os http://fritz.box:49000/igddesc.xml http://fritz.box:49000/igdconnSCPD.xml http://fritz.box:49000/igdicfgSCPD.xml http://fritz.box:49000/igddslSCPD.xml