vincent wong
Published © GPL3+

DRS For Water Filtration System

I am building a water filter replenishment system using Amazon DRS by monitoring the water usage.

IntermediateFull instructions provided2,212
DRS For Water Filtration System

Things used in this project

Hardware components

Water Flow Sensor Fluid Flowmeter Switch for Water Heater Imprinter
×1
Arduino MKR1000
Arduino MKR1000
×1

Software apps and online services

AWS SNS
Amazon Web Services AWS SNS
Amazon Dash Replenishment Service
Amazon Web Services Amazon Dash Replenishment Service
Microsoft Azure
Microsoft Azure
Arduino IDE
Arduino IDE

Story

Read more

Schematics

schema_waterflow_jpKI0Rzvx1.jpg

Code

index.html

HTML
Device registration
<!doctype html><html class="a-no-js" data-19ax5a9jf="dingo"><head><script>var aPageStart = (new Date()).getTime();</script><meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>
<script type='text/javascript'>
var ue_csm = window,
    ue_hob = +new Date();
(function(d){var e=d.ue=d.ue||{},f=Date.now||function(){return+new Date};e.d=function(b){return f()-(b?0:d.ue_t0)};e.stub=function(b,a){if(!b[a]){var c=[];b[a]=function(){c.push([c.slice.call(arguments),e.d(),d.ue_id])};b[a].replay=function(b){for(var a;a=c.shift();)b(a[0],a[1],a[2])};b[a].isStub=1}};e.exec=function(b,a){return function(){if(1==window.ueinit)try{return b.apply(this,arguments)}catch(c){ueLogError(c,{attribution:a||"undefined",logLevel:"WARN"})}}}})(ue_csm);


    var ue_err_chan = 'jserr-rw';
(function(c,d){function e(f,b){if(!(a.ec>a.mxe)&&f){a.ec++;a.ter.push(f);b=b||{};var c=f.logLevel||b.logLevel;c&&c!=k||a.ecf++;b.pageURL=""+(d.location?d.location.href:"");b.logLevel=c;b.attribution=f.attribution||b.attribution;a.erl.push({ex:f,info:b})}}function h(a,b,d,e,g){c.ueLogError({m:a,f:b,l:d,c:""+e,err:g,fromOnError:1,args:arguments},g?{attribution:g.attribution,logLevel:g.logLevel}:void 0);return!1}var k="FATAL",a={ec:0,ecf:0,pec:0,ts:0,erl:[],ter:[],mxe:50,startTimer:function(){a.ts++;
setInterval(function(){c.ue&&a.pec<a.ec&&c.uex("at");a.pec=a.ec},1E4)}};h.skipTrace=1;e.skipTrace=1;e.isStub=1;c.ueLogError=e;c.ue_err=a;d.onerror=h})(ue_csm,window);


var ue_id = 'KEPNZPAP23MACWK7175G',
    ue_url = '/gp/uedata',
    ue_navtiming = 1,
    ue_mid = 'ATVPDKIKX0DER',
    ue_sid = '161-9726678-7749403',
    ue_sn = 'drs-web.amazon.com',
    ue_furl = 'fls-na.amazon.com',
    ue_fcsn = 1,
    ue_urt = 3,
    ue_rpl_ns = 'cel-rpl',
    ue_fpf = '//fls-na.amazon.com/1/batch/1/OP/ATVPDKIKX0DER:161-9726678-7749403:KEPNZPAP23MACWK7175G$uedata=s:',

    ue_swi = 1;
function ue_viz(){(function(c,e,a){function k(b){if(c.ue.viz.length<p&&!l){var a=b.type;b=b.originalEvent;/^focus./.test(a)&&b&&(b.toElement||b.fromElement||b.relatedTarget)||(a=e[m]||("blur"==a||"focusout"==a?"hidden":"visible"),c.ue.viz.push(a+":"+(+new Date-c.ue.t0)),"visible"==a&&(ue.isl&&uex("at"),l=1))}}for(var l=0,f,g,m,n=["","webkit","o","ms","moz"],d=0,p=20,h=0;h<n.length&&!d;h++)if(a=n[h],f=(a?a+"H":"h")+"idden",d="boolean"==typeof e[f])g=a+"visibilitychange",m=(a?a+"V":"v")+"isibilityState";
k({});d&&e.addEventListener(g,k,0);c.ue&&d&&(c.ue.pageViz={event:g,propHid:f})})(ue_csm,document,window)};

(function(a,g){function v(a){return a&&a.replace&&a.replace(/^\s+|\s+$/g,"")}function p(a){return"undefined"===typeof a}function t(d,c,e,h){var g=h||+new Date,m;a.ueam&&a.ueam(c,d,h);if(c||p(e)){if(d)for(m in h=c?f("t",c)||f("t",c,{}):a.ue.t,h[d]=g,e)e.hasOwnProperty(m)&&f(m,c,e[m]);return g}}function f(d,c,e){var f=a.ue,g=c&&c!=f.id?f.sc[c]:f;g||(g=f.sc[c]={});"id"==d&&e&&(f.cfa2=1);return g[d]=e||g[d]}function w(d,c,e,f,g){e="on"+e;var m=c[e];"function"===typeof m?d&&(a.ue.h[d]=m):m=function(){};
c[e]=g?function(a){f(a);m(a)}:function(a){m(a);f(a)};c[e]&&(c[e].isUeh=1)}function A(d,c,e){function h(c,e){var b=[c],D=0,g={},m,h;e?(b.push("m=1"),g[e]=1):g=a.ue.sc;for(h in g)if(g.hasOwnProperty(h)){var k=f("wb",h),l=f("t",h)||{},q=f("t0",h)||a.ue.t0,n;if(e||2==k){k=k?D++:"";b.push("sc"+k+"="+h);for(n in l)3>=n.length&&!p(l[n])&&null!==l[n]&&b.push(n+k+"="+(l[n]-q));b.push("t"+k+"="+l[d]);if(f("ctb",h)||f("wb",h))m=1}}!x&&m&&b.push("ctb=1");return b.join("&")}function z(c,b,e,d){if(c){var f=a.ue_err,
h;d&&a.ue.log||(h=new Image,a.ue.iel.push(h),h.src=c);E?a.ue_fpf&&g.encodeURIComponent&&c&&(d=new Image,c=""+a.ue_fpf+g.encodeURIComponent(c)+":"+(+new Date-a.ue_t0),a.ue.iel.push(d),d.src=c):a.ue.log&&(h=g.chrome&&"ul"==b,a.ue.log(c,"uedata",a.ue_svi?{n:1,img:!d&&h?1:0}:{n:1}),a.ue.ielf.push(c));f&&!f.ts&&f.startTimer();a.ue.b&&(f=a.ue.b,a.ue.b="",z(f,b,e,1))}}function m(c){if(!ue.collected){var b=c.timing,e=c.navigation,d=ue.t;b&&(d.na_=b.navigationStart,d.ul_=b.unloadEventStart,d._ul=b.unloadEventEnd,
d.rd_=b.redirectStart,d._rd=b.redirectEnd,d.fe_=b.fetchStart,d.lk_=b.domainLookupStart,d._lk=b.domainLookupEnd,d.co_=b.connectStart,d._co=b.connectEnd,d.sc_=b.secureConnectionStart,d.rq_=b.requestStart,d.rs_=b.responseStart,d._rs=b.responseEnd,d.dl_=b.domLoading,d.di_=b.domInteractive,d.de_=b.domContentLoadedEventStart,d._de=b.domContentLoadedEventEnd,d._dc=b.domComplete,d.ld_=b.loadEventStart,d._ld=b.loadEventEnd,b=d.na_,c="function"!==typeof c.now||p(b)?0:new Date(b+c.now())-new Date,d.ntd=c+a.ue.t0);
e&&(d.ty=e.type+a.ue.t0,d.rc=e.redirectCount+a.ue.t0);ue.collected=1}}function s(b){var c=n&&n.navigation?n.navigation.type:y,d=c&&2!=c,e=a.ue.bfini;a.ue.cfa2||(e&&1<e&&(b+="&bfform=1",d||(a.ue.isBFT=e-1)),2==c&&(b+="&bfnt=1",a.ue.isBFT=a.ue.isBFT||1),a.ue.ssw&&a.ue.isBFT&&(p(a.ue.isNRBF)&&(c=a.ue.ssw(a.ue.oid),c.e||p(c.val)||(a.ue.isNRBF=1<c.val?0:1)),p(a.ue.isNRBF)||(b+="&nrbf="+a.ue.isNRBF)),a.ue.isBFT&&!a.ue.isNRBF&&(b+="&bft="+a.ue.isBFT));return b}if(c||p(e)){for(var q in e)e.hasOwnProperty(q)&&
f(q,c,e[q]);t("pc",c,e);q=f("id",c)||a.ue.id;var b=a.ue.url+"?"+d+"&v="+a.ue.v+"&id="+q,x=f("ctb",c)||f("wb",c),n=g.performance||g.webkitPerformance,k,l;x&&(b+="&ctb="+x);1<a.ueinit&&(b+="&ic="+a.ueinit);!a.ue._fi||"at"!=d||c&&c!=q||(b+=a.ue._fi());if(!("ld"!=d&&"ul"!=d||c&&c!=q)){if("ld"==d){try{g.onbeforeunload&&g.onbeforeunload.isUeh&&(g.onbeforeunload=null)}catch(w){}if(g.chrome)for(l=0;l<ue.ulh.length;l++)B("beforeunload",ue.ulh[l]);(l=document.ue_backdetect)&&l.ue_back&&l.ue_back.value++;a._uess&&
(k=a._uess());a.ue.isl=1}ue._bf&&(b+="&bf="+ue._bf());a.ue_navtiming&&n&&n.timing&&(f("ctb",q,"1"),1==a.ue_navtiming&&t("tc",y,y,n.timing.navigationStart));n&&m(n);a.ue.t.hob=a.ue_hob;a.ue.t.hoe=a.ue_hoe;a.ue.ifr&&(b+="&ifr=1")}t(d,c,e);e="ld"==d&&c&&f("wb",c);var u;e||q==a.ue.oid||F((f("t",c)||{}).tc||+f("t0",c),+f("t0",c));a.ue_mbl&&a.ue_mbl.cnt&&!e&&(b+=a.ue_mbl.cnt());e?f("wb",c,2):"ld"==d&&(r.lid=v(q));for(u in a.ue.sc)if(1==f("wb",u))break;if(e){if(a.ue.s)return;b=h(b,null)}else l=h(b,null),
l!=b&&(l=s(l),a.ue.b=l),k&&(b+=k),b=h(b,c||a.ue.id);b=s(b);if(a.ue.b||e)for(u in a.ue.sc)2==f("wb",u)&&delete a.ue.sc[u];k=0;ue._rt&&(b+="&rt="+ue._rt());e||(a.ue.s=0,(k=a.ue_err)&&0<k.ec&&k.pec<k.ec&&(k.pec=k.ec,b+="&ec="+k.ec+"&ecf="+k.ecf),k=f("ctb",c),f("t",c,{}));b&&a.ue.tag&&0<a.ue.tag().length&&(b+="&csmtags="+a.ue.tag().join("|"),a.ue.tag=a.ue.tagC());b&&a.ue.viz&&0<a.ue.viz.length&&(b+="&viz="+a.ue.viz.join("|"),a.ue.viz=[]);b&&!p(a.ue_pty)&&(b+="&pty="+a.ue_pty+"&spty="+a.ue_spty+"&pti="+
a.ue_pti);b&&a.ue.tabid&&(b+="&tid="+a.ue.tabid);b&&a.ue.aftb&&(b+="&aftb=1");b&&a.ue.sbf&&(b+="&sbf=1");!a.ue._ui||c&&c!=q||(b+=a.ue._ui());a.ue.a=b;z(b,d,k,e)}}function s(a,c,e){e=e||g;e.addEventListener?e.addEventListener(a,c,!1):e.attachEvent&&e.attachEvent("on"+a,c)}function B(a,c,e){e=e||g;e.removeEventListener?e.removeEventListener(a,c,!1):e.detachEvent&&e.detachEvent("on"+a,c)}function C(){function d(){a.onUl()}function c(a){return function(){e[a]||(e[a]=1,A(a))}}var e=a.ue.r,f,p;a.onLd=c("ld");
a.onLdEnd=c("ld");a.onUl=c("ul");f={stop:c("os")};g.chrome?(s("beforeunload",d),ue.ulh.push(d)):f[G]=a.onUl;for(p in f)f.hasOwnProperty(p)&&w(0,g,p,f[p]);a.ue_viz&&ue_viz();s("load",a.onLd);t("ue")}function F(d,c){a.ue_mbl&&a.ue_mbl.ajax&&a.ue_mbl.ajax(d,c);a.ue.tag("ajax-transition")}a.ueinit=(a.ueinit||0)+1;var r={t0:g.aPageStart||a.ue_t0,id:a.ue_id,url:a.ue_url,rid:a.ue_id,a:"",b:"",h:{},r:{ld:0,oe:0,ul:0},s:1,t:{},sc:{},iel:[],ielf:[],fc_idx:{},viz:[],v:"0.626.0",d:a.ue&&a.ue.d,log:a.ue&&a.ue.log,
clog:a.ue&&a.ue.clog,onflush:a.ue&&a.ue.onflush,onunload:a.ue&&a.ue.onunload,stub:a.ue&&a.ue.stub,lr:a.ue&&a.ue.lr,exec:a.ue&&a.ue.exec,ulh:[],cfa2:0},E=a.ue_fpf?1:0,G="beforeunload",y;r.oid=v(r.id);r.lid=v(r.id);a.ue=r;a.ue._t0=a.ue.t0;a.ue.tagC=function(){var a={};return function(c){c&&(a[c]=1);c=[];for(var e in a)a.hasOwnProperty(e)&&c.push(e);return c}};a.ue.tag=a.ue.tagC();a.ue.ifr=g.top!==g.self||g.frameElement?1:0;ue.attach=s;ue.detach=B;ue.reset=function(d,c){d&&(a.ue_cel&&a.ue_cel.reset(),
a.ue.t0=+new Date,a.ue.rid=d,a.ue.id=d,a.ue.fc_idx={},a.ue.viz=[])};a.uei=C;a.ueh=w;a.ues=f;a.uet=t;a.uex=A;C()})(ue_csm,window);


ue.stub(ue,"log");ue.stub(ue,"onunload");ue.stub(ue,"onflush");
(function(g){var a=g.ue;a.cv={};a.cv.scopes={};a.count=function(b,e,c){var d={},f=a.cv;d.counter=b;d.value=e;d.t=a.d();c&&c.scope&&(f=a.cv.scopes[c.scope]=a.cv.scopes[c.scope]||{},d.scope=c.scope);if(void 0===e)return f[b];f[b]=e;b=0;c&&c.bf&&(b=1);a.clog&&0===b?a.clog(d,"csmcount",{bf:b}):a.log&&a.log(d,"csmcount",{c:1,bf:b})};a.count("baselineCounter2",1)})(ue_csm);


<!-- 6nwm0qomzrvnagwbwoq1v36957g0f3qukasch1pdmsa4 -->
var ue_hoe = +new Date();
</script><title dir="ltr"></title><link rel="shortcut icon" href="https://www.amazon.com/favicon.ico" />
        <link rel="stylesheet" href="https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AccioCustomerUIAssets-b4ceb2bfc35ef2a7f71ea489c176e9b62bbc6c23._V2_.css#AUIClients/AccioCustomerUIAssets.secure.min" />
<link rel="stylesheet" href="https://images-na.ssl-images-amazon.com/images/I/61yf4UF1RtL._RC|21j4aYuLqTL.css,318Lc7ZjZUL.css,310HgKKWalL.css_.css#AUIClients/AmazonUI.min" />
<script>
(function(d,f,H,r){function u(a,b){m&&m.count&&m.count("aui:"+a,0===b?0:b||(m.count("aui:"+a)||0)+1)}function t(a){try{return a.test(navigator.userAgent)}catch(b){return!1}}function y(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)}function q(a,b,c,g){b=b&&c?b+a+c:b||c;return g?q(a,b,g):b}function z(a,b,c){try{Object.defineProperty(a,b,{value:c,writable:!1})}catch(g){a[b]=c}return c}function I(){return setTimeout(S,0)}function ja(a,b){var c=a.length,g=c,
e=function(){g--||(J.push(b),K||(I(),K=!0))};for(e();c--;)T[a[c]]?e():(v[a[c]]=v[a[c]]||[]).push(e)}function ka(a,b,c,g){var e=f.createElement(a?"script":"link");y(e,"error",g);if(a){e.type="text/javascript";e.async=!0;if(a=c)a=-1!==b.indexOf("images/I")||/AUIClients/.test(b);a&&e.setAttribute("crossorigin","anonymous");e.src=b}else e.rel="stylesheet",e.href=b;f.getElementsByTagName("head")[0].appendChild(e)}function U(a,b){return function(c){function g(){ka(b,c,e,function(b){L?u("resource_unload"):
e?(e=!1,u("resource_retry"),g()):(u("resource_error"),a.log("Asset failed to load: "+c));b&&b.stopPropagation?b.stopPropagation():d.event&&(d.event.cancelBubble=!0)})}if(V[c])return!1;V[c]=!0;u("resource_count");var e=!0;return!g()}}function la(a,b,c){for(var g={name:a,guard:function(c){return b.guardFatal(a,c)},logError:function(c,e,d){b.logError(c,e,d,a)}},e=[],d=0;d<c.length;d++)A.hasOwnProperty(c[d])&&(e[d]=M.hasOwnProperty(c[d])?M[c[d]](A[c[d]],g):A[c[d]]);return e}function w(a,b,c,g,e){return function(k,
f){function l(){var a=null;g?a=f:"function"===typeof f&&(p.start=N(),a=f.apply(d,la(k,h,m)),p.end=N());if(b){A[k]=a;a=k;for(T[a]=!0;(v[a]||[]).length;)v[a].shift()();delete v[a]}p.done=!0}var h=e||this;"function"===typeof k&&(f=k,k=void 0);b&&(k=(k||"__NONAME__").replace(/^prv:/,""),W.hasOwnProperty(k)&&h.error(q(" @ ","Component already registered",k),k),W[k]=!0);for(var m=[],n=0;n<a.length;n++)m[n]=a[n].replace(/^prv:/,"");var p=X[k||"anon"+ ++ma]={depend:m,registered:N(),namespace:h.namespace};
c?l():ja(m,h.guardFatal(k,l));return{decorate:function(a){M[k]=h.guardFatal(k,a)}}}}function Y(a){return function(){return{execute:w(arguments,!1,a,!1,this),register:w(arguments,!0,a,!1,this)}}}function Z(a){return function(b,c){c||(c=b,b=void 0);var d=this.attribution;return function(){B.push({attribution:d,name:b,logLevel:a});var e=c.apply(this,arguments);B.pop();return e}}}function C(a,b){this.load={js:U(this,!0),css:U(this)};z(this,"namespace",b);z(this,"attribution",a)}function aa(){f.body?n.trigger("a-bodyBegin"):
setTimeout(aa,20)}function x(a,b){if(b){for(var c=a.className.split(" "),d=c.length;d--;)if(c[d]===b)return;a.className+=" "+b}}function ba(a,b){for(var c=a.className.split(" "),d=[],e;void 0!==(e=c.pop());)e&&e!==b&&d.push(e);a.className=d.join(" ")}function ca(a){try{return a()}catch(b){return!1}}function D(){if(E){var a=d.innerWidth?{w:d.innerWidth,h:d.innerHeight}:{w:h.clientWidth,h:h.clientHeight},b=!1;5<Math.abs(a.w-O.w)||50<a.h-O.h?(O=a,P=4,(b=l.mobile||l.tablet?a.w>a.h:1250<=a.w)?x(h,"a-ws"):
ba(h,"a-ws")):P--&&(da=setTimeout(D,16))}}function na(a){(E=void 0===a?!E:!!a)&&D()}function oa(){return E}"use strict";r=d.AmazonUIPageJS||d.P;var m=d.ue;m&&m.tag&&(m.tag("aui"),m.tag("aui:aui_build_date:3.16.10.5-2016-11-22"));var F=H.now=H.now||function(){return+new H},N=function(a){return a&&a.now?a.now.bind(a):F}(d.performance),J=[],K=!1,S;S=function(){for(var a=I(),b=F();J.length;)if(J.shift()(),50<F()-b)return;clearTimeout(a);K=!1};t(/OS 6_[0-9]+ like Mac OS X/i)&&y(d,"scroll",I);var T={},
v={},V={},L=!1;y(d,"beforeunload",function(){L=!0;setTimeout(function(){L=!1},1E4)});var W={},A={},M={},X={},ma=0,B=[],ea=d.onerror;d.onerror=function(a,b,c,g,e){e&&"object"===typeof e||(e=Error(a,b,c),e.columnNumber=g,e.stack=b||c||g?q(String.fromCharCode(92),e.message,"at "+q(":",b,c,g)):void 0);var f=B.pop()||{};e.attribution=q(":",e.attribution||f.attribution,f.name);e.logLevel=f.logLevel;e.attribution&&console&&console.log&&console.log([e.logLevel||"ERROR",a,"thrown by",e.attribution].join(" "));
B=[];ea&&(f=[].slice.call(arguments),f[4]=e,ea.apply(d,f))};C.prototype={logError:function(a,b,c,g){b={message:b,logLevel:c||"ERROR",attribution:q(":",this.attribution,g)};if(d.ueLogError)return d.ueLogError(a||b,a?b:null),!0;console&&console.error&&(console.log(b),console.error(a));return!1},error:function(a,b,c,d){a=Error(q(":",d,a,c));a.attribution=q(":",this.attribution,b);throw a;},guardError:Z(),guardFatal:Z("FATAL"),log:function(a,b,c){return this.logError(null,a,b,c)},declare:w([],!0,!0,!0),
register:w([],!0),execute:w([]),AUI_BUILD_DATE:"3.16.10.5-2016-11-22",when:Y(),now:Y(!0),trigger:function(a,b,c){var f=F();this.declare(a,{data:b,pageElapsedTime:f-(d.aPageStart||NaN),triggerTime:f});c&&c.instrument&&fa.when("prv:a-logTrigger").execute(function(b){b(a)})},handleTriggers:function(){this.log("handleTriggers deprecated")},attributeErrors:function(a){return new C(a)},_namespace:function(a,b){return new C(a,b)}};var n=z(d,"AmazonUIPageJS",new C),fa=n._namespace("PageJS","AmazonUI");fa.declare("prv:p-debug",
X);"use strict";n.declare("p-recorder-events",[]);n.declare("p-recorder-stop",function(){});z(d,"P",n);aa();if(f.addEventListener){var ga;f.addEventListener("DOMContentLoaded",ga=function(){n.trigger("a-domready");f.removeEventListener("DOMContentLoaded",ga,!1)},!1)}var h=f.documentElement,Q=function(){var a=["O","ms","Moz","Webkit"],b=f.createElement("div");return{testGradients:function(){b.style.cssText=("background-image:-webkit-gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:"+
a.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);return-1<b.style.backgroundImage.indexOf("gradient")},test:function(c){var d=c.charAt(0).toUpperCase()+c.substr(1);c=(a.join(d+" ")+d+" "+c).split(" ");for(d=c.length;d--;)if(""===b.style[c[d]])return!0;return!1},testTransform3d:function(){var a=!1;d.matchMedia&&(a=d.matchMedia("(-webkit-transform-3d)").matches);return a}}}();r=h.className;var ha=/(^| )a-mobile( |$)/.test(r),ia=/(^| )a-tablet( |$)/.test(r),l={audio:function(){return!!f.createElement("audio").canPlayType},
video:function(){return!!f.createElement("video").canPlayType},canvas:function(){return!!f.createElement("canvas").getContext},svg:function(){return!!f.createElementNS&&!!f.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect},offline:function(){return navigator.hasOwnProperty&&navigator.hasOwnProperty("onLine")&&navigator.onLine},dragDrop:function(){return"draggable"in f.createElement("span")},geolocation:function(){return!!navigator.geolocation},history:function(){return!(!d.history||
!d.history.pushState)},webworker:function(){return!!d.Worker},autofocus:function(){return"autofocus"in f.createElement("input")},inputPlaceholder:function(){return"placeholder"in f.createElement("input")},textareaPlaceholder:function(){return"placeholder"in f.createElement("textarea")},localStorage:function(){return"localStorage"in d&&null!==d.localStorage},orientation:function(){return"orientation"in d},touch:function(){return"ontouchend"in f},gradients:function(){return Q.testGradients()},hires:function(){var a=
d.devicePixelRatio&&1.5<=d.devicePixelRatio||d.matchMedia&&d.matchMedia("(min-resolution:144dpi)").matches;u("hiRes"+(ha?"Mobile":ia?"Tablet":"Desktop"),a?1:0);return a},transform3d:function(){return Q.testTransform3d()},touchScrolling:function(){return t(/Windowshop|android.([3-9]|[L-Z])|OS ([5-9]|[1-9][0-9]+)(_[0-9]{1,2})+ like Mac OS X|Chrome|Silk|Firefox|Trident.+?; Touch/i)},ios:function(){return t(/OS [1-9][0-9]*(_[0-9]*)+ like Mac OS X/i)},android:function(){return t(/android.([1-9]|[L-Z])/i)&&
!t(/trident/i)},mobile:function(){return ha},tablet:function(){return ia}},p;for(p in l)l.hasOwnProperty(p)&&(l[p]=ca(l[p]));for(var R="textShadow textStroke boxShadow borderRadius borderImage opacity transform transition".split(" "),G=0;G<R.length;G++)l[R[G]]=ca(function(){return Q.test(R[G])});var E=!0,da=0,O={w:0,h:0},P=4;D();y(d,"resize",function(){clearTimeout(da);P=4;D()});ba(h,"a-no-js");x(h,"a-js");!t(/OS [1-8](_[0-9]*)+ like Mac OS X/i)||d.navigator.standalone||t(/safari/i)||x(h,"a-ember");
if(l.localStorage)try{x(h,localStorage.getItem("a-skin-font-class"))}catch(pa){}r=[];for(p in l)l.hasOwnProperty(p)&&l[p]&&r.push("a-"+p.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()}));x(h,r.join(" "));h.setAttribute("data-aui-build-date","3.16.10.5-2016-11-22");n.register("p-detect",function(){return{capabilities:l,toggleResponsiveGrid:na,responsiveGridEnabled:oa}});n.declare("a-event-revised-handling",!1)})(window,document,Date);
  (window.AmazonUIPageJS ? AmazonUIPageJS : P).load.js('https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AccioCustomerUIAssets-bbc636f0572471e8eebe82195a4d37e27c2ad39b._V2_.js#AUIClients/AccioCustomerUIAssets.secure.min');
  (window.AmazonUIPageJS ? AmazonUIPageJS : P).load.js('https://images-na.ssl-images-amazon.com/images/I/01KRcg6-T5L._RC|61yGn8SWTgL.js,118juELdZRL.js,51ZWMq2iULL.js,01N6xzIJxbL.js,51K9yT87dJL.js,01rpauTep4L.js,31tLXa0efAL.js,01yqNhFLqeL.js,61vXpM9XUXL.js,018X-PE063L.js,01BBu+b9t0L.js,01eO7OoSd6L.js_.js#AUIClients/AmazonUI.min');
</script>
<script type='text/javascript'>
(function(e,c){function h(b,a){f.push([b,a])}function g(b,a){if(b){var c=e.head||e.getElementsByTagName("head")[0]||e.documentElement,d=e.createElement("script");d.async="async";d.src=b;d.setAttribute("crossorigin","anonymous");a&&a.onerror&&(d.onerror=a.onerror);a&&a.onload&&(d.onload=a.onload);c.insertBefore(d,c.firstChild)}}function k(){ue.uels=g;for(var b=0;b<f.length;b++){var a=f[b];g(a[0],a[1])}ue.deffered=1}var f=[];c.ue&&(ue.uels=h,c.ue.attach&&c.ue.attach("load",k))})(document,window);
(function(a){var b=a.alert;window.alert=function(){a.ueLogError&&a.ueLogError({message:"[CSM] Alert invocation detected with argument: "+arguments[0],logLevel:"WARN"});Function.prototype.apply.apply(b,[a,arguments||[]])}})(window);
(function(k,l,g){function m(a){c||(c=b[a.type].id,"undefined"===typeof a.clientX?(e=a.pageX,f=a.pageY):(e=a.clientX,f=a.clientY),2!=c||h&&(h!=e||n!=f)?(r(),d.isl&&l.setTimeout(function(){p("at",d.id)},0)):(h=e,n=f,c=0))}function r(){for(var a in b)b.hasOwnProperty(a)&&d.detach(a,m,b[a].parent)}function s(){for(var a in b)b.hasOwnProperty(a)&&d.attach(a,m,b[a].parent)}function t(){var a="";!q&&c&&(q=1,a+="&ui="+c);return a}var d=k.ue,p=k.uex,q=0,c=0,h,n,e,f,b={click:{id:1,parent:g},mousemove:{id:2,
parent:g},scroll:{id:3,parent:l},keydown:{id:4,parent:g}};d&&p&&(s(),d._ui=t)})(ue_csm,window,document);



    if (window.ue && window.ue.uels) {
            var cel_widgets = [ { "c":"celwidget" } ];

                ue.uels("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/ClientSideMetricsAUIJavascript-0031b2f2a155b5c13deee8a23805e8758884e579._V2_.js");

    }

(function(k,c){function l(a,b){return a.filter(function(a){return a.initiatorType==b})}function f(a,c){if(b.t[a]){var g=b.t[a]-b._t0,e=c.filter(function(a){return 0!==a.responseEnd&&m(a)<g}),f=l(e,"script"),h=l(e,"link"),k=l(e,"img"),n=e.map(function(a){return a.name.split("/")[2]}).filter(function(a,b,c){return a&&c.lastIndexOf(a)==b}),q=e.filter(function(a){return a.duration<p}),s=g-Math.max.apply(null,e.map(m))<r|0;"af"==a&&(b._afjs=f.length);return a+":"+[e[d],f[d],h[d],k[d],n[d],q[d],s].join("-")}}
function m(a){return a.responseEnd-(b._t0-c.timing.navigationStart)}function n(){var a=c[h]("resource"),d=f("cf",a),g=f("af",a),a=f("ld",a);delete b._rt;b._ld=b.t.ld-b._t0;b._art&&b._art();return[d,g,a].join("_")}var p=20,r=50,d="length",b=k.ue,h="getEntriesByType";b._rre=m;b._rt=c&&c.timing&&c[h]&&n})(ue_csm,window.performance);

(function(l,d){function c(b){b="";var c=a.isBFT?"b":"s",d=""+a.oid,f=""+a.lid,g=d;d!=f&&20==f.length&&(c+="a",g+="-"+f);a.tabid&&(b=a.tabid+"+");b+=c+"-"+g;b!=e&&100>b.length&&(e=b,document.cookie="csm-hit="+b+("|"+ +new Date)+m+"; path=/")}function n(){e=0}function h(b){!0===d[a.pageViz.propHid]?e=0:!1===d[a.pageViz.propHid]&&c({type:"visible"})}var m="; expires="+(new Date(+new Date+6048E5)).toGMTString(),e,a=l.ue||{},k=a.pageViz&&a.pageViz.event&&a.pageViz.propHid;a.attach&&(a.attach("click",c),
a.attach("keyup",c),k||(a.attach("focus",c),a.attach("blur",n)),k&&(a.attach(a.pageViz.event,h,d),h({})));a.aftb=1})(ue_csm,document);


ue_csm.ue.stub(ue,"impression");


(function(h,d,k){function f(a,c,b){a&&a.indexOf&&0===a.indexOf("http")&&0!==a.indexOf("https")&&l(t,c,a,b)}function g(a,c,b){a&&a.indexOf&&m&&(location.href.split("#")[0]!=a&&null!==a&&"undefined"!==typeof a||l(u,c,a,b))}function l(a,c,b,e){n[b]||(e=v&&e?p(e):"N/A",d.ueLogError&&d.ueLogError({message:a+c+" : "+b,logLevel:w,stack:"N/A"},{attribution:e}),n[b]=1,q++)}function e(a,c){if(a&&c)for(var b=0;b<a.length;b++)try{c(a[b])}catch(d){}}function r(){return d.performance&&d.performance.getEntriesByType?
d.performance.getEntriesByType("resource"):[]}function p(a){if(a.id)return"//*[@id='"+a.id+"']";var c;c=1;var b;for(b=a.previousSibling;b;b=b.previousSibling)b.nodeName==a.nodeName&&(c+=1);b=a.nodeName;1!=c&&(b+="["+c+"]");a.parentNode&&(b=p(a.parentNode)+"/"+b);return b}function x(){var a=k.images;a&&a.length&&e(a,function(a){var b=a.getAttribute("src");f(b,"img",a);g(b,"img",a)})}function y(){var a=k.scripts;a&&a.length&&e(a,function(a){var b=a.getAttribute("src");f(b,"script",a);g(b,"script",a)})}
function z(){var a=k.styleSheets;a&&a.length&&e(a,function(a){if(a=a.ownerNode){var b=a.getAttribute("href");f(b,"style",a);g(b,"style",a)}})}function A(){if(B){var a=r();e(a,function(a){f(a.name,a.initiatorType)})}}function C(){m&&e(r(),function(a){g(a.name,a.initiatorType)})}function s(){var a;a=d.location&&d.location.protocol?d.location.protocol:void 0;"https:"==a&&(A(),x(),y(),z(),C(),q<D&&setTimeout(s,E))}var t="[CSM] Insecure content detected ",u="[CSM] Ajax request to same page detected ",
w="WARN",n={},q=0,E=h.ue_nsip||1E3,D=5,B=1==h.ue_urt,m=1==h.ue_suar,v=!0;ue_csm.ue_disableNonSecure||(d.performance&&d.performance.setResourceTimingBufferSize&&d.performance.setResourceTimingBufferSize(300),s())})(ue_csm,window,document);


if(window.ue&&uet) { uet('bb'); }
</script></head><body class="accui teaser domain_prod a-aui_51744-c a-aui_57326-c a-aui_58736-c a-aui_72554-c a-aui_83815-c a-aui_86171-c a-aui_accessibility_49860-c a-aui_attr_validations_1_51371-c a-aui_bolt_62845-c a-aui_decorate_77059-t1 a-aui_noopener_84118-t1 a-aui_ux_56217-c a-aui_ux_59374-c a-aui_ux_60000-c"><div id="a-page"><script type="a-state" data-a-state="{&quot;key&quot;:&quot;a-wlab-states&quot;}">{"AUI_51744":"C","AUI_57326":"C","AUI_58736":"C","AUI_72554":"C","AUI_83815":"C","AUI_86171":"C","AUI_ACCESSIBILITY_49860":"C","AUI_ATTR_VALIDATIONS_1_51371":"C","AUI_BOLT_62845":"C","AUI_DECORATE_77059":"T1","AUI_NOOPENER_84118":"T1","AUI_UX_56217":"C","AUI_UX_59374":"C","AUI_UX_60000":"C"}</script>





<style>
    .brand_space {
       background-color: #b9cf25;
    }
</style>

<div class="a-row">
    <div class="a-column a-span6 amazon_space">
        <div class="a-row logo">
            <div class="a-column a-span12 a-text-left">
                <img alt="Amazon logo" src="https://drs-web.amazon.com/images/amazon_logo.png" width="80" title="Amazon" data-a-hires="https://drs-web.amazon.com/images/amazon_logo_high.png">
            </div>
        </div>

        <div class="a-row teaser_text">
            <div class="a-column a-span12 a-text-left">
                <span>Amazon will automatically ship you new filtration catridges before you run out.</span>
            </div>
        </div>

        <div class="a-row a-grid-vertical-align a-grid-center amazon_text order_text">
            <div class="a-column a-span3 a-text-center">
                <img alt="Order only what you need" src="https://drs-web.amazon.com/images/order_glyph.png" height="59" width="55" title="Order only what you need" data-a-hires="/images/order_glyph_high.png">
            </div>
            <div class="a-column a-span9 a-text-left text a-span-last">
                <span class="title">Order only what you need</span>
                <br>
                <span>Order physical goods from Amazon when supplies are running low.</span>
            </div>
        </div>

        <div class="a-row a-grid-vertical-align a-grid-center amazon_text">
            <div class="a-column a-span3 a-text-center">
                <img alt="" src="https://drs-web.amazon.com/images/secure_glyph.png" height="59" width="55" data-a-hires="https://drs-web.amazon.com/images/secure_glyph_high.png">
            </div>
            <div class="a-column a-span9 a-text-left text a-span-last">
                <span class="title"></span>
                <br>
                <span>Enjoy the speed, safety, and security that comes with refilling your products with Amazon Dash Replenishment Service.</span>
            </div>
        </div>
    </div>

    <div class="a-column a-span6 brand_space a-span-last">
        <div class="a-row teaser_image">
            <div class="a-column a-span12 a-text-center">
                <img alt="" src="images/wfs_teaser.png" data-a-hires="images/wfs_teaser.png">
            </div>
        </div>

        <div class="a-row teaser_footer">
            <div class="a-column a-span12">

                
                    <div class="a-row">
                        <div class="a-column a-span12">
                            <span class="a-button a-button-thumbnail start_button"><span class="a-button-inner"><a href="registration.html" class="a-button-text" role="button">
                                <span class="start_button_text">Get started</span>
                            </a></span></span>
                        </div>
                    </div>
                

                
                    <div class="a-row links">
                        <div class="a-column a-span6 a-text-left">
                            
                                <a class="a-link-normal" href="https://developer.amazon.com">Remind me later</a>
                            
                        </div>

                        <div class="a-column a-span6 a-text-right a-span-last">
                            
                                <a class="a-link-normal" href="https://www.amazon.com">Skip</a>
                            
                        </div>
                    </div>
                

            </div>
        </div>
    </div>
</div>
<div id='be' style="display:none;visibility:hidden;"><form name='ue_backdetect' action="get"><input type="hidden" name='ue_back' value='1' /></form>


    <script type="text/javascript">
var ue_mbl=ue_csm.ue.exec(function(e,a){function k(f){b=f||{};a.AMZNPerformance=b;b.transition=b.transition||{};b.timing=b.timing||{};e.ue.exec(l,"csm-android-check")()&&b.tags instanceof Array&&(f=-1!=b.tags.indexOf("usesAppStartTime")||b.transition.type?!b.transition.type&&-1<b.tags.indexOf("usesAppStartTime")?"warm-start":void 0:"view-transition",f&&(b.transition.type=f));"reload"===d._nt&&e.ue_orct||"intrapage-transition"===d._nt?a.performance&&performance.timing&&performance.timing.navigationStart?
b.timing.transitionStart=a.performance.timing.navigationStart:delete b.timing.transitionStart:"undefined"===typeof d._nt&&a.performance&&performance.timing&&performance.timing.navigationStart&&a.history&&"function"===typeof a.History&&"object"===typeof a.history&&history.length&&1!=history.length&&(b.timing.transitionStart=a.performance.timing.navigationStart);f=b.transition;var c;c=d._nt?d._nt:void 0;f.subType=c;a.ue&&a.ue.tag&&a.ue.tag("has-AMZNPerformance");d.isl&&a.uex&&uex("at","csm-timing");
m()}function n(b){a.ue&&a.ue.count&&a.ue.count("csm-cordova-plugin-failed",1)}function l(){return a.webclient&&"function"===typeof a.webclient.getRealClickTime?a.cordova&&a.cordova.platformId&&"ios"==a.cordova.platformId?!1:!0:!1}function m(){try{P.register("AMZNPerformance",function(){return b})}catch(a){}}function g(){if(!b)return"";ue_mbl.cnt=null;var a=b.transition,c;c=b.timing.transitionStart;c="undefined"!==typeof c&&"undefined"!==typeof h?c-h:void 0;a=["mts",c,"mtt",a.type,"mtst",a.subType,
"mtlt",a.launchType];c="";for(var d=0;d<a.length;d+=2){var e=a[d],g=a[d+1];"undefined"!==typeof g&&(c+="&"+e+"="+g)}return c}function p(a,c){b&&(h=c,b.timing.transitionStart=a,b.transition.type="view-transition",b.transition.subType="ajax-transition",b.transition.launchType="normal",ue_mbl.cnt=g)}var d=e.ue||{},h=e.ue_t0,b;if(a.P&&a.P.when&&a.P.register)return a.P.when("CSMPlugin").execute(function(a){a.buildAMZNPerformance&&a.buildAMZNPerformance({successCallback:k,failCallback:n})}),{cnt:g,ajax:p}},
"mobile-timing")(ue_csm,window);

(function(d){d._uess=function(){var a="";screen&&screen.width&&screen.height&&(a+="&sw="+screen.width+"&sh="+screen.height);var b=function(a){var b=document.documentElement["client"+a];return"CSS1Compat"===document.compatMode&&b||document.body["client"+a]||b},c=b("Width"),b=b("Height");c&&b&&(a+="&vw="+c+"&vh="+b);return a}})(ue_csm);

(function(a){var b=document.ue_backdetect;b&&b.ue_back&&a.ue&&(a.ue.bfini=b.ue_back.value);a.uet&&a.uet("be");a.onLdEnd&&(window.addEventListener?window.addEventListener("load",a.onLdEnd,!1):window.attachEvent&&window.attachEvent("onload",a.onLdEnd));a.ueh&&a.ueh(0,window,"load",a.onLd,1);a.ue&&a.ue.tag&&(a.ue_furl&&a.ue_furl.split?(b=a.ue_furl.split("."))&&b[0]&&a.ue.tag(b[0]):a.ue.tag("nofls"))})(ue_csm);
(function(g,h){function d(a,d){var b={};if(!e||!f)try{var c=h.sessionStorage;c?a&&("undefined"!==typeof d?c.setItem(a,d):b.val=c.getItem(a)):f=1}catch(g){e=1}e&&(b.e=1);return b}var b=g.ue||{},a="",f,e,c,a=d("csmtid");f?a="NA":a.e?a="ET":(a=a.val,a||(a=b.oid||"NI",d("csmtid",a)),c=d(b.oid),c.e||(c.val=c.val||0,d(b.oid,c.val+1)),b.ssw=d);b.tabid=a})(ue_csm,window);


(function(b,c){var a=c.images;a&&a.length&&b.ue.count("totalImages",a.length)})(ue_csm,document);


ue_csm.ue._rtn = 1;
(function(e,f){function h(a){a=a.split("?")[0]||a;a=a.replace("http://","").replace("https://","").replace("resource://","").replace("res://","").replace("undefined://","").replace("chrome://","").replace(/\*/g,"").replace(/!/g,"").replace(/~/g,"");var b=a.split("/");a=a.substr(a.lastIndexOf("/")+1);b.splice(-1);b=b.map(function(a){c[a]||(c[a]=(k++).toString(36));return c[a]});b.push(a);return b.join("!")}function l(){return f.getEntriesByType("resource").filter(function(a){return d._rre(a)<d._ld}).sort(function(a,
b){return a.responseEnd-b.responseEnd}).splice(0,m).map(function(a){var b=[],c;for(c in a)g[c]&&a[c]&&b.push(g[c]+Math.max(a[c]|0,-1).toString(36));b.push("i"+a.initiatorType);(1==d._rtn&&d._afjs>n||2==d._rtn)&&b.push("n"+h(a.name));return b.join("_")}).join("*")}function p(){var a="pm",b;for(b in c)c.hasOwnProperty(b)&&(a+="*"+c[b]+"_"+b);return a}function q(){d.log({k:"rtiming",value:l()+"~"+p()},"csm")}if(f&&f.getEntriesByType&&Array.prototype.map&&Array.prototype.filter&&e.ue&&e.ue.log){var g=
{connectStart:"c",connectEnd:"C",domainLookupStart:"d",domainLookupEnd:"D",duration:"z",fetchStart:"f",redirectStart:"r",redirectEnd:"R",requestStart:"q",responseStart:"s",responseEnd:"S",startTime:"a"},d=e.ue,c={},k=1,n=20,m=200;d&&d._rre&&(d._art=function(){d._ld&&window.setTimeout(q,0)})}})(ue_csm||{},window.performance);


(function(c,d){var b=c.ue,a=d.navigator;b&&b.tag&&a&&(a=a.connection||a.mozConnection||a.webkitConnection)&&a.type&&b.tag("netInfo:"+a.type)})(ue_csm,window);


(function(c,d){function g(a,b){for(var c=[],d=0;d<a.length;d++){var f=a[d],e=b.encode(f);if(f[h]){var k=b.metaSep,f=f[h],l=b.metaPairSep,g=[],m=void 0;for(m in f)f.hasOwnProperty(m)&&g.push(m+"="+f[m]);f=g.join(l);e+=k+f}c.push(e)}return c.join(b.resourceSep)}function n(a){var b=a[h]=a[h]||{};b[t]||(b[t]=c.ue_mid);b[u]||(b[u]=c.ue_sid);b[k]||(b[k]=c.ue_id);b.csm=1;a="//"+c.ue_furl+"/1/"+a[v]+"/1/OP/"+a[w]+"/"+a[x]+"/"+g([a],y);if(p)try{p.call(d[q],a)}catch(e){c.ue.sbf=1,(new Image).src=a}else(new Image).src=
a}function r(){l&&l.isStub&&l.replay(function(a,b,c){a=a[0];b=a[h]=a[h]||{};b[k]=b[k]||c;n(a)});e.impression=n;l=null}if(!(1<c.ueinit)){var h="metadata",x="impressionType",v="foresterChannel",w="programGroup",t="marketplaceId",u="session",k="requestId",q="navigator",e=c.ue||{},p=d[q]&&d[q].sendBeacon,s=function(a,b,c,d){return{encode:d,resourceSep:a,metaSep:b,metaPairSep:c}},y=s("","?","&",function(a){return g(a.impressionData,z)}),z=s("/",":",",",function(a){return a.featureName+":"+g(a.resources,
A)}),A=s(",","@","|",function(a){return a.id}),l=e.impression;(e.impression||n)({programGroup:"csm",impressionType:"action",impressionData:[{featureName:"csm-features",resources:[{id:"impression-tracking"}]}],foresterChannel:"action-impressions"});p?r():(e.attach("load",r),e.attach("beforeunload",r));d.P&&d.P.register&&d.P.register("impression-client",function(){})}})(ue_csm,window);


if (window.ue_wurl) {
(function(b,a,c){function d(){c.glog.flush({mid:a.ue_mid,sid:a.ue_sid,mkt:a.ue_mkt,sn:a.ue_sn,furl:"https://"+a.ue_furl+"/1/batch/1/OE/",async:!0})}if(b.URL&&b.Worker){b=URL.createObjectURL(new Blob(["(",function(a){importScripts(a)}.toString(),")('",a.ue_wurl,"')"],{type:"application/javascript"}));var f=new Worker(b),e=!1;c.glog=function(a,b,d){f.postMessage({m:"log",l:a,n:b,o:d});e||c.log();e=!0};c.glog.flush=function(a){f.postMessage({m:"flush",o:a});e=!1};c.onunload(d);c.onflush(d)}})(window,
ue_csm,ue);

}

var ue_pty = "Teaser";

var ue_spty = "TBD";


</script>

</div>

<noscript>
    <img height="1" width="1" style='display:none;visibility:hidden;' src='//fls-na.amazon.com/1/batch/1/OP/ATVPDKIKX0DER:161-9726678-7749403:KEPNZPAP23MACWK7175G$uedata=s:%2Fgp%2Fuedata%3Fnoscript%26id%3DKEPNZPAP23MACWK7175G:0' alt=""/>
</noscript>
</div></body></html>

registration.html

HTML
Device registration
<!doctype html><html class="a-no-js" data-19ax5a9jf="dingo"><head><script>var aPageStart = (new Date()).getTime();</script><meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>
<script type='text/javascript'>
var ue_csm = window,
    ue_hob = +new Date();
(function(d){var e=d.ue=d.ue||{},f=Date.now||function(){return+new Date};e.d=function(b){return f()-(b?0:d.ue_t0)};e.stub=function(b,a){if(!b[a]){var c=[];b[a]=function(){c.push([c.slice.call(arguments),e.d(),d.ue_id])};b[a].replay=function(b){for(var a;a=c.shift();)b(a[0],a[1],a[2])};b[a].isStub=1}};e.exec=function(b,a){return function(){if(1==window.ueinit)try{return b.apply(this,arguments)}catch(c){ueLogError(c,{attribution:a||"undefined",logLevel:"WARN"})}}}})(ue_csm);


    var ue_err_chan = 'jserr-rw';
(function(c,d){function e(f,b){if(!(a.ec>a.mxe)&&f){a.ec++;a.ter.push(f);b=b||{};var c=f.logLevel||b.logLevel;c&&c!=k||a.ecf++;b.pageURL=""+(d.location?d.location.href:"");b.logLevel=c;b.attribution=f.attribution||b.attribution;a.erl.push({ex:f,info:b})}}function h(a,b,d,e,g){c.ueLogError({m:a,f:b,l:d,c:""+e,err:g,fromOnError:1,args:arguments},g?{attribution:g.attribution,logLevel:g.logLevel}:void 0);return!1}var k="FATAL",a={ec:0,ecf:0,pec:0,ts:0,erl:[],ter:[],mxe:50,startTimer:function(){a.ts++;
setInterval(function(){c.ue&&a.pec<a.ec&&c.uex("at");a.pec=a.ec},1E4)}};h.skipTrace=1;e.skipTrace=1;e.isStub=1;c.ueLogError=e;c.ue_err=a;d.onerror=h})(ue_csm,window);


var ue_id = 'KEPNZPAP23MACWK7175G',
    ue_url = '/gp/uedata',
    ue_navtiming = 1,
    ue_mid = 'ATVPDKIKX0DER',
    ue_sid = '161-9726678-7749403',
    ue_sn = 'drs-web.amazon.com',
    ue_furl = 'fls-na.amazon.com',
    ue_fcsn = 1,
    ue_urt = 3,
    ue_rpl_ns = 'cel-rpl',
    ue_fpf = '//fls-na.amazon.com/1/batch/1/OP/ATVPDKIKX0DER:161-9726678-7749403:KEPNZPAP23MACWK7175G$uedata=s:',

    ue_swi = 1;
function ue_viz(){(function(c,e,a){function k(b){if(c.ue.viz.length<p&&!l){var a=b.type;b=b.originalEvent;/^focus./.test(a)&&b&&(b.toElement||b.fromElement||b.relatedTarget)||(a=e[m]||("blur"==a||"focusout"==a?"hidden":"visible"),c.ue.viz.push(a+":"+(+new Date-c.ue.t0)),"visible"==a&&(ue.isl&&uex("at"),l=1))}}for(var l=0,f,g,m,n=["","webkit","o","ms","moz"],d=0,p=20,h=0;h<n.length&&!d;h++)if(a=n[h],f=(a?a+"H":"h")+"idden",d="boolean"==typeof e[f])g=a+"visibilitychange",m=(a?a+"V":"v")+"isibilityState";
k({});d&&e.addEventListener(g,k,0);c.ue&&d&&(c.ue.pageViz={event:g,propHid:f})})(ue_csm,document,window)};

(function(a,g){function v(a){return a&&a.replace&&a.replace(/^\s+|\s+$/g,"")}function p(a){return"undefined"===typeof a}function t(d,c,e,h){var g=h||+new Date,m;a.ueam&&a.ueam(c,d,h);if(c||p(e)){if(d)for(m in h=c?f("t",c)||f("t",c,{}):a.ue.t,h[d]=g,e)e.hasOwnProperty(m)&&f(m,c,e[m]);return g}}function f(d,c,e){var f=a.ue,g=c&&c!=f.id?f.sc[c]:f;g||(g=f.sc[c]={});"id"==d&&e&&(f.cfa2=1);return g[d]=e||g[d]}function w(d,c,e,f,g){e="on"+e;var m=c[e];"function"===typeof m?d&&(a.ue.h[d]=m):m=function(){};
c[e]=g?function(a){f(a);m(a)}:function(a){m(a);f(a)};c[e]&&(c[e].isUeh=1)}function A(d,c,e){function h(c,e){var b=[c],D=0,g={},m,h;e?(b.push("m=1"),g[e]=1):g=a.ue.sc;for(h in g)if(g.hasOwnProperty(h)){var k=f("wb",h),l=f("t",h)||{},q=f("t0",h)||a.ue.t0,n;if(e||2==k){k=k?D++:"";b.push("sc"+k+"="+h);for(n in l)3>=n.length&&!p(l[n])&&null!==l[n]&&b.push(n+k+"="+(l[n]-q));b.push("t"+k+"="+l[d]);if(f("ctb",h)||f("wb",h))m=1}}!x&&m&&b.push("ctb=1");return b.join("&")}function z(c,b,e,d){if(c){var f=a.ue_err,
h;d&&a.ue.log||(h=new Image,a.ue.iel.push(h),h.src=c);E?a.ue_fpf&&g.encodeURIComponent&&c&&(d=new Image,c=""+a.ue_fpf+g.encodeURIComponent(c)+":"+(+new Date-a.ue_t0),a.ue.iel.push(d),d.src=c):a.ue.log&&(h=g.chrome&&"ul"==b,a.ue.log(c,"uedata",a.ue_svi?{n:1,img:!d&&h?1:0}:{n:1}),a.ue.ielf.push(c));f&&!f.ts&&f.startTimer();a.ue.b&&(f=a.ue.b,a.ue.b="",z(f,b,e,1))}}function m(c){if(!ue.collected){var b=c.timing,e=c.navigation,d=ue.t;b&&(d.na_=b.navigationStart,d.ul_=b.unloadEventStart,d._ul=b.unloadEventEnd,
d.rd_=b.redirectStart,d._rd=b.redirectEnd,d.fe_=b.fetchStart,d.lk_=b.domainLookupStart,d._lk=b.domainLookupEnd,d.co_=b.connectStart,d._co=b.connectEnd,d.sc_=b.secureConnectionStart,d.rq_=b.requestStart,d.rs_=b.responseStart,d._rs=b.responseEnd,d.dl_=b.domLoading,d.di_=b.domInteractive,d.de_=b.domContentLoadedEventStart,d._de=b.domContentLoadedEventEnd,d._dc=b.domComplete,d.ld_=b.loadEventStart,d._ld=b.loadEventEnd,b=d.na_,c="function"!==typeof c.now||p(b)?0:new Date(b+c.now())-new Date,d.ntd=c+a.ue.t0);
e&&(d.ty=e.type+a.ue.t0,d.rc=e.redirectCount+a.ue.t0);ue.collected=1}}function s(b){var c=n&&n.navigation?n.navigation.type:y,d=c&&2!=c,e=a.ue.bfini;a.ue.cfa2||(e&&1<e&&(b+="&bfform=1",d||(a.ue.isBFT=e-1)),2==c&&(b+="&bfnt=1",a.ue.isBFT=a.ue.isBFT||1),a.ue.ssw&&a.ue.isBFT&&(p(a.ue.isNRBF)&&(c=a.ue.ssw(a.ue.oid),c.e||p(c.val)||(a.ue.isNRBF=1<c.val?0:1)),p(a.ue.isNRBF)||(b+="&nrbf="+a.ue.isNRBF)),a.ue.isBFT&&!a.ue.isNRBF&&(b+="&bft="+a.ue.isBFT));return b}if(c||p(e)){for(var q in e)e.hasOwnProperty(q)&&
f(q,c,e[q]);t("pc",c,e);q=f("id",c)||a.ue.id;var b=a.ue.url+"?"+d+"&v="+a.ue.v+"&id="+q,x=f("ctb",c)||f("wb",c),n=g.performance||g.webkitPerformance,k,l;x&&(b+="&ctb="+x);1<a.ueinit&&(b+="&ic="+a.ueinit);!a.ue._fi||"at"!=d||c&&c!=q||(b+=a.ue._fi());if(!("ld"!=d&&"ul"!=d||c&&c!=q)){if("ld"==d){try{g.onbeforeunload&&g.onbeforeunload.isUeh&&(g.onbeforeunload=null)}catch(w){}if(g.chrome)for(l=0;l<ue.ulh.length;l++)B("beforeunload",ue.ulh[l]);(l=document.ue_backdetect)&&l.ue_back&&l.ue_back.value++;a._uess&&
(k=a._uess());a.ue.isl=1}ue._bf&&(b+="&bf="+ue._bf());a.ue_navtiming&&n&&n.timing&&(f("ctb",q,"1"),1==a.ue_navtiming&&t("tc",y,y,n.timing.navigationStart));n&&m(n);a.ue.t.hob=a.ue_hob;a.ue.t.hoe=a.ue_hoe;a.ue.ifr&&(b+="&ifr=1")}t(d,c,e);e="ld"==d&&c&&f("wb",c);var u;e||q==a.ue.oid||F((f("t",c)||{}).tc||+f("t0",c),+f("t0",c));a.ue_mbl&&a.ue_mbl.cnt&&!e&&(b+=a.ue_mbl.cnt());e?f("wb",c,2):"ld"==d&&(r.lid=v(q));for(u in a.ue.sc)if(1==f("wb",u))break;if(e){if(a.ue.s)return;b=h(b,null)}else l=h(b,null),
l!=b&&(l=s(l),a.ue.b=l),k&&(b+=k),b=h(b,c||a.ue.id);b=s(b);if(a.ue.b||e)for(u in a.ue.sc)2==f("wb",u)&&delete a.ue.sc[u];k=0;ue._rt&&(b+="&rt="+ue._rt());e||(a.ue.s=0,(k=a.ue_err)&&0<k.ec&&k.pec<k.ec&&(k.pec=k.ec,b+="&ec="+k.ec+"&ecf="+k.ecf),k=f("ctb",c),f("t",c,{}));b&&a.ue.tag&&0<a.ue.tag().length&&(b+="&csmtags="+a.ue.tag().join("|"),a.ue.tag=a.ue.tagC());b&&a.ue.viz&&0<a.ue.viz.length&&(b+="&viz="+a.ue.viz.join("|"),a.ue.viz=[]);b&&!p(a.ue_pty)&&(b+="&pty="+a.ue_pty+"&spty="+a.ue_spty+"&pti="+
a.ue_pti);b&&a.ue.tabid&&(b+="&tid="+a.ue.tabid);b&&a.ue.aftb&&(b+="&aftb=1");b&&a.ue.sbf&&(b+="&sbf=1");!a.ue._ui||c&&c!=q||(b+=a.ue._ui());a.ue.a=b;z(b,d,k,e)}}function s(a,c,e){e=e||g;e.addEventListener?e.addEventListener(a,c,!1):e.attachEvent&&e.attachEvent("on"+a,c)}function B(a,c,e){e=e||g;e.removeEventListener?e.removeEventListener(a,c,!1):e.detachEvent&&e.detachEvent("on"+a,c)}function C(){function d(){a.onUl()}function c(a){return function(){e[a]||(e[a]=1,A(a))}}var e=a.ue.r,f,p;a.onLd=c("ld");
a.onLdEnd=c("ld");a.onUl=c("ul");f={stop:c("os")};g.chrome?(s("beforeunload",d),ue.ulh.push(d)):f[G]=a.onUl;for(p in f)f.hasOwnProperty(p)&&w(0,g,p,f[p]);a.ue_viz&&ue_viz();s("load",a.onLd);t("ue")}function F(d,c){a.ue_mbl&&a.ue_mbl.ajax&&a.ue_mbl.ajax(d,c);a.ue.tag("ajax-transition")}a.ueinit=(a.ueinit||0)+1;var r={t0:g.aPageStart||a.ue_t0,id:a.ue_id,url:a.ue_url,rid:a.ue_id,a:"",b:"",h:{},r:{ld:0,oe:0,ul:0},s:1,t:{},sc:{},iel:[],ielf:[],fc_idx:{},viz:[],v:"0.626.0",d:a.ue&&a.ue.d,log:a.ue&&a.ue.log,
clog:a.ue&&a.ue.clog,onflush:a.ue&&a.ue.onflush,onunload:a.ue&&a.ue.onunload,stub:a.ue&&a.ue.stub,lr:a.ue&&a.ue.lr,exec:a.ue&&a.ue.exec,ulh:[],cfa2:0},E=a.ue_fpf?1:0,G="beforeunload",y;r.oid=v(r.id);r.lid=v(r.id);a.ue=r;a.ue._t0=a.ue.t0;a.ue.tagC=function(){var a={};return function(c){c&&(a[c]=1);c=[];for(var e in a)a.hasOwnProperty(e)&&c.push(e);return c}};a.ue.tag=a.ue.tagC();a.ue.ifr=g.top!==g.self||g.frameElement?1:0;ue.attach=s;ue.detach=B;ue.reset=function(d,c){d&&(a.ue_cel&&a.ue_cel.reset(),
a.ue.t0=+new Date,a.ue.rid=d,a.ue.id=d,a.ue.fc_idx={},a.ue.viz=[])};a.uei=C;a.ueh=w;a.ues=f;a.uet=t;a.uex=A;C()})(ue_csm,window);


ue.stub(ue,"log");ue.stub(ue,"onunload");ue.stub(ue,"onflush");
(function(g){var a=g.ue;a.cv={};a.cv.scopes={};a.count=function(b,e,c){var d={},f=a.cv;d.counter=b;d.value=e;d.t=a.d();c&&c.scope&&(f=a.cv.scopes[c.scope]=a.cv.scopes[c.scope]||{},d.scope=c.scope);if(void 0===e)return f[b];f[b]=e;b=0;c&&c.bf&&(b=1);a.clog&&0===b?a.clog(d,"csmcount",{bf:b}):a.log&&a.log(d,"csmcount",{c:1,bf:b})};a.count("baselineCounter2",1)})(ue_csm);


<!-- 6nwm0qomzrvnagwbwoq1v36957g0f3qukasch1pdmsa4 -->
var ue_hoe = +new Date();
</script><title dir="ltr"></title><link rel="shortcut icon" href="https://www.amazon.com/favicon.ico" />
        <link rel="stylesheet" href="https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AccioCustomerUIAssets-b4ceb2bfc35ef2a7f71ea489c176e9b62bbc6c23._V2_.css#AUIClients/AccioCustomerUIAssets.secure.min" />
<link rel="stylesheet" href="https://images-na.ssl-images-amazon.com/images/I/61yf4UF1RtL._RC|21j4aYuLqTL.css,318Lc7ZjZUL.css,310HgKKWalL.css_.css#AUIClients/AmazonUI.min" />
<script>
(function(d,f,H,r){function u(a,b){m&&m.count&&m.count("aui:"+a,0===b?0:b||(m.count("aui:"+a)||0)+1)}function t(a){try{return a.test(navigator.userAgent)}catch(b){return!1}}function y(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)}function q(a,b,c,g){b=b&&c?b+a+c:b||c;return g?q(a,b,g):b}function z(a,b,c){try{Object.defineProperty(a,b,{value:c,writable:!1})}catch(g){a[b]=c}return c}function I(){return setTimeout(S,0)}function ja(a,b){var c=a.length,g=c,
e=function(){g--||(J.push(b),K||(I(),K=!0))};for(e();c--;)T[a[c]]?e():(v[a[c]]=v[a[c]]||[]).push(e)}function ka(a,b,c,g){var e=f.createElement(a?"script":"link");y(e,"error",g);if(a){e.type="text/javascript";e.async=!0;if(a=c)a=-1!==b.indexOf("images/I")||/AUIClients/.test(b);a&&e.setAttribute("crossorigin","anonymous");e.src=b}else e.rel="stylesheet",e.href=b;f.getElementsByTagName("head")[0].appendChild(e)}function U(a,b){return function(c){function g(){ka(b,c,e,function(b){L?u("resource_unload"):
e?(e=!1,u("resource_retry"),g()):(u("resource_error"),a.log("Asset failed to load: "+c));b&&b.stopPropagation?b.stopPropagation():d.event&&(d.event.cancelBubble=!0)})}if(V[c])return!1;V[c]=!0;u("resource_count");var e=!0;return!g()}}function la(a,b,c){for(var g={name:a,guard:function(c){return b.guardFatal(a,c)},logError:function(c,e,d){b.logError(c,e,d,a)}},e=[],d=0;d<c.length;d++)A.hasOwnProperty(c[d])&&(e[d]=M.hasOwnProperty(c[d])?M[c[d]](A[c[d]],g):A[c[d]]);return e}function w(a,b,c,g,e){return function(k,
f){function l(){var a=null;g?a=f:"function"===typeof f&&(p.start=N(),a=f.apply(d,la(k,h,m)),p.end=N());if(b){A[k]=a;a=k;for(T[a]=!0;(v[a]||[]).length;)v[a].shift()();delete v[a]}p.done=!0}var h=e||this;"function"===typeof k&&(f=k,k=void 0);b&&(k=(k||"__NONAME__").replace(/^prv:/,""),W.hasOwnProperty(k)&&h.error(q(" @ ","Component already registered",k),k),W[k]=!0);for(var m=[],n=0;n<a.length;n++)m[n]=a[n].replace(/^prv:/,"");var p=X[k||"anon"+ ++ma]={depend:m,registered:N(),namespace:h.namespace};
c?l():ja(m,h.guardFatal(k,l));return{decorate:function(a){M[k]=h.guardFatal(k,a)}}}}function Y(a){return function(){return{execute:w(arguments,!1,a,!1,this),register:w(arguments,!0,a,!1,this)}}}function Z(a){return function(b,c){c||(c=b,b=void 0);var d=this.attribution;return function(){B.push({attribution:d,name:b,logLevel:a});var e=c.apply(this,arguments);B.pop();return e}}}function C(a,b){this.load={js:U(this,!0),css:U(this)};z(this,"namespace",b);z(this,"attribution",a)}function aa(){f.body?n.trigger("a-bodyBegin"):
setTimeout(aa,20)}function x(a,b){if(b){for(var c=a.className.split(" "),d=c.length;d--;)if(c[d]===b)return;a.className+=" "+b}}function ba(a,b){for(var c=a.className.split(" "),d=[],e;void 0!==(e=c.pop());)e&&e!==b&&d.push(e);a.className=d.join(" ")}function ca(a){try{return a()}catch(b){return!1}}function D(){if(E){var a=d.innerWidth?{w:d.innerWidth,h:d.innerHeight}:{w:h.clientWidth,h:h.clientHeight},b=!1;5<Math.abs(a.w-O.w)||50<a.h-O.h?(O=a,P=4,(b=l.mobile||l.tablet?a.w>a.h:1250<=a.w)?x(h,"a-ws"):
ba(h,"a-ws")):P--&&(da=setTimeout(D,16))}}function na(a){(E=void 0===a?!E:!!a)&&D()}function oa(){return E}"use strict";r=d.AmazonUIPageJS||d.P;var m=d.ue;m&&m.tag&&(m.tag("aui"),m.tag("aui:aui_build_date:3.16.10.5-2016-11-22"));var F=H.now=H.now||function(){return+new H},N=function(a){return a&&a.now?a.now.bind(a):F}(d.performance),J=[],K=!1,S;S=function(){for(var a=I(),b=F();J.length;)if(J.shift()(),50<F()-b)return;clearTimeout(a);K=!1};t(/OS 6_[0-9]+ like Mac OS X/i)&&y(d,"scroll",I);var T={},
v={},V={},L=!1;y(d,"beforeunload",function(){L=!0;setTimeout(function(){L=!1},1E4)});var W={},A={},M={},X={},ma=0,B=[],ea=d.onerror;d.onerror=function(a,b,c,g,e){e&&"object"===typeof e||(e=Error(a,b,c),e.columnNumber=g,e.stack=b||c||g?q(String.fromCharCode(92),e.message,"at "+q(":",b,c,g)):void 0);var f=B.pop()||{};e.attribution=q(":",e.attribution||f.attribution,f.name);e.logLevel=f.logLevel;e.attribution&&console&&console.log&&console.log([e.logLevel||"ERROR",a,"thrown by",e.attribution].join(" "));
B=[];ea&&(f=[].slice.call(arguments),f[4]=e,ea.apply(d,f))};C.prototype={logError:function(a,b,c,g){b={message:b,logLevel:c||"ERROR",attribution:q(":",this.attribution,g)};if(d.ueLogError)return d.ueLogError(a||b,a?b:null),!0;console&&console.error&&(console.log(b),console.error(a));return!1},error:function(a,b,c,d){a=Error(q(":",d,a,c));a.attribution=q(":",this.attribution,b);throw a;},guardError:Z(),guardFatal:Z("FATAL"),log:function(a,b,c){return this.logError(null,a,b,c)},declare:w([],!0,!0,!0),
register:w([],!0),execute:w([]),AUI_BUILD_DATE:"3.16.10.5-2016-11-22",when:Y(),now:Y(!0),trigger:function(a,b,c){var f=F();this.declare(a,{data:b,pageElapsedTime:f-(d.aPageStart||NaN),triggerTime:f});c&&c.instrument&&fa.when("prv:a-logTrigger").execute(function(b){b(a)})},handleTriggers:function(){this.log("handleTriggers deprecated")},attributeErrors:function(a){return new C(a)},_namespace:function(a,b){return new C(a,b)}};var n=z(d,"AmazonUIPageJS",new C),fa=n._namespace("PageJS","AmazonUI");fa.declare("prv:p-debug",
X);"use strict";n.declare("p-recorder-events",[]);n.declare("p-recorder-stop",function(){});z(d,"P",n);aa();if(f.addEventListener){var ga;f.addEventListener("DOMContentLoaded",ga=function(){n.trigger("a-domready");f.removeEventListener("DOMContentLoaded",ga,!1)},!1)}var h=f.documentElement,Q=function(){var a=["O","ms","Moz","Webkit"],b=f.createElement("div");return{testGradients:function(){b.style.cssText=("background-image:-webkit-gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:"+
a.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);return-1<b.style.backgroundImage.indexOf("gradient")},test:function(c){var d=c.charAt(0).toUpperCase()+c.substr(1);c=(a.join(d+" ")+d+" "+c).split(" ");for(d=c.length;d--;)if(""===b.style[c[d]])return!0;return!1},testTransform3d:function(){var a=!1;d.matchMedia&&(a=d.matchMedia("(-webkit-transform-3d)").matches);return a}}}();r=h.className;var ha=/(^| )a-mobile( |$)/.test(r),ia=/(^| )a-tablet( |$)/.test(r),l={audio:function(){return!!f.createElement("audio").canPlayType},
video:function(){return!!f.createElement("video").canPlayType},canvas:function(){return!!f.createElement("canvas").getContext},svg:function(){return!!f.createElementNS&&!!f.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect},offline:function(){return navigator.hasOwnProperty&&navigator.hasOwnProperty("onLine")&&navigator.onLine},dragDrop:function(){return"draggable"in f.createElement("span")},geolocation:function(){return!!navigator.geolocation},history:function(){return!(!d.history||
!d.history.pushState)},webworker:function(){return!!d.Worker},autofocus:function(){return"autofocus"in f.createElement("input")},inputPlaceholder:function(){return"placeholder"in f.createElement("input")},textareaPlaceholder:function(){return"placeholder"in f.createElement("textarea")},localStorage:function(){return"localStorage"in d&&null!==d.localStorage},orientation:function(){return"orientation"in d},touch:function(){return"ontouchend"in f},gradients:function(){return Q.testGradients()},hires:function(){var a=
d.devicePixelRatio&&1.5<=d.devicePixelRatio||d.matchMedia&&d.matchMedia("(min-resolution:144dpi)").matches;u("hiRes"+(ha?"Mobile":ia?"Tablet":"Desktop"),a?1:0);return a},transform3d:function(){return Q.testTransform3d()},touchScrolling:function(){return t(/Windowshop|android.([3-9]|[L-Z])|OS ([5-9]|[1-9][0-9]+)(_[0-9]{1,2})+ like Mac OS X|Chrome|Silk|Firefox|Trident.+?; Touch/i)},ios:function(){return t(/OS [1-9][0-9]*(_[0-9]*)+ like Mac OS X/i)},android:function(){return t(/android.([1-9]|[L-Z])/i)&&
!t(/trident/i)},mobile:function(){return ha},tablet:function(){return ia}},p;for(p in l)l.hasOwnProperty(p)&&(l[p]=ca(l[p]));for(var R="textShadow textStroke boxShadow borderRadius borderImage opacity transform transition".split(" "),G=0;G<R.length;G++)l[R[G]]=ca(function(){return Q.test(R[G])});var E=!0,da=0,O={w:0,h:0},P=4;D();y(d,"resize",function(){clearTimeout(da);P=4;D()});ba(h,"a-no-js");x(h,"a-js");!t(/OS [1-8](_[0-9]*)+ like Mac OS X/i)||d.navigator.standalone||t(/safari/i)||x(h,"a-ember");
if(l.localStorage)try{x(h,localStorage.getItem("a-skin-font-class"))}catch(pa){}r=[];for(p in l)l.hasOwnProperty(p)&&l[p]&&r.push("a-"+p.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()}));x(h,r.join(" "));h.setAttribute("data-aui-build-date","3.16.10.5-2016-11-22");n.register("p-detect",function(){return{capabilities:l,toggleResponsiveGrid:na,responsiveGridEnabled:oa}});n.declare("a-event-revised-handling",!1)})(window,document,Date);
  (window.AmazonUIPageJS ? AmazonUIPageJS : P).load.js('https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AccioCustomerUIAssets-bbc636f0572471e8eebe82195a4d37e27c2ad39b._V2_.js#AUIClients/AccioCustomerUIAssets.secure.min');
  (window.AmazonUIPageJS ? AmazonUIPageJS : P).load.js('https://images-na.ssl-images-amazon.com/images/I/01KRcg6-T5L._RC|61yGn8SWTgL.js,118juELdZRL.js,51ZWMq2iULL.js,01N6xzIJxbL.js,51K9yT87dJL.js,01rpauTep4L.js,31tLXa0efAL.js,01yqNhFLqeL.js,61vXpM9XUXL.js,018X-PE063L.js,01BBu+b9t0L.js,01eO7OoSd6L.js_.js#AUIClients/AmazonUI.min');
</script>
<script type='text/javascript'>
(function(e,c){function h(b,a){f.push([b,a])}function g(b,a){if(b){var c=e.head||e.getElementsByTagName("head")[0]||e.documentElement,d=e.createElement("script");d.async="async";d.src=b;d.setAttribute("crossorigin","anonymous");a&&a.onerror&&(d.onerror=a.onerror);a&&a.onload&&(d.onload=a.onload);c.insertBefore(d,c.firstChild)}}function k(){ue.uels=g;for(var b=0;b<f.length;b++){var a=f[b];g(a[0],a[1])}ue.deffered=1}var f=[];c.ue&&(ue.uels=h,c.ue.attach&&c.ue.attach("load",k))})(document,window);
(function(a){var b=a.alert;window.alert=function(){a.ueLogError&&a.ueLogError({message:"[CSM] Alert invocation detected with argument: "+arguments[0],logLevel:"WARN"});Function.prototype.apply.apply(b,[a,arguments||[]])}})(window);
(function(k,l,g){function m(a){c||(c=b[a.type].id,"undefined"===typeof a.clientX?(e=a.pageX,f=a.pageY):(e=a.clientX,f=a.clientY),2!=c||h&&(h!=e||n!=f)?(r(),d.isl&&l.setTimeout(function(){p("at",d.id)},0)):(h=e,n=f,c=0))}function r(){for(var a in b)b.hasOwnProperty(a)&&d.detach(a,m,b[a].parent)}function s(){for(var a in b)b.hasOwnProperty(a)&&d.attach(a,m,b[a].parent)}function t(){var a="";!q&&c&&(q=1,a+="&ui="+c);return a}var d=k.ue,p=k.uex,q=0,c=0,h,n,e,f,b={click:{id:1,parent:g},mousemove:{id:2,
parent:g},scroll:{id:3,parent:l},keydown:{id:4,parent:g}};d&&p&&(s(),d._ui=t)})(ue_csm,window,document);



    if (window.ue && window.ue.uels) {
            var cel_widgets = [ { "c":"celwidget" } ];

                ue.uels("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/ClientSideMetricsAUIJavascript-0031b2f2a155b5c13deee8a23805e8758884e579._V2_.js");

    }

(function(k,c){function l(a,b){return a.filter(function(a){return a.initiatorType==b})}function f(a,c){if(b.t[a]){var g=b.t[a]-b._t0,e=c.filter(function(a){return 0!==a.responseEnd&&m(a)<g}),f=l(e,"script"),h=l(e,"link"),k=l(e,"img"),n=e.map(function(a){return a.name.split("/")[2]}).filter(function(a,b,c){return a&&c.lastIndexOf(a)==b}),q=e.filter(function(a){return a.duration<p}),s=g-Math.max.apply(null,e.map(m))<r|0;"af"==a&&(b._afjs=f.length);return a+":"+[e[d],f[d],h[d],k[d],n[d],q[d],s].join("-")}}
function m(a){return a.responseEnd-(b._t0-c.timing.navigationStart)}function n(){var a=c[h]("resource"),d=f("cf",a),g=f("af",a),a=f("ld",a);delete b._rt;b._ld=b.t.ld-b._t0;b._art&&b._art();return[d,g,a].join("_")}var p=20,r=50,d="length",b=k.ue,h="getEntriesByType";b._rre=m;b._rt=c&&c.timing&&c[h]&&n})(ue_csm,window.performance);

(function(l,d){function c(b){b="";var c=a.isBFT?"b":"s",d=""+a.oid,f=""+a.lid,g=d;d!=f&&20==f.length&&(c+="a",g+="-"+f);a.tabid&&(b=a.tabid+"+");b+=c+"-"+g;b!=e&&100>b.length&&(e=b,document.cookie="csm-hit="+b+("|"+ +new Date)+m+"; path=/")}function n(){e=0}function h(b){!0===d[a.pageViz.propHid]?e=0:!1===d[a.pageViz.propHid]&&c({type:"visible"})}var m="; expires="+(new Date(+new Date+6048E5)).toGMTString(),e,a=l.ue||{},k=a.pageViz&&a.pageViz.event&&a.pageViz.propHid;a.attach&&(a.attach("click",c),
a.attach("keyup",c),k||(a.attach("focus",c),a.attach("blur",n)),k&&(a.attach(a.pageViz.event,h,d),h({})));a.aftb=1})(ue_csm,document);


ue_csm.ue.stub(ue,"impression");


(function(h,d,k){function f(a,c,b){a&&a.indexOf&&0===a.indexOf("http")&&0!==a.indexOf("https")&&l(t,c,a,b)}function g(a,c,b){a&&a.indexOf&&m&&(location.href.split("#")[0]!=a&&null!==a&&"undefined"!==typeof a||l(u,c,a,b))}function l(a,c,b,e){n[b]||(e=v&&e?p(e):"N/A",d.ueLogError&&d.ueLogError({message:a+c+" : "+b,logLevel:w,stack:"N/A"},{attribution:e}),n[b]=1,q++)}function e(a,c){if(a&&c)for(var b=0;b<a.length;b++)try{c(a[b])}catch(d){}}function r(){return d.performance&&d.performance.getEntriesByType?
d.performance.getEntriesByType("resource"):[]}function p(a){if(a.id)return"//*[@id='"+a.id+"']";var c;c=1;var b;for(b=a.previousSibling;b;b=b.previousSibling)b.nodeName==a.nodeName&&(c+=1);b=a.nodeName;1!=c&&(b+="["+c+"]");a.parentNode&&(b=p(a.parentNode)+"/"+b);return b}function x(){var a=k.images;a&&a.length&&e(a,function(a){var b=a.getAttribute("src");f(b,"img",a);g(b,"img",a)})}function y(){var a=k.scripts;a&&a.length&&e(a,function(a){var b=a.getAttribute("src");f(b,"script",a);g(b,"script",a)})}
function z(){var a=k.styleSheets;a&&a.length&&e(a,function(a){if(a=a.ownerNode){var b=a.getAttribute("href");f(b,"style",a);g(b,"style",a)}})}function A(){if(B){var a=r();e(a,function(a){f(a.name,a.initiatorType)})}}function C(){m&&e(r(),function(a){g(a.name,a.initiatorType)})}function s(){var a;a=d.location&&d.location.protocol?d.location.protocol:void 0;"https:"==a&&(A(),x(),y(),z(),C(),q<D&&setTimeout(s,E))}var t="[CSM] Insecure content detected ",u="[CSM] Ajax request to same page detected ",
w="WARN",n={},q=0,E=h.ue_nsip||1E3,D=5,B=1==h.ue_urt,m=1==h.ue_suar,v=!0;ue_csm.ue_disableNonSecure||(d.performance&&d.performance.setResourceTimingBufferSize&&d.performance.setResourceTimingBufferSize(300),s())})(ue_csm,window,document);


if(window.ue&&uet) { uet('bb'); }
</script></head><body class="accui teaser domain_prod a-aui_51744-c a-aui_57326-c a-aui_58736-c a-aui_72554-c a-aui_83815-c a-aui_86171-c a-aui_accessibility_49860-c a-aui_attr_validations_1_51371-c a-aui_bolt_62845-c a-aui_decorate_77059-t1 a-aui_noopener_84118-t1 a-aui_ux_56217-c a-aui_ux_59374-c a-aui_ux_60000-c"><div id="a-page"><script type="a-state" data-a-state="{&quot;key&quot;:&quot;a-wlab-states&quot;}">{"AUI_51744":"C","AUI_57326":"C","AUI_58736":"C","AUI_72554":"C","AUI_83815":"C","AUI_86171":"C","AUI_ACCESSIBILITY_49860":"C","AUI_ATTR_VALIDATIONS_1_51371":"C","AUI_BOLT_62845":"C","AUI_DECORATE_77059":"T1","AUI_NOOPENER_84118":"T1","AUI_UX_56217":"C","AUI_UX_59374":"C","AUI_UX_60000":"C"}</script>





<style>
    .teaser .brand_space {
       background-color: #b9cf25;
	   height: auto;
    }
</style>

<div class="a-row">
    <div class="a-column a-span6 amazon_space">
        <div class="a-row logo">
            <div class="a-column a-span12 a-text-left">
                <img alt="Amazon logo" src="https://drs-web.amazon.com/images/amazon_logo.png" width="80" title="Amazon" data-a-hires="https://drs-web.amazon.com/images/amazon_logo_high.png">
            </div>
        </div>

        <div class="a-row teaser_text">
            <div class="a-column a-span12 a-text-left">
                <span>Amazon will automatically ship you new filtration catridges before you run out.</span>
            </div>
        </div>

        <div class="a-row a-grid-vertical-align a-grid-center amazon_text order_text">
            <div class="a-column a-span3 a-text-center">
                <img alt="Order only what you need" src="https://drs-web.amazon.com/images/order_glyph.png" height="59" width="55" title="Order only what you need" data-a-hires="/images/order_glyph_high.png">
            </div>
            <div class="a-column a-span9 a-text-left text a-span-last">
                <span class="title">Order only what you need</span>
                <br>
                <span>Order physical goods from Amazon when supplies are running low.</span>
            </div>
        </div>

        <div class="a-row a-grid-vertical-align a-grid-center amazon_text">
            <div class="a-column a-span3 a-text-center">
                <img alt="" src="https://drs-web.amazon.com/images/secure_glyph.png" height="59" width="55" data-a-hires="https://drs-web.amazon.com/images/secure_glyph_high.png">
            </div>
            <div class="a-column a-span9 a-text-left text a-span-last">
                <span class="title"></span>
                <br>
                <span>Enjoy the speed, safety, and security that comes with refilling your products with Amazon Dash Replenishment Service.</span>
            </div>
        </div>
    </div>

    <div class="a-column a-span6 brand_space a-span-last">
        <div class="a-row teaser_image">
            <div class="a-column a-span12 a-text-center">
                <img alt="" src="images/wfs_teaser.png" data-a-hires="images/wfs_teaser.png">
            </div>
        </div>

        <div class="a-row teaser_footer">
		
            <div class="a-column a-span12 a-text-left">
                <span>Device Model ID</span>
            </div>
            <div class="a-column a-span12 a-text-left a-text-bold">
                <span>fe152d18-4d66-49d1-a3e4-118d1c509b06</span>
            </div>
            <div class="a-column a-span12 a-text-left">
                <span>Serial #</span>
            </div>
            <div class="a-column a-span12 a-text-left">
                <span>
				    <input  class="a-span12" id="serial_no" name="serial_no" value="ujFCkMRHnAPZ" />  
				</span>
            </div>

        </div>
		
		
		
	<div id="amazon-root"></div>
	<script type="text/javascript">

		window.onAmazonLoginReady = function() {
		  amazon.Login.setClientId('amzn1.application-oa2-client.dd7238f2130d48179c24da58bacac020');
		};
		(function(d) {
		  var a = d.createElement('script'); a.type = 'text/javascript';
		  a.async = true; a.id = 'amazon-login-sdk';
		  a.src = 'https://api-cdn.amazon.com/sdk/login1.js';
		  d.getElementById('amazon-root').appendChild(a);
		})(document);

	</script>

<div class="a-row teaser_image">
	<div class="a-column a-span12 a-text-center">
	<a href id="LoginWithAmazon">
	<img border="0" alt="Login with Amazon"
		src="https://images-na.ssl-images-amazon.com/images/G/01/lwa/btnLWA_gold_156x32.png"
		width="156" height="32" />
	</a>
	</div>
</div>
	
	<script type="text/javascript">

		document.getElementById('LoginWithAmazon').onclick = function() {
		var device = 'fe152d18-4d66-49d1-a3e4-118d1c509b06';
		var serial = document.getElementById("serial_no").value;   // '1234567890';
		var returnurl = 'https://wesee.azurewebsites.net/lwa/handle_drs.php?device=' + device + '&serial=' + serial;
		var options = new Object();
		var scope = ('dash:replenish');
		var scope_data = new Object();
		scope_data['dash:replenish'] = {"device_model":device ,"serial":serial ,"is_test_device":true};
		options['scope_data'] = scope_data;
		options['scope'] = scope;
		options['response_type'] = 'code';
		amazon.Login.authorize(options, returnurl);
		return false;
		};

	</script>
                

		
		
		
		
		
    </div>
</div>
<div id='be' style="display:none;visibility:hidden;"><form name='ue_backdetect' action="get"><input type="hidden" name='ue_back' value='1' /></form>


    <script type="text/javascript">
var ue_mbl=ue_csm.ue.exec(function(e,a){function k(f){b=f||{};a.AMZNPerformance=b;b.transition=b.transition||{};b.timing=b.timing||{};e.ue.exec(l,"csm-android-check")()&&b.tags instanceof Array&&(f=-1!=b.tags.indexOf("usesAppStartTime")||b.transition.type?!b.transition.type&&-1<b.tags.indexOf("usesAppStartTime")?"warm-start":void 0:"view-transition",f&&(b.transition.type=f));"reload"===d._nt&&e.ue_orct||"intrapage-transition"===d._nt?a.performance&&performance.timing&&performance.timing.navigationStart?
b.timing.transitionStart=a.performance.timing.navigationStart:delete b.timing.transitionStart:"undefined"===typeof d._nt&&a.performance&&performance.timing&&performance.timing.navigationStart&&a.history&&"function"===typeof a.History&&"object"===typeof a.history&&history.length&&1!=history.length&&(b.timing.transitionStart=a.performance.timing.navigationStart);f=b.transition;var c;c=d._nt?d._nt:void 0;f.subType=c;a.ue&&a.ue.tag&&a.ue.tag("has-AMZNPerformance");d.isl&&a.uex&&uex("at","csm-timing");
m()}function n(b){a.ue&&a.ue.count&&a.ue.count("csm-cordova-plugin-failed",1)}function l(){return a.webclient&&"function"===typeof a.webclient.getRealClickTime?a.cordova&&a.cordova.platformId&&"ios"==a.cordova.platformId?!1:!0:!1}function m(){try{P.register("AMZNPerformance",function(){return b})}catch(a){}}function g(){if(!b)return"";ue_mbl.cnt=null;var a=b.transition,c;c=b.timing.transitionStart;c="undefined"!==typeof c&&"undefined"!==typeof h?c-h:void 0;a=["mts",c,"mtt",a.type,"mtst",a.subType,
"mtlt",a.launchType];c="";for(var d=0;d<a.length;d+=2){var e=a[d],g=a[d+1];"undefined"!==typeof g&&(c+="&"+e+"="+g)}return c}function p(a,c){b&&(h=c,b.timing.transitionStart=a,b.transition.type="view-transition",b.transition.subType="ajax-transition",b.transition.launchType="normal",ue_mbl.cnt=g)}var d=e.ue||{},h=e.ue_t0,b;if(a.P&&a.P.when&&a.P.register)return a.P.when("CSMPlugin").execute(function(a){a.buildAMZNPerformance&&a.buildAMZNPerformance({successCallback:k,failCallback:n})}),{cnt:g,ajax:p}},
"mobile-timing")(ue_csm,window);

(function(d){d._uess=function(){var a="";screen&&screen.width&&screen.height&&(a+="&sw="+screen.width+"&sh="+screen.height);var b=function(a){var b=document.documentElement["client"+a];return"CSS1Compat"===document.compatMode&&b||document.body["client"+a]||b},c=b("Width"),b=b("Height");c&&b&&(a+="&vw="+c+"&vh="+b);return a}})(ue_csm);

(function(a){var b=document.ue_backdetect;b&&b.ue_back&&a.ue&&(a.ue.bfini=b.ue_back.value);a.uet&&a.uet("be");a.onLdEnd&&(window.addEventListener?window.addEventListener("load",a.onLdEnd,!1):window.attachEvent&&window.attachEvent("onload",a.onLdEnd));a.ueh&&a.ueh(0,window,"load",a.onLd,1);a.ue&&a.ue.tag&&(a.ue_furl&&a.ue_furl.split?(b=a.ue_furl.split("."))&&b[0]&&a.ue.tag(b[0]):a.ue.tag("nofls"))})(ue_csm);
(function(g,h){function d(a,d){var b={};if(!e||!f)try{var c=h.sessionStorage;c?a&&("undefined"!==typeof d?c.setItem(a,d):b.val=c.getItem(a)):f=1}catch(g){e=1}e&&(b.e=1);return b}var b=g.ue||{},a="",f,e,c,a=d("csmtid");f?a="NA":a.e?a="ET":(a=a.val,a||(a=b.oid||"NI",d("csmtid",a)),c=d(b.oid),c.e||(c.val=c.val||0,d(b.oid,c.val+1)),b.ssw=d);b.tabid=a})(ue_csm,window);


(function(b,c){var a=c.images;a&&a.length&&b.ue.count("totalImages",a.length)})(ue_csm,document);


ue_csm.ue._rtn = 1;
(function(e,f){function h(a){a=a.split("?")[0]||a;a=a.replace("http://","").replace("https://","").replace("resource://","").replace("res://","").replace("undefined://","").replace("chrome://","").replace(/\*/g,"").replace(/!/g,"").replace(/~/g,"");var b=a.split("/");a=a.substr(a.lastIndexOf("/")+1);b.splice(-1);b=b.map(function(a){c[a]||(c[a]=(k++).toString(36));return c[a]});b.push(a);return b.join("!")}function l(){return f.getEntriesByType("resource").filter(function(a){return d._rre(a)<d._ld}).sort(function(a,
b){return a.responseEnd-b.responseEnd}).splice(0,m).map(function(a){var b=[],c;for(c in a)g[c]&&a[c]&&b.push(g[c]+Math.max(a[c]|0,-1).toString(36));b.push("i"+a.initiatorType);(1==d._rtn&&d._afjs>n||2==d._rtn)&&b.push("n"+h(a.name));return b.join("_")}).join("*")}function p(){var a="pm",b;for(b in c)c.hasOwnProperty(b)&&(a+="*"+c[b]+"_"+b);return a}function q(){d.log({k:"rtiming",value:l()+"~"+p()},"csm")}if(f&&f.getEntriesByType&&Array.prototype.map&&Array.prototype.filter&&e.ue&&e.ue.log){var g=
{connectStart:"c",connectEnd:"C",domainLookupStart:"d",domainLookupEnd:"D",duration:"z",fetchStart:"f",redirectStart:"r",redirectEnd:"R",requestStart:"q",responseStart:"s",responseEnd:"S",startTime:"a"},d=e.ue,c={},k=1,n=20,m=200;d&&d._rre&&(d._art=function(){d._ld&&window.setTimeout(q,0)})}})(ue_csm||{},window.performance);


(function(c,d){var b=c.ue,a=d.navigator;b&&b.tag&&a&&(a=a.connection||a.mozConnection||a.webkitConnection)&&a.type&&b.tag("netInfo:"+a.type)})(ue_csm,window);


(function(c,d){function g(a,b){for(var c=[],d=0;d<a.length;d++){var f=a[d],e=b.encode(f);if(f[h]){var k=b.metaSep,f=f[h],l=b.metaPairSep,g=[],m=void 0;for(m in f)f.hasOwnProperty(m)&&g.push(m+"="+f[m]);f=g.join(l);e+=k+f}c.push(e)}return c.join(b.resourceSep)}function n(a){var b=a[h]=a[h]||{};b[t]||(b[t]=c.ue_mid);b[u]||(b[u]=c.ue_sid);b[k]||(b[k]=c.ue_id);b.csm=1;a="//"+c.ue_furl+"/1/"+a[v]+"/1/OP/"+a[w]+"/"+a[x]+"/"+g([a],y);if(p)try{p.call(d[q],a)}catch(e){c.ue.sbf=1,(new Image).src=a}else(new Image).src=
a}function r(){l&&l.isStub&&l.replay(function(a,b,c){a=a[0];b=a[h]=a[h]||{};b[k]=b[k]||c;n(a)});e.impression=n;l=null}if(!(1<c.ueinit)){var h="metadata",x="impressionType",v="foresterChannel",w="programGroup",t="marketplaceId",u="session",k="requestId",q="navigator",e=c.ue||{},p=d[q]&&d[q].sendBeacon,s=function(a,b,c,d){return{encode:d,resourceSep:a,metaSep:b,metaPairSep:c}},y=s("","?","&",function(a){return g(a.impressionData,z)}),z=s("/",":",",",function(a){return a.featureName+":"+g(a.resources,
A)}),A=s(",","@","|",function(a){return a.id}),l=e.impression;(e.impression||n)({programGroup:"csm",impressionType:"action",impressionData:[{featureName:"csm-features",resources:[{id:"impression-tracking"}]}],foresterChannel:"action-impressions"});p?r():(e.attach("load",r),e.attach("beforeunload",r));d.P&&d.P.register&&d.P.register("impression-client",function(){})}})(ue_csm,window);


if (window.ue_wurl) {
(function(b,a,c){function d(){c.glog.flush({mid:a.ue_mid,sid:a.ue_sid,mkt:a.ue_mkt,sn:a.ue_sn,furl:"https://"+a.ue_furl+"/1/batch/1/OE/",async:!0})}if(b.URL&&b.Worker){b=URL.createObjectURL(new Blob(["(",function(a){importScripts(a)}.toString(),")('",a.ue_wurl,"')"],{type:"application/javascript"}));var f=new Worker(b),e=!1;c.glog=function(a,b,d){f.postMessage({m:"log",l:a,n:b,o:d});e||c.log();e=!0};c.glog.flush=function(a){f.postMessage({m:"flush",o:a});e=!1};c.onunload(d);c.onflush(d)}})(window,
ue_csm,ue);

}

var ue_pty = "Teaser";

var ue_spty = "TBD";


</script>

</div>

<noscript>
    <img height="1" width="1" style='display:none;visibility:hidden;' src='//fls-na.amazon.com/1/batch/1/OP/ATVPDKIKX0DER:161-9726678-7749403:KEPNZPAP23MACWK7175G$uedata=s:%2Fgp%2Fuedata%3Fnoscript%26id%3DKEPNZPAP23MACWK7175G:0' alt=""/>
</noscript>
</div></body></html>

handle_drs.php

PHP
Handle the redirect url
<html> 
<body> 
<?php 
	//var_dump($_REQUEST);
	
	$grant_type = 'authorization_code'; 
	$client_id = 'your client id'; //your client id 
	$client_secret = 'your client secret'; //your client secret	 
	$device = urlencode($_REQUEST['device']);
	$serial = urlencode($_REQUEST['serial']);
	$code =  urlencode($_REQUEST['code']); //the code is retured as a parameter in the query string once the user logs in 
	$data = array("grant_type"=>$grant_type, "code" => $code, "client_id"=> $client_id, "client_secret"=> $client_secret); 
	$postvars = ''; 
	foreach($data as $key=>$value) { 
	$postvars .= $key . "=" . $value . "&"; 
	} 
	$c = curl_init('https://api.amazon.com/auth/o2/token');  
	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST"); 
	curl_setopt($c, CURLOPT_POSTFIELDS, $postvars); 
	curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded;charset=UTF-8')); 
	$r = curl_exec($c); 
	curl_close($c); 
	$ra = json_decode($r, true); 
	if (isset($ra['error']) == true){ //there was an error obtaining the auth token 
		echo '<h3>There was an error authenticating with Amazon. Can you please start over again? Click <a href="/drs4wfs/">here</a> to start again.</h3>'	; 
	} else { 
	
		// DB connection info
		$host = "ap-cdbr-azure-southeast-b.cloudapp.net:3306";  //db host
		$user = "db user";  //db user
		$pwd = "db password";  //db password
		$db = "db name";  //db name
		 
		 // Connect to database.
		 try {
			 $conn = new PDO( "mysql:host=$host;dbname=$db", $user, $pwd);
			 $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
		 }
		 catch(Exception $e){
			 die(var_dump($e));
		 }


		$access_token = $ra['access_token']; 
		$refresh_token = $ra['refresh_token']; 
		$expires_in = $ra['expires_in']; 

		try {
			 $date = date("Y-m-d");
			 // Insert data
			 $sql_insert = "INSERT INTO drs_tbl (device, serial, code, access_token, refresh_token, expires_in, date) 
							VALUES (?,?,?,?,?,?,?)";
			 $stmt = $conn->prepare($sql_insert);
			 $stmt->bindValue(1, $device);
			 $stmt->bindValue(2, $serial);
			 $stmt->bindValue(3, $code);
			 $stmt->bindValue(4, $access_token);
			 $stmt->bindValue(5, $refresh_token);
			 $stmt->bindValue(6, $expires_in);
			 $stmt->bindValue(7, $date);
			 $stmt->execute();
		 }
		 catch(Exception $e) {
			 die(var_dump($e));
		 }

 
		echo "<h1>Registration complete.</h1>";
		
		//$access_token = $ra['access_token']; 
		//$refresh_token = $ra['refresh_token']; 
		//var_dump($ra);
		//echo 'access token -> ' . $access_token . '<br/>';
		//echo 'refresh token -> ' .  $refresh_token . '<br/>';
		
	} 
?> 
</body> 
</html> 

refresh_drs.php

PHP
Refresh token
<html> 
<body> 
<?php 
	//var_dump($_REQUEST);
	
	$device = urlencode($_REQUEST['device']);
	$serial = urlencode($_REQUEST['serial']);

	// DB connection info
	$host = "ap-cdbr-azure-southeast-b.cloudapp.net:3306";
	$user = "db user";   // db user
	$pwd = "db password";   // db password
	$db = "db name";   // db name
	 
	// Connect to database.
	try {
		$conn = new PDO( "mysql:host=$host;dbname=$db", $user, $pwd);
		$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
	}
	catch(Exception $e){
		die(var_dump($e));
	}

	try {
		// Select data
		$sql_select = "SELECT refresh_token FROM drs_tbl WHERE device = ? AND serial = ?";
		$stmt = $conn->prepare($sql_select);
		$stmt->bindValue(1, $device);
		$stmt->bindValue(2, $serial);
		$stmt->execute();
		
		$row = $stmt->fetch(PDO::FETCH_ASSOC);
		//echo "<br/>>>> old refresh token <<< " . $row['refresh_token'] . "<br/>";
		$refresh_token = $row['refresh_token'];
	 }
	 catch(Exception $e) {
		die(var_dump($e));
	 }


	$grant_type = 'refresh_token'; 
	$client_id = 'your client id'; //your client id 
	$client_secret = 'your client secret'; //your client secret	
	//$refresh_token = '';
	$data = array("grant_type"=>$grant_type, "refresh_token" => $refresh_token, "client_id"=> $client_id, "client_secret"=> $client_secret); 
	$postvars = ''; 
	foreach($data as $key=>$value) { 
	$postvars .= $key . "=" . $value . "&"; 
	} 

	$c = curl_init('https://api.amazon.com/auth/o2/token');  
	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST"); 
	curl_setopt($c, CURLOPT_POSTFIELDS, $postvars); 
	curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded')); 
	$r = curl_exec($c); 
	$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);  
	curl_close($c); 
	//echo "<br/>>>> httpcode <<< " . $httpcode . "<br/>";

	$ra = json_decode($r, true); 
	//echo "<br/><br/>";
	//var_dump($ra); 
	//echo "<br/><br/>";
		
	if ($httpcode != 200){ 
		echo '<h3>There was an error during token refresh.</h3>'	; 
	} else { 
	 
		try {
			// Update data
			$sql_update = "UPDATE drs_tbl SET access_token = ?, expires_in = ? WHERE device = ? AND serial = ?";
			$stmt = $conn->prepare($sql_update);
			$stmt->bindValue(1, $ra['access_token']);
			$stmt->bindValue(2, $ra['expires_in']);
			$stmt->bindValue(3, $device);
			$stmt->bindValue(4, $serial);
			$stmt->execute();
			
		 }
		 catch(Exception $e) {
			die(var_dump($e));
		 }

		 echo "<h1>Token refresh complete.</h1>";
		
	} 
?> 
</body> 
</html> 

replenish_drs.php

PHP
Replenish order
<html> 
<body> 
<?php 
	//var_dump($_REQUEST);
	
	$device = urlencode($_REQUEST['device']);
	$serial = urlencode($_REQUEST['serial']);

	// DB connection info
	$host = "ap-cdbr-azure-southeast-b.cloudapp.net:3306";
	$user = "db user";  // db user
	$pwd = "db password";  // db password
	$db = "db name";  // db name
	 
	// Connect to database.
	try {
		$conn = new PDO( "mysql:host=$host;dbname=$db", $user, $pwd);
		$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
	}
	catch(Exception $e){
		die(var_dump($e));
	}

	try {
		// Select data
		$sql_select = "SELECT access_token FROM drs_tbl WHERE device = ? AND serial = ?";
		$stmt = $conn->prepare($sql_select);
		$stmt->bindValue(1, $device);
		$stmt->bindValue(2, $serial);
		$stmt->execute();
		
		$row = $stmt->fetch(PDO::FETCH_ASSOC);
		//echo "<br/>>>> access token <<< " . $row['access_token'] . "<br/>";
		$access_token = $row['access_token'];
	 }
	 catch(Exception $e) {
		die(var_dump($e));
	 }

	$slot_id = "dbdf9606-0c52-4f48-8995-af33638f6ccc";
	$c = curl_init('https://dash-replenishment-service-na.amazon.com/replenish/' . $slot_id);  
	curl_setopt($c, CURLOPT_CUSTOMREQUEST, "POST"); 
	curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($c, CURLOPT_HTTPHEADER, array('Authorization:Bearer ' . $access_token, 
	'x-amzn-accept-type:com.amazon.dash.replenishment.DrsReplenishResult@1.0',
	'x-amzn-type-version:com.amazon.dash.replenishment.DrsReplenishInput@1.0', 
	'Content-Type:application/x-www-form-urlencoded')); 
	$r = curl_exec($c); 
	$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);  
	curl_close($c); 
	//echo ">>> httpcode <<< " . $httpcode . "<br/>";

	$ra = json_decode($r, true); 
	//echo "<br/><br/>";
	//var_dump($ra); 
	//echo "<br/><br/>";
		
	if ($httpcode != 200){ 
		echo '<h3>There was an error during order replenishment.</h3>'	; 
	} else { 
	 
		echo "<h1>Replenishment complete.</h1>";
		
	} 
?> 
</body> 
</html> 

waterflow_drs.ino

C/C++
/*
Liquid flow rate sensor -DIYhacking.com Arvind Sanjeev

Measure the liquid/water flow rate using this code. 
Connect Vcc and Gnd of sensor to arduino, and the 
signal line to arduino digital pin 2.
 
 */
#include <WiFi101.h>

byte statusLed    = 13;

byte sensorInterrupt = 0;  // 0 = digital pin 2
byte sensorPin       = 2;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 4.5;

volatile byte pulseCount;  

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;

unsigned long oldTime;

char ssid[] = "your network ssid";      // your network SSID (name)
char pass[] = "your network password";   // your network password

char hostname[] = "wesee.azurewebsites.net";    // host name address for your Azure web app
char feeduri[] = "/lwa/replenish_drs.php?device=fe152d18-4d66-49d1-a3e4-118d1c509b06&serial=2xUJugQmFBNn"; //feed URI (device + serial)

int status = WL_IDLE_STATUS;
WiFiClient client;

unsigned int litresCount;

void setup()
{
  
  // Initialize a serial connection for reporting values to the host
  Serial.begin(38400);

   
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  
  // you're connected now, so print out the status:
  printWifiStatus();


    
  // Set up the status LED line as an output
  pinMode(statusLed, OUTPUT);
  digitalWrite(statusLed, HIGH);  // We have an active-low LED attached
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;

  litresCount = 1;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}

/**
 * Main program loop
 */
void loop()
{
  String response = "";
  char c;
  // read response if WiFi Client is available
  while (client.available()) {
    c = client.read();
    response.concat(c);
  }
  
  if((millis() - oldTime) > 1000)    // Only process counters once per second
  { 
    // Disable the interrupt while calculating flow rate and sending the value to
    // the host
    detachInterrupt(sensorInterrupt);
        
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
    
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
    
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitres += flowMilliLitres;
      
    unsigned int frac;
    
    // Print the flow rate for this second in litres / minute
    Serial.print("Flow rate: ");
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable
    Serial.print("L/min");
    // Print the number of litres flowed in this second
    Serial.print("  Current Liquid Flowing: ");             // Output separator
    Serial.print(flowMilliLitres);
    Serial.print("mL/Sec");

    // Print the cumulative total of litres flowed since starting
    Serial.print("  Output Liquid Quantity: ");             // Output separator
    Serial.print(totalMilliLitres);
    Serial.println("mL"); 

    // send to web app for order replenishment for every Litre of water
    if (totalMilliLitres > litresCount * 1000) {
      litresCount++;
      sendOrderReplenishment();
    }
    
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
    
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
}

/*
Insterrupt Service Routine
 */
void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  IPAddress subnet = WiFi.subnetMask();
  Serial.print("Netmask: ");
  Serial.println(subnet);

  IPAddress gateway = WiFi.gatewayIP();
  Serial.print("Gateway: ");
  Serial.println(gateway);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void sendOrderReplenishment() {

  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  String contentType = "text/plain";
  
  // if there's a successful connection:
  if (client.connect(hostname, 80)) {
    //make the GET request
    client.print("GET ");  //Do a GET
    client.print(feeduri);  // On the feedURI
    client.println(" HTTP/1.1"); 
    client.print("Host: "); 
    client.println(hostname);  //with hostname header
    client.println("Connection: close");

    client.print("Content-Type: ");
    client.println(contentType);

    client.println();

    Serial.println();
    Serial.println(">>> send order replenishment <<<");

  }
  else {
    // if you couldn't make a connection:
    Serial.println();
    Serial.println("connection failed");
  }
  
}

Credits

vincent wong

vincent wong

60 projects • 163 followers

Comments

Add projectSign up / Login