From eBower Wiki
Jump to: navigation, search
(The Stoker)
(The Stoker)
Line 1: Line 1:
 
This is an evolution of my original stoker_mon project. And my evolution, I mean complete rewrite from scratch. This is a web server designed to control and monitor a [https://www.rocksbarbque.com/ Stoker] power draft controller.
 
This is an evolution of my original stoker_mon project. And my evolution, I mean complete rewrite from scratch. This is a web server designed to control and monitor a [https://www.rocksbarbque.com/ Stoker] power draft controller.
 +
 +
= The Setup =
 +
 +
  
 
= The Stoker =
 
= The Stoker =

Revision as of 17:17, 29 March 2015

This is an evolution of my original stoker_mon project. And my evolution, I mean complete rewrite from scratch. This is a web server designed to control and monitor a Stoker power draft controller.

The Setup

The Stoker

I have a Stoker WiFi, but I've found that the WiFi isn't all that stable. It will periodically drop, and the Stoker itself has a pretty horrid security model considering its intended purpose is to control an active fire right next to your house. The new Stoker II may fix some of these issues, but so does a Raspberry Pi.

What you'll need is a Raspberry Pi with a physical Ethernet port and a WiFi dongle. The WiFi is how it connects to the Internet, the physical Ethernet port is how it connects to the Stoker. The first thing you'll want to do is the standard Raspberry Pi stuff. Use something like nmap -sP 192.168.0.0/24 to find your current hosts, power up the Pi with the Ethernet port plugged in and run the command again to find the Pi. You should now be able to telnet in with pi/raspberry and run the initial setup to expand the storage, change the password, and whatever else you want to do. Of course, always run sudo apt-get update && sudo apt-get dist-upgrade to get the latest software. You should also add ipv6 to the bottom of /etc/modules or you'll be stuck in 2010...

WiFi

First job is to get the WiFi running. If you run ifconfig you should see a wlan0, if not you'll need to find drivers. Now edit /etc/network/interfaces to include your network name and password:

allow-hotplug wlan0
iface wlan0 inet dhcp
        wpa-ssid "MyWiFi"
        wpa-psk "my_password"

DHCP

Now we'll need to install a DHCP server. This is optional, you can also just fix your Stoker's IP address via the Stoker UI, but I prefer everything to be DHCP so I can move it between networks easily. Run sudo apt-get install isc-dhcp-server, edit /etc/dhcp/dhcpd.conf to include the following lines:

subnet 172.16.14.0 netmask 255.255.255.0 {
  range 172.16.14.10 172.16.14.20;
}

host stoker {
  hardware ethernet 00:60:35:xx:xx:xx;
  fixed-address 172.16.14.10;
}

This assumes that you're using 172.16.14.0/24 and want to set up the Stoker at 172.16.14.10 - make sure to replace the xx:xx:xx with your own Stoker's MAC address. You can find this in /var/lib/dhcp.leases as well.

Now we'll need to edit /etc/network/interfaces to include the following:

iface eth0 inet static
address 172.16.14.1
netmask 255.255.255.0

Apache

Finally, we'll want Apache up and running. We need to run sudo apt-get install apache2 php5 php5-curl to install it. Then we'll need to edit /etc/apache2/sites-available/default to include the AddType line in the /var/www/ directory setting:

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AddType application/x-httpd-php .json
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

stoker.json

All I care about is getting the JSON API working, the user interface is useless to me but you can always write your own with this as a baseline. It's important to me that the API be transparent at this point, so I can't tell if I'm talking to my Pi or the Stoker directly. However I may add some enhanced features eventually that break this.

<?php
$curl_json = curl_init();
curl_setopt($curl_json, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl_json, CURLOPT_URL, 'http://172.16.14.10/stoker.json');
curl_setopt($curl_json, CURLOPT_RETURNTRANSFER, true);
$json_resp = curl_exec($curl_json);
$resp_info = curl_getinfo($curl_json);
curl_close($curl_json);
 
if ( $resp_info['http_code'] == 200 ) {
  print $json_resp;
} else {
  var_dump($responseInfo);
}
 
?>

Security

Finally, let's lock things down a bit. Run sudo apt-get install ufw. Now I run:

sudo ufw allow in on wlan0 from 2001:470:1f07:a86::/64

This allows access only from my IPv6 subnet on any port. I don't have ports open other than 80 (http) and 22 (ssh) and I intend to manually do host-based checks when writing to the Stoker so only my webserver can access the write interface.