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

TR064 #71

Open rudolf32 opened 4 months ago

rudolf32 commented 4 months ago

Hello

I have used this library last year. This year I tried again, but I get an exception28 that rises, because in the function the variable value has no content, it was not initialized. The stream no gets connected and no content is found.

Are there special versions of IDE and Wifi library I have to use?

Thanks for help.

saak2820 commented 4 months ago

@rudolf32

Please try my develp branch and Report Back.

https://github.com/saak2820/Arduino-TR-064-SOAP-Library

rudolf32 commented 4 months ago

Hello @saak2820

I just tried it, without success:

⸮scandone 17:03:23.582 -> connected with Federation.Home, channel 6 17:03:23.582 -> dhcp client start... 17:03:24.050 -> ............ip:10.4.0.148,mask:255.255.255.0,gw:10.4.0.1 17:03:30.017 -> . 17:03:30.017 -> WiFi connected IP address: 10.4.0.148 17:03:30.017 -> Web Server started at 17:03:29 / 1707671009 17:03:31.143 -> Initialize TR-064 connection 17:03:31.143 -> TR64 started. 17:03:31.143 -> Waiting for Keypress 17:03:33.530 -> pm open,type:2 0 17:03:40.390 -> TR64-Init at 17:03:39 17:03:40.484 -> [TR064][httpRequest] prepare request to URL: http://x.x.x.x:49000/tr64desc.xml 17:03:40.484 -> [HTTP-Client][sendRequest] type: 'GET' redirCount: 0 17:03:43.293 -> [HTTP-Client] connected to x.x.x.x:49000 17:03:43.293 -> [HTTP-Client] sending request header 17:03:43.293 -> ----- 17:03:43.293 -> GET /tr64desc.xml HTTP/1.1 17:03:43.293 -> Host: x.x.x.x:49000 17:03:43.293 -> User-Agent: ESP8266HTTPClient 17:03:43.293 -> Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0 17:03:43.293 -> Connection: keep-alive 17:03:43.293 -> Content-Length: 0 17:03:43.293 -> 17:03:43.293 -> ----- 17:03:43.293 -> [HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK 17:03:43.293 -> [HTTP-Client][handleHeaderResponse] RX: 'Cache-Control: max-age=120 17:03:43.293 -> [HTTP-Client][handleHeaderResponse] RX: 'Connection: Keep-Alive 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Content-Length: 14126 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Content-Type: text/xml 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Date: Sun, 11 Feb 2024 16:03:42 GMT 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'ETag: "2E3D0BBxxxxxxxxxx" 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Expires: Sun, 11 Feb 2024 16:05:42 GMT 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Last-Modified: Thu, 01 Jan 1970 00:01:50 GMT 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Mime-Version: 1.0 17:03:43.338 -> [HTTP-Client][handleHeaderResponse] RX: 'Keep-Alive: timeout=60, max=300 17:03:43.385 -> [HTTP-Client][handleHeaderResponse] RX: ' 17:03:43.385 -> [HTTP-Client][handleHeaderResponse] code: 200 17:03:43.385 -> [HTTP-Client][handleHeaderResponse] size: 14126 17:03:43.385 -> [TR064][httpRequest] GET... 17:03:43.385 -> [TR064][httpRequest] Response code: 200 17:03:43.385 -> [TR064][initServiceURLs] get the Stream 17:03:43.385 -> [TR064][initServiceURLs] 0 readServiceName: @ readServiceUrl: 17:03:43.385 -> [TR064][initServiceURLs] 1 readServiceName: @ readServiceUrl: 17:03:43.385 -> [TR064][initServiceURLs] 2 readServiceName: @ readServiceUrl: ... 17:03:43.938 -> [TR064][initServiceURLs] 98 readServiceName: @ readServiceUrl: 17:03:43.938 -> [TR064][initServiceURLs] 99 readServiceName: @ readServiceUrl: 17:03:43.938 -> [TR064][initServiceURLs] 100 readServiceName: ⸮⸮⸮??
-> from here only rubbish from memory

17:03:43.986 -> [String] ' @ readSer ... viceUrl: ': OOM: 31 -> 59424 bytes 17:03:43.986 -> @ readServiceUrl: 17:03:43.986 -> Fatal exception 28(LoadProhibitedCause): 17:03:43.986 -> epc1=0x4000e140, epc2=0x00000000, epc3=0x00000000, excvaddr=0x06010000, depc=0x00000000

my own trace shows, that:

bool TR064::xmlTakeParam(String& value, const String& needParam) { WiFiClient * stream = &tr064client; stream->Stream::setTimeout(40);

value = ""; would protect from exception

while(stream->connected()) {  -----------------------> it never enters here and returns value without content or memory

stream->connected() is always false.

...

}
return true;

}

Regrads Rudolf

saak2820 commented 4 months ago

Hi @rudolf32

I'll have a look at it tomorrow. Can you make your call without the init method? Example is in the caller.ino

rudolf32 commented 4 months ago

Hello @saak2820

not yet

21:35:06.119 -> Calling 9 to Fritzbox by TR64 at 21:35:05 21:35:06.119 -> [TR064] 21:35:06.119 -> [TR064][action] with parameters 21:35:06.165 -> [TR064][action] with extraction 21:35:06.165 -> [TR064][cleanOldServiceName] searching for prefix in servicename: urn:dslforum-org:service:X_VoIP:1 21:35:06.165 -> [String] ' ... /s:Header>': Reallocating large String(161 -> 306 bytes) 21:35:06.165 -> [String] '<?xml vers ... s:Body><u:': Reallocating large String(317 -> 336 bytes) 21:35:06.165 -> [String] '<?xml vers ... xmlns:u="': Reallocating large String(346 -> 371 bytes) 21:35:06.165 -> [TR064][action_raw] with parameter, NewX_AVM-DE_PhoneNumber 21:35:06.165 -> [TR064][action_raw] with parametervalue, 9 21:35:06.165 -> [String] '<?xml vers ... X_VoIP:1">': Reallocating large String(381 -> 435 bytes) 21:35:06.213 -> [String] '<?xml vers ... oneNumber>': Reallocating large String(435 -> 481 bytes) 21:35:06.213 -> [TR064][findServiceURL] Services NOT Loaded. 21:35:06.213 -> [TR064][httpRequest] URL is empty, abort http request. 21:35:06.213 -> [TR064][action] Request Failed 21:35:06.213 -> [HTTP-Client][end] tcp is closed 21:35:06.213 -> [HTTP-Client][end] tcp is closed

rudolf32 commented 4 months ago

second try like caller.ino

21:42:27.226 -> [TR064][action] with extraction 21:42:27.226 -> [TR064][cleanOldServiceName] searching for prefix in servicename: X_VoIP:1 21:42:27.226 -> [String] ' ... /s:Header>': Reallocating large String(161 -> 306 bytes) 21:42:27.226 -> [String] '<?xml vers ... s:Body><u:': Reallocating large String(317 -> 336 bytes) 21:42:27.226 -> [String] '<?xml vers ... xmlns:u="': Reallocating large String(346 -> 371 bytes) 21:42:27.226 -> [TR064][action_raw] with parameter, NewX_AVM-DE_PhoneNumber 21:42:27.273 -> [TR064][action_raw] with parametervalue, 9 21:42:27.273 -> [String] '<?xml vers ... X_VoIP:1">': Reallocating large String(381 -> 435 bytes) 21:42:27.273 -> [String] '<?xml vers ... oneNumber>': Reallocating large String(435 -> 481 bytes) 21:42:27.273 -> [TR064][findServiceURL] Services NOT Loaded.** 21:42:27.273 -> [TR064][httpRequest] URL is empty, abort http request. 21:42:27.273 -> [TR064][action] Request Failed 21:42:27.273 -> [HTTP-Client][end] tcp is closed

rudolf32 commented 4 months ago

Unfortunately it is looking for the Service String in a not filled array.

THX Rudolf

rudolf32 commented 4 months ago

Hello any new libs to test? If someone is using this lib and it works, please let me know the version of environment to upload and compile. THX

saak2820 commented 2 months ago

HI Rudolf

in your log there is a line with the following content.

[TR064][initServiceURLs] get the Stream

this comes from the original code.

With the code from the develop branch, the following should be there.

[TR064][initServiceURLs] Searching the XML for serviceType

Please try the sources from my develp branch. [https://github.com/saak2820/Arduino-TR-064-SOAP-Library]

to use this library, put the files tr064.cpp and tr064.h in your library folder of your Arduino installation.

....\Arduino\libraries\Arduino-TR-064-SOAP-Library\src