2 # modify next two line for your DSP-W215
5 # do not modify after this line if you don't know what you are doing
8 echo -e "\nUsage: $(basename $0) [OPTION]"
10 echo -e "\t--getstate"
12 echo -e "\t--noise SoundType(1-6) Volume(0-100) Duration(??)"
18 echo -n "$data" | openssl dgst "-md5" -hmac "$key" -binary | xxd -ps -u
21 contentType="Content-Type: text/xml; charset=utf-8"
22 soapLogin="SOAPAction: \"http://purenetworks.com/HNAP1/Login\""
26 head="<?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>"
27 end="</soap:Body></soap:Envelope>"
29 message="<Login xmlns=\"http://purenetworks.com/HNAP1/\"><Action>request</Action><Username>admin</Username><LoginPassword></LoginPassword><Captcha/></Login>"
30 loginrequest="$head$message$end"
31 #echo "Login request: $loginrequest"
33 #ret=`curl -s -X POST -H "$contentType" -H "$soapLogin" --data-binary "$loginrequest" http://$IP/HNAP1`
34 ret=`curl -v -X POST -H "$contentType" -H "$soapLogin" --data-binary "$loginrequest" http://$IP/HNAP1`
35 echo -e "Returned value: $ret"
38 opt=`echo -n "$ret" | grep -Po "(?<=<$1>).*(?=</$1>)"`
42 #echo -e "Challenge: "
43 #echo -e `getResult Challenge`
45 challenge=`getResult Challenge`
46 cookie="Cookie: uid=`getResult Cookie`"
47 publickey="`getResult PublicKey`$PIN"
48 privatekey=`hash_hmac "$challenge" "$publickey"`
49 password=`hash_hmac "$challenge" "$privatekey"`
51 auth_str="$timestamp\"http://purenetworks.com/HNAP1/Login\""
52 auth=`hash_hmac "$auth_str" "$privatekey"`
53 hnap_auth="HNAP_AUTH: $auth $timestamp"
55 message="<Login xmlns=\"http://purenetworks.com/HNAP1/\"><Action>login</Action><Username>admin</Username><LoginPassword>$password</LoginPassword><Captcha/></Login>"
57 login="$head$message$end"
58 echo "Login info: $login"
61 #ret=`curl -s -X POST -H "$contentType" -H "$soapLogin" -H "$hnap_auth" -H "$cookie" --data-binary "$login" http://$IP/HNAP1`
62 ret=`curl -v -X POST -H "$contentType" -H "$soapLogin" -H "$hnap_auth" -H "$cookie" --data-binary "$login" http://$IP/HNAP1`
63 echo -e "Returned value: $ret"
65 echo -e "\nUsage: $(basename $0) [OPTION]"
69 #Next 2 rows to modify query
70 method="GetSirenAlarmSettings"
71 message="<$method xmlns=\"http://purenetworks.com/HNAP1/\"><ModuleID>1</ModuleID>><Controller>1</Controller></$method>"
73 #Do not modify after this line
74 soapAction="SOAPAction: \"http://purenetworks.com/HNAP1/$method\""
75 authStr="$timestamp\"http://purenetworks.com/HNAP1/$method\""
76 auth=`hash_hmac "$authStr" "$privatekey"`
77 hnap_auth="HNAP_AUTH: $auth $timestamp"
78 data="$head$message$end"
80 #Get Device state from GetSocketSettings
81 #ret=`curl -s -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`
82 ret=`curl -v -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`
83 echo -e "Timestamp=$timestamp\tSOAPAction=$soapAction\tAuthStr=$authStr\tAUTH=$auth\tHNAP=$hnap_auth\tRET = $ret" #This line is for debug purpose
86 #Next 2 rows to modify query
88 message="<$method xmlns=\"http://purenetworks.com/HNAP1/\"><ModuleID>1</ModuleID><Controller>1</Controller><SoundType>$2</SoundType><Volume>$3</Volume><Duration>$4</Duration></$method>"
90 #Do not modify after this line
91 soapAction="SOAPAction: \"http://purenetworks.com/HNAP1/$method\""
92 authStr="$timestamp\"http://purenetworks.com/HNAP1/$method\""
93 auth=`hash_hmac "$authStr" "$privatekey"`
94 hnap_auth="HNAP_AUTH: $auth $timestamp"
95 data="$head$message$end"
96 echo -e "Sound data: $data"
98 #Get Device state from GetSocketSettings
99 #ret=`curl -s -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`
100 ret=`curl -v -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`
101 echo -e "Return value: $ret"
104 #Next 2 rows to modify query
105 method="SetAlarmDismissed"
106 message="<$method xmlns=\"http://purenetworks.com/HNAP1/\"><ModuleID>1</ModuleID><Controller>1</Controller></$method>"
108 #Do not modify after this line
109 soapAction="SOAPAction: \"http://purenetworks.com/HNAP1/$method\""
110 authStr="$timestamp\"http://purenetworks.com/HNAP1/$method\""
111 auth=`hash_hmac "$authStr" "$privatekey"`
112 hnap_auth="HNAP_AUTH: $auth $timestamp"
113 data="$head$message$end"
114 echo -e "Stop data: $data"
116 #Get Device state from GetSocketSettings
117 #ret=`curl -s -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`
118 ret=`curl -v -X POST -H "$contentType" -H "$soapAction" -H "$hnap_auth" -H "$cookie" --data-binary "$data" http://$IP/HNAP1`