Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usable with Arduino uno/nano #35

Open
Waschtli opened this issue Oct 18, 2020 · 9 comments
Open

usable with Arduino uno/nano #35

Waschtli opened this issue Oct 18, 2020 · 9 comments

Comments

@Waschtli
Copy link

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
Copy link
Owner

Aypac commented Oct 20, 2020

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
Copy link
Author

Waschtli commented Oct 21, 2020 via email

@Aypac
Copy link
Owner

Aypac commented Oct 21, 2020

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
Copy link
Author

Waschtli commented Oct 22, 2020 via email

@Aypac
Copy link
Owner

Aypac commented Oct 22, 2020

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
Copy link
Owner

Aypac commented Oct 22, 2020

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
Copy link
Owner

Aypac commented Jan 17, 2021

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

@Aypac
Copy link
Owner

Aypac commented May 29, 2021

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

@Aypac
Copy link
Owner

Aypac commented Jul 27, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants