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

usable with Arduino uno/nano #35

Open Waschtli opened 3 years ago

Waschtli commented 3 years ago

Hello,

would it be possible to use the library with an Arduino Uno / Nano with a wired connection made by an Ethernet-Shield with either an ENC28J60- or a WIZ5x00-Chip?

Thank's in advance

Waschtl

Aypac commented 3 years ago

Hi Waschtl, in principle, this should not be a problem at all. All it needs is a working LAN connection to the router and to be able to post a few HTTP requests. However, I've never tested it and don't know how compatible the ESP wifi and the LAN shield libraries are. It should not be very hard to change the few lines, were the HTTP requests are triggered to be compatible to the according library. However, as I do not have any of these devices, it is hard for me to test. I would propose you start testing it and when you run into problems, you let me know (here) and I'll try to help you along the way :)

Waschtli commented 3 years ago

Dear Mr. Vollmer,

thank you very much for your response. Similar to yours, the idea of the project is to ring DECT-Phones when the doorbell rings. However, I will try to use WLAN for mobile devices only and it is not always enabled. For infrastructure devices I prefere a hard wired connetion and the doorbell is part of that. An Arduino Nano stacked with an ENC28J60 based shield aready has a working Ethernet connection using a different sketch. Maybe the ENC28J60 shield is not the best choice in terms of memory usage, but I'll see if I can get it working. Another ethernet shield based on WIZ5100 is also available. Following your suggestion. I'll try it with the described hardware and keep you updated on the progress and any setbacks.

With kind regards

Waschtl

Am 20.10.2020 10:47 schrieb René Vollmer:

Hi Waschtl, in principle, this should not be a problem at all. All it needs is a working LAN connection to the router and to be able to post a few HTTP requests. However, I've never tested it and don't know how compatible the ESP wifi and the LAN shield libraries are. It should not be very hard to change the few lines, were the HTTP requests are triggered to be compatible to the according library. However, as I do not have any of these devices, it is hard for me to test. I would propose you start testing it and when you run into problems, you let me know (here) and I'll try to help you along the way :)

-- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [1], or unsubscribe [2].

Links:

[1] https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/35#issuecomment-712695667 [2] https://github.com/notifications/unsubscribe-auth/ARNSUFAL7SGUPIPKKZRORXLSLVFBHANCNFSM4SVNBKYQ

Aypac commented 3 years ago

Hi Waschtli,

cool! LAN is still so much more reliable. Just a pain to add all those cables and the ESPs are so freaking cheap 😋 But there is one thing I don't quite get; don't you have to bring a LAN cable to the outside for this to work? Is that a good idea?

Either way, I would suggest to use this branch (instead of master), as it implements a few improvements, which I want to bring to master soon. I would start by using this example and add another block after line 28, something like:

#elif defined(Uno)
    //Imports for Uno/Nano
    #include <LAN.h>
    #include <HTTPClient.h>
    LAN WiFiMulti;

(pseudo-code)

then remove all the wifi-related stuff (e.g lines 42-53, 71-73, 123-134). Add any other code needed for the LAN shield. Then test if it already runs. Maybe you are lucky. Otherwise you want to look at this file, lines 392 and following. But if you can keep the same HTTPClient (see above), I think it might just work by changing the example.

Excited to hear how it goes! Good luck, René

Waschtli commented 3 years ago

Hi René

Oh, thank you very much. No, I will not put a LAN cable out of the house. You're right, that's not a good idea. There is a junction box in the basement near the router where all intercom cables go. There I will pick up the ringing signal. I'll start with your suggested sketch and see if I can get something working. As far as I understand right now, the TR-064 connection need a login and the password is MD5 encrypted before transmission, right? Would it be possible to insert the hash directly into the code to avoid the MD5 encryption during runtime? I know, a hard coded secret is not the best idea but this is valid for the hash too, isn't it? From previouse examples I learned that the ENC28J60 use many recources of the
ATmega328. So I try to reduce the code requirements.

With kind regards

Waschtl

Am 21.10.2020 10:33 schrieb René Vollmer:

Hi Waschtli,

cool! LAN is still so much more reliable. Just a pain to add all those cables and the ESPs are so freaking cheap 😋 But there is one thing I don't quite get; don't you have to bring a LAN cable to the outside for this to work? Is that a good idea?

Either way, I would suggest to use this branch [1] (instead of master), as it implements a few improvements, which I want to bring to master soon. I would start by using this example [2] and add another block after line 28, something like:

elif defined(Uno)

//Imports for Uno/Nano

include

include

LAN WiFiMulti;

(pseudo-code)

then remove all the wifi-related stuff (e.g lines 42-53, 71-73, 123-134). Add any other code needed for the LAN shield. Then test if it already runs. Maybe you are lucky. Otherwise you want to look at this file [3], lines 392 and following. But if you can keep the same HTTPClient (see above), I think it might just work by changing the example.

Excited to hear how it goes! Good luck, René

-- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [4], or unsubscribe [5].

Links:

[1] https://github.com/Aypac/Arduino-TR-064-SOAP-Library/tree/branch-auto-refresh [2] https://github.com/Aypac/Arduino-TR-064-SOAP-Library/tree/branch-auto-refresh/examples/caller [3] https://github.com/Aypac/Arduino-TR-064-SOAP-Library/blob/branch-auto-refresh/src/tr064.cpp [4] https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/35#issuecomment-713404851 [5] https://github.com/notifications/unsubscribe-auth/ARNSUFDAVVY54SN4SVIJUJLSL2MGTANCNFSM4SVNBKYQ

Aypac commented 3 years ago

I see. How are you planning to pick up the wireless(?) bell signal? So what happens is this: The script

  1. contacts the router and gets some basic information (no authentication) and a so-called nonce ("challenge")
  2. it uses some of this basic static information and your username and password and uses MD5 hashing to create a non-reversible login this only happens once (as long as you keep your µC powered)
  3. It uses this MD5 hash adds the nonce and hashes it again
  4. It sends an actual request with this double-hashed code. In the request, there is the info you wanted (hopefully :P) and a new nonce.
  5. Repeat from 3 for any further requests.

As you can see, there is only one hash you could replace with a pre-hashed code, which is also only run once. So not much to gain there. Also; why would you care? µC are so cheap and basically use no power, so you can dedicate them to a single job that can use up as many resources as it want.

The only advantage I see is that your username and password are not hard-coded into the µC.

If you really wanted to get rid of the MD5 library, you could of course outsource it to an online server. I wrote a small php script for that: this website (just replace the _ in the URL accordingly). If you trust me enough you can use that or write your own. However, then you are dependent on having an active internet connection. Maybe not worth it for something as fundamental as your door-bell...

Aypac commented 3 years ago

If you add plain=1 (so http://aypac.de/tr064_nonce.php?realm=_&uid=_&pw=_&sn=_&plain=1 ), you only get the auth code back.

Aypac commented 3 years ago

Hi Waschtl, how are things going? Made any progress?

Aypac commented 3 years ago

Hi Waschtl, how are things going? Made any progress?

Aypac commented 1 year ago

Hi @Waschtli , how are things going? Made any progress?