{"id":515,"date":"2013-02-03T21:24:46","date_gmt":"2013-02-03T20:24:46","guid":{"rendered":"http:\/\/quantum-bits.org\/?p=515"},"modified":"2022-08-12T17:35:35","modified_gmt":"2022-08-12T16:35:35","slug":"baking-apple-pies","status":"publish","type":"post","link":"https:\/\/www.quantum-bits.org\/?p=515","title":{"rendered":"Baking Apple Pies"},"content":{"rendered":"<table width=\"100%\">\n<tbody>\n<tr>\n<td>Now that &#8220;applepie&#8221; (my very first Raspberry Pi) is set up, it is time to have a little fun. The first hacks will be to turn the device into a cheap (but nonetheless quite efficient) AirPlay \/ AirPrint device, while baking a real Apple Pie&#8230;<\/td>\n<td><img decoding=\"async\" src=\"http:\/\/quantum-bits.org\/wp-content\/uploads\/2013\/02\/raspberrypi-logo.png\" alt=\"\" align=\"top\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Setting up AirPlay<\/strong><\/p>\n<p>First, I hooked up the Raspberry Pi to Altec Lansing powered speakers through the Jack connector.<\/p>\n<p>Next, one has to force audio output to stereo jack (Raspberry PI defaults to HDMI audio output):<\/p>\n<pre line=\"1\" lang=\"bash\">apt-get update\napt-get upgrade\napt-get install alsa-utils\namixer cset numid=3 1<\/pre>\n<p>The result can be easily tested:<\/p>\n<pre line=\"1\" lang=\"bash\">aplay \/usr\/share\/sounds\/alsa\/Front_Center.wav<\/pre>\n<p>.. and I could hear the phrase &#8220;Front, Center&#8221; coming out from the speakers.<\/p>\n<p>Then, one has to setup <strong>Avahi<\/strong> and <strong>Shairport<\/strong>.<\/p>\n<p><strong>Avahi<\/strong> is a free (as in free speech) implementation of Apple <a title=\"Bonjour\" href=\"http:\/\/en.wikipedia.org\/wiki\/Zero_configuration_networking\" target=\"_blank\" rel=\"noopener\">zeroconf \/ bonjour<\/a> protocol, including a system for multicast DNS\/DNS-SD service discovery. It is licensed under the LGPL and included in the Raspbian distribution. Thus, the installation of avahi is quite easy:<\/p>\n<pre line=\"1\" lang=\"bash\">apt-get install avahi-deamon avahi-utils<\/pre>\n<p>Shairport, on the other hand, is not packaged with the Raspbian distribution. It has to be built from sources.<\/p>\n<p>Let&#8217;s install all Shairport dependencies:<\/p>\n<pre line=\"1\" lang=\"bash\">apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl  cpanminus make  libavahi-client-dev\ncpan Net::SDP<\/pre>\n<p>Then get Shairport&#8217;s sources<\/p>\n<pre line=\"1\" lang=\"bash\">cd \/opt\nmkdir airport\ncd airport\ngit clone https:\/\/github.com\/albertz\/shairport.git shairport<\/pre>\n<p>Let&#8217;s compile and install Shairport :<\/p>\n<pre line=\"1\" lang=\"bash\">cd shairport\nmake\nmake install\ncp shairport.init.sample \/etc\/init.d\/shairport\nupdate-rc.d shairport defaults<\/pre>\n<p>Edit the default startup configuration file (\/etc\/init.d\/shairport) and define the name of your AirPlay device (change the &#8220;NAME&#8221; variable):<\/p>\n<pre line=\"1\" lang=\"bash\">vi \/etc\/init.d\/shairport<\/pre>\n<p>I named my AirPlay device &#8220;<em>Apple Pie Bureau<\/em>&#8220;. Now, start up avahi-daemon and shairport:<\/p>\n<pre line=\"1\" lang=\"bash\">service avahi-daemon start\nservice shairport start<\/pre>\n<p>And you&#8217;re ready to rock, either form an iPhone \/ iPad:<\/p>\n<p><center><img decoding=\"async\" title=\"rock on!\" src=\"http:\/\/quantum-bits.org\/wp-content\/uploads\/2013\/02\/air-play2.png\" alt=\"\"><\/center><br \/>\n&nbsp;<br \/>\nor from iTunes:<\/p>\n<p><center><img decoding=\"async\" title=\"rock on!\" src=\"http:\/\/quantum-bits.org\/wp-content\/uploads\/2013\/02\/air-play1.png\" alt=\"\"><\/center><\/p>\n<p>Cool \ud83d\ude0e<\/p>\n<p><strong>Setting up AirPrint<\/strong><\/p>\n<p>Setting up AirPrint is about the same procedure. The idea is to set up a <a title=\"CUPS\" href=\"http:\/\/en.wikipedia.org\/wiki\/CUPS\" target=\"_blank\" rel=\"noopener\">CUPS<\/a> server, configure a shared printer and then to broadcast AirPrint stuff via avahi. The bridge between them is built upon the <a title=\"AirPrint generate script\" href=\"https:\/\/github.com\/tjfontaine\/airprint-generate\">airprint-generate<\/a> script and a few tweaks.<\/p>\n<p>Let&#8217;s install CUPS (and associated printer drivers) and avahi-discover:<\/p>\n<pre line=\"1\" lang=\"bash\">apt-get install cups cups-filters cups-pdf cups-ppdc python-cups \napt-get install foomatic-db-gutenprint libgutenprint2 printer-driver-gutenprint foomatic-db-compressed-ppds foomatic-db-engine foomatic-db-gutenprint foomatic-filters \napt-get install avahi-discover libnss-mdns\nusermod -aG lpadmin pi<\/pre>\n<p>Next, as usual, one has to edit CUPS configuration file (\/etc\/cups\/cups.conf):<\/p>\n<ul>\n<li style=\"list-style: square inside; color: #aaaaaa;\"><span style=\"color: #666666;\">Comment out the &#8220;Listen localhost:631&#8221; line<\/span><\/li>\n<li style=\"list-style: square inside; color: #aaaaaa;\"><span style=\"color: #666666;\">Add the line &#8220;Port 631&#8221;. This way, printers can be added throught CUPS web interface from any host<\/span><\/li>\n<li style=\"list-style: square inside; color: #aaaaaa;\"><span style=\"color: #666666;\">Add &#8220;Allow @Local&#8221; right after &#8220;Order allow, deny&#8221; for &lt;Location \/&gt; and &lt;Location \/admin&gt;<\/span><\/li>\n<li style=\"list-style: square inside; color: #aaaaaa;\"><span style=\"color: #666666;\">start CUPS: service cups start<\/span><\/li>\n<\/ul>\n<p>After connecting my AcuLaser AC1100 printer to the Raspberry Pi (and hunting for hours to get the proper drivers), I was able to access CUPS web administration interface (&#8220;https:\/\/applepie:631\/admin&#8221;) and add a new shared printer.<\/p>\n<p>Then comes the tricky part: bridging CUPS and Avahi:<\/p>\n<pre line=\"1\" lang=\"bash\">cd \/opt\nmkdir airprint\nwget -O airprint-generate.py --no-check-certificate https:\/\/raw.github.com\/tjfontaine\/airprint-generate\/master\/airprint-generate.py\nchmod +x airprint-generate.py\necho \"image\/urf urf string(0,UNIRAST)\" &gt; \/usr\/share\/cups\/mime\/airprint.types\necho \"image\/urf urf (0,UNIRAST)\" &gt; \/usr\/share\/cups\/mime\/apple.types\necho \"image\/urf application\/pdf 100 pdftoraster\" &gt; \/usr\/share\/cups\/mime\/airprint.convs\necho \"image\/urf application\/vnd.cups-postscript 66 pdftops\" &gt; \/usr\/share\/cups\/mime\/local.convs<\/pre>\n<pre line=\"1\" lang=\"bash\">.\/airprint-generate.py\ncp AirPrint-EPSON-AL-C1100.service \/etc\/avahi\/services\nservice avahi-daemin restart<\/pre>\n<p>The CUPS shared printer, connected to the Raspberry Pi, is now ready to be used, either from GNU\/Linux, Mac OSX or iOS devices:<\/p>\n<p><center><img decoding=\"async\" title=\"AirPrint on iPad\" src=\"http:\/\/quantum-bits.org\/wp-content\/uploads\/2013\/02\/air-print1.png\" alt=\"\"><\/center>Niice \ud83d\ude0e<\/p>\n<p><strong>Baking Apple Pies<\/strong><\/p>\n<p>There we go. Appart from the CUPS GNU\/Linux AL-C1100 drivers (which were not easy to find and configure), it was quite easy \ud83d\ude42<\/p>\n<p>The Raspberry Pi (named ApplePie) is now set up, and ready to meet &#8230; the <em>other<\/em> freashly baked apple Pie:<\/p>\n<p><center><img decoding=\"async\" title=\"pi vs pie\" src=\"http:\/\/quantum-bits.org\/wp-content\/uploads\/2013\/02\/pivspie.png\" alt=\"\"><\/center>(and yes, I&#8217;m quite happy with this &#8220;pi vs pie&#8221; joke)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that &#8220;applepie&#8221; (my very first Raspberry Pi) is set up, it is time to have a little fun. The first hacks will be to turn the device into a &#8230;<\/p>\n","protected":false},"author":1,"featured_media":3853,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[5,21],"tags":[],"_links":{"self":[{"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/posts\/515"}],"collection":[{"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=515"}],"version-history":[{"count":0,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/posts\/515\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=\/wp\/v2\/media\/3853"}],"wp:attachment":[{"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quantum-bits.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}