Skip to content

Instantly share code, notes, and snippets.

@meub
Last active April 27, 2018 09:38
Show Gist options
  • Save meub/5e6efce206ceb86f7075411c452530a0 to your computer and use it in GitHub Desktop.
Save meub/5e6efce206ceb86f7075411c452530a0 to your computer and use it in GitHub Desktop.
Instructions on how to setup DD-WRT to recognize Amazon Dash button presses
### Dash Button Hack ###
DD WRT > Services > Services > Additional DNSMasq options:
dhcp-script=/tmp/custom.sh
DD WRT > Status > Wireless:
Press your Dash button.
Note your MAC address as it appears on the Status page.
DD WRT > Administration > Commands > Custom Script:
Set the "lease_update" script below as your custom script
Modify the MAC address to be your dash button's MAC.
### lease_update script ###
#!/bin/sh
# if $1 is add del or old, this is a dnsmasq-called lease-change
# script, update the nvram database. if $1 is init, emit a
# dnsmasq-format lease file to stdout representing the current state of the
# database, this is called by dnsmasq at startup.
NVRAM=/usr/sbin/nvram
PREFIX=dnsmasq_lease_
# Arguments.
# $1 is action (add, del, old)
# $2 is MAC
# $3 is address
# $4 is hostname (optional, may be unset)
# env.
# DNSMASQ_LEASE_LENGTH or DNSMASQ_LEASE_EXPIRES (which depends on HAVE_BROKEN_RTC)
# DNSMASQ_CLIENT_ID (optional, may be unset)
# File.
# length|expires MAC addr hostname|* CLID|*
# Primary key is address.
if [ ${1} = init ] ; then
${NVRAM} show | sed -n -e "/^${PREFIX}.*/ s/^.*=//p"
else
if [ ${1} = del ] ; then
${NVRAM} unset ${PREFIX}${3}
fi
if [ ${1} = old ] || [ ${1} = add ] ; then
${NVRAM} set ${PREFIX}${3}="${DNSMASQ_LEASE_LENGTH:-}${DNSMASQ_LEASE_EXPIRES:-} ${2} ${3} ${4:-*} ${DNSMASQ_CLIENT_ID:-*}"
fi
${NVRAM} commit
fi
# use your dash button MAC address here
if [ $2 = "74:c2:46:c7:fa:FF" ] ; then
# do whatever you want here
curl "http://<your-server>/dash/$1/$2/$3/$4"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment