• November 19, 2017, 12:47:14 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

This Forum Beta is ONLY for registered owners of D-Link products in the USA for which we have created boards at this time.

Pages: 1 [2]

Author Topic: DSP-W215 - read values via HNAP protocol  (Read 9659 times)

pzelenka

  • Level 1 Member
  • *
  • Posts: 21
Re: DSP-W215 - read values via HNAP protocol
« Reply #15 on: January 20, 2016, 02:39:47 PM »

It seems ok. What firmware version do you have? Maybe you culd run the script from github and see if it works. You only have to install nodejs.
Logged

zidekmat

  • Level 1 Member
  • *
  • Posts: 1
Re: DSP-W215 - read values via HNAP protocol
« Reply #16 on: January 22, 2016, 04:41:05 PM »

Hi Pavel, curl command is not working for me neither, but it doesn't matter since the Node app is. Awesome work! Thanks a lot.
I have a question thou. How did you figure out /Login endpoint and the mechanism? In CISCO's HNAP whitepaper it says it uses basic auth. If I query DEVICE_IP/HNAP it gives me WSDL without /Login action and I couldn't find it even in mobile app's source code... so that's really mystery for me.
The thing is I have more of D-Link devices like that and I'd like to extend your app for those too and I can't find WSDL describing response formats.
If you don't want to discuss it here, please contact me by email.
Logged

pzelenka

  • Level 1 Member
  • *
  • Posts: 21
Re: DSP-W215 - read values via HNAP protocol
« Reply #17 on: January 23, 2016, 01:27:07 AM »

I tried to put the IP address of the plug into the browser and login page appeared. The login page also contained some Javascripts with the login procedure logic. This was the starting point. I also tried wireshark. But it was quite useless for me because the plug sends data to Amazon WS via HTTS. I reccomend this video https://www.youtube.com/watch?v=rjry28Ym7kI&index=32&list=WL
Logged

Kryptokrates

  • Level 1 Member
  • *
  • Posts: 5
Re: DSP-W215 - read values via HNAP protocol
« Reply #18 on: January 25, 2016, 12:32:09 AM »

You can capture some traffic during the setup-phase. The socket creates an unencrypted network in which you'll see requests/response for Login, Get-/SetDeviceSettings(2) etc. while configuring the device with your Smartphone app.
Logged

pzelenka

  • Level 1 Member
  • *
  • Posts: 21
Re: DSP-W215 - read values via HNAP protocol
« Reply #19 on: January 25, 2016, 01:11:42 AM »

Yes I know however I was able to find out those steps without Wireshark. More interesting would be to find out how to get the data from Amazon WS
Logged

Angakok

  • Level 1 Member
  • *
  • Posts: 5
Re: DSP-W215 - read values via HNAP protocol
« Reply #20 on: January 28, 2016, 07:02:51 AM »

hi pzelenka,

i'm using the same firmware as you.
Originally i've tried to access the plug in python (because i've many pkug to manage and i prefer python to do that) but with the same result (i receive a GetDeviceSetting response) that's why i've tried to come back to basic with curl.
I will try your code soon in order to identify if it's an environnement issue or a coder issue :)

Angakok

Logged

Angakok

  • Level 1 Member
  • *
  • Posts: 5
Re: DSP-W215 - read values via HNAP protocol
« Reply #21 on: February 20, 2016, 12:41:47 AM »

Hi,

it works well with tour code, i think the problem is arround the SOAPAction ... curl expect a word and not a complete URL.

Regards,
Logged

infy

  • Level 1 Member
  • *
  • Posts: 1
Re: DSP-W215 - read values via HNAP protocol
« Reply #22 on: July 17, 2016, 01:38:51 PM »

Hi Pzelenka,
thank you for sharing your js code. I'm interested to manage my plug from http request as have you made. If I use your app.js with node I can turn on the plug with >node app.js on  . If I run >node app.js off plug still on... what's wrong? My firmware is 2.22.
Thank you for any suggestion.

Now I've analyzed your app.js and I understand that execute only information about the plug. Now I've implemented an url request to my service that read the current temperautre in my cellar and swtich the plug on off. Thank you for your code. Great job!

Regards
« Last Edit: July 19, 2016, 12:34:04 PM by infy »
Logged

garce

  • Level 1 Member
  • *
  • Posts: 4
Re: DSP-W215 - read values via HNAP protocol
« Reply #23 on: August 31, 2016, 11:57:10 AM »

Hi, I want to buy the DSP-W215 solely to measure/monitor temperature and have a record over time (as granularly as possible but certainly every 10 minutes at least).
It sounds to me that I would be able to do this from earlier comments. I havent read the instructions in detail. I am planning to leverage a laptop PC that I have running at home to do this. I assume that I need to follow instructions in github.
1. I assume the result is having something like a text file with columns with the raw data?
2. Would there be a column for time and another one for Watts?
Thanks for your help.
Logged

pzelenka

  • Level 1 Member
  • *
  • Posts: 21
Re: DSP-W215 - read values via HNAP protocol
« Reply #24 on: August 31, 2016, 12:05:10 PM »

Hi,
the sample code on github does exactly what you described. It polls data from the plug at specified interval and writes them into text file including the time.  If you want to run the code as background task you can utilize npm module "forever".
Logged

nhsqr

  • Level 1 Member
  • *
  • Posts: 4
Re: DSP-W215 - read values via HNAP protocol
« Reply #25 on: March 02, 2017, 06:16:47 AM »

Hi Pavel,

my request is a POST request but i don't receive a cookie ... the response is a GetDeviceSettingsResponse and not a LoginResponse.
I've probably missed something ...

my request :
 curl --header "Content-Type: text/xml; charset=utf-8" --header "SOAPAction: http://purenetworks.com/HNAP1/Login" --data @auth.xml http://192.168.60.9/HNAP1
With the input message in the auth.xml file.

Regards.

Hello,
If anyone is still interested I figured out what is wrong with the curl request.
First I thought it was something more complex and I wasted a lot of time trying all bunch of stuff.
And finally after a tcpdump of SOAP request of nodejs program I noticed that http://purenetworks.com/HNAP1/Login should be inside quotes. So Simple! :)
So the request should be with escaped quotes like this:
curl --header "Content-Type: text/xml; charset=utf-8" --header "SOAPAction: \"http://purenetworks.com/HNAP1/Login\"" --data @auth.xml http://192.168.60.9/HNAP1
Logged

FurryNutz

  • Poweruser
  •   ▲
    ▲ ▲
  • *****
  • Posts: 43640
  • D-Link Global Forum Moderator
    • New DIR-890L Router with SmartConnect™ Technology
Re: DSP-W215 - read values via HNAP protocol
« Reply #26 on: March 02, 2017, 01:58:36 PM »

Thanks for posting this information. Hope it's helpful for future users.
 ;)
Logged
Cable:100mb/3Mb>Motorola SB6183>COVR3902>HP 24pt Gb Switch. 3xDGL-4500s,DIR-857,835,827,815,890L,880L,868L,865L,836L,810L,685,657,3x655s,645,628,601,DNR-202L,DNS-345,DCS-933L,936L and 960L.
Go Here>Router Troubleshooting

nhsqr

  • Level 1 Member
  • *
  • Posts: 4
Re: DSP-W215 - read values via HNAP protocol
« Reply #27 on: March 04, 2017, 06:10:46 AM »

I am now trying the next step which is to authenticate.
The authentication process uses HMAC-MD5.
Unfortunately I spent several days already trying to use openssl to generate md5 hash for login with no success.
I am using openssl like this:

$PrivateKey=`echo -n "$Challenge" | openssl dgst -md5 -hmac "$PublicKey" -binary | xxd -ps -u`
$Login=`echo -n "$Challenge" | openssl dgst -md5 -hmac "$PrivateKey" -binary | xxd -ps -u`

Where:
$Challenge is the return string from first step and also hex encoded with "xxd -ps -u"
$PublicKey is the return string from first step concatenated with the password and also hex encoded with "xxd -ps -u"

I did a tcpdump from node app.js from bikerp/github and with:
$Challenge="tzd1skQFcoArsdTU7D4I" #not hex encoded
$PublicKey="u2eNyVyvK22JlCTtvA2e" #also not hex encoded
$password="777260" #password for the DSP-W215

echo "$Login" should have given me: 2942D0DF1E77B62BB2DBD4A511C63169
but instead it gives me: 30FD3BDA28A864484AD9AEA3FBDE6811

I can't figure out what is the problem. I tried a lot of different ways and none of them worked.
If anyone has an idea, please let me know

EDIT: Disregard what I wrote :) $PublicKey and $Challenge should not be hax encoded and all is working :)

EDIT 2: I can't believe I figured it out! I'm gonna make bash script for the DSP-W215 API and I'm gonna post it on GitHub :)

EDIT 3: Here is the GitHub link: https://github.com/nhsqr/hnap-dsp-w215
« Last Edit: March 05, 2017, 09:19:33 AM by nhsqr »
Logged

ghainbach

  • Level 1 Member
  • *
  • Posts: 1
Re: DSP-W215 - read values via HNAP protocol
« Reply #28 on: June 06, 2017, 02:25:24 PM »

Downloaded .sh file and changed the IP address and PIN, but getting the following SOAP error:

Grahams-MacBook-Pro:hnap-dsp-w215-master graham$ ./hnap-dsp-w215.sh --getpower
Login:
Timestamp=1496783442   SOAPAction=SOAPAction: "http://purenetworks.com/HNAP1/GetCurrentPowerConsumption"   AuthStr=1496783442"http://purenetworks.com/HNAP1/GetCurrentPowerConsumption"   AUTH=7165F989EAB0348EEBD2BE87EE3A79AC   HNAP=HNAP_AUTH: 7165F989EAB0348EEBD2BE87EE3A79AC 1496783442   RET = <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>401 Unauthorized</faultstring></soap:Fault></soap:Body></soap:Envelope>
Power:  W
Logged

nhsqr

  • Level 1 Member
  • *
  • Posts: 4
Re: DSP-W215 - read values via HNAP protocol
« Reply #29 on: June 09, 2017, 03:28:31 AM »

First sorry for the late reply.

It seems like either you don't have openssl installed or your PIN is wrong or your firmware version is not the latest. Also which hardware version of DSP-W215 do you have?
Logged
Pages: 1 [2]