Difference between revisions of "FM radio API"

From Chumby Wiki
Jump to: navigation, search
(New page: ==Introduction== chumbradiod is a small daemon application that hosts information about a Chumby radio over HTTP, and also allows for real time configuration of the FM radio parameters. ...)
 
 
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
  
chumbradiod is a small daemon application that hosts information about a Chumby radio over HTTP, and also allows for real time configuration of the FM radio parameters.
+
chumbradiod is a small daemon application that hosts information about a Chumby radio over HTTP, and also allows for real time configuration of the FM radio parameters. Chumbradiod was build using the [[Chumby Radio API]].
  
 
==Status Usage==
 
==Status Usage==
Line 7: Line 7:
 
  chumby:/# service_control chumbradiod start
 
  chumby:/# service_control chumbradiod start
  
You should then be able to access the status of the chumby radio by opening any web browser to the page <pre>http://ip:8081/radio/status.xml</pre>.  To get debugging information, you need to first convince the controlpanel that chumbradiod is actually running.  To do this, run <pre>echo 1 > /var/services/chumbradiod/pids</pre>, and then just run <pre>chumbradiod</pre>.
+
You should then be able to access the status of the chumby radio by opening any web browser to the page <pre>http://ip:8081/radio/status.xml</pre>
  
 
==Status Response==
 
==Status Response==
Line 58: Line 58:
 
<pre>http://ip:8081/radio/configure?rds=1</pre>
 
<pre>http://ip:8081/radio/configure?rds=1</pre>
  
* Set seeking strength.  You probably want this to be very low.
+
* Set seeking strength
 
<pre>http://ip:8081/radio/configure?seek_strength=20</pre>
 
<pre>http://ip:8081/radio/configure?seek_strength=20</pre>
  
Line 68: Line 68:
  
 
* Set the country, which defines tuning frequency ranges.  Note you'll probably want to issue a rescan at the same time.
 
* Set the country, which defines tuning frequency ranges.  Note you'll probably want to issue a rescan at the same time.
<pre>http://ip:8081/radio/configure?country=usa</pre>
+
<pre>http://ip:8081/radio/configure?country=us</pre>
<pre>http://ip:8081/radio/configure?country=japan</pre>
+
<pre>http://ip:8081/radio/configure?country=jp</pre>
<pre>http://ip:8081/radio/configure?country=china</pre>
+
<pre>http://ip:8081/radio/configure?country=ch</pre>
 +
<pre>http://ip:8081/radio/configure?country=eu</pre>
 +
<pre>http://ip:8081/radio/configure?country=it</pre>
 +
<pre>http://ip:8081/radio/configure?country=xx</pre>
  
 
* Lock the configuration interface with key 12345.  Note that once locked, you'll need to specify the same "key" every time you issue a "configure" request.  Unlock by sending the key, along with "lock=0".
 
* Lock the configuration interface with key 12345.  Note that once locked, you'll need to specify the same "key" every time you issue a "configure" request.  Unlock by sending the key, along with "lock=0".
Line 80: Line 83:
 
* Configure multiple options
 
* Configure multiple options
 
<pre>http://ip:8081/radio/configure?station=94.9&power=1</pre>
 
<pre>http://ip:8081/radio/configure?station=94.9&power=1</pre>
 +
 +
==Country Listing==
 +
 +
You can get a list of supported countries by calling <pre>http://ip:8081/radio/countries</pre>
 +
 +
<countries>
 +
    <country iso="ch" start="76.00" stop="108.00" spacing="100"/>
 +
    <country iso="eu" start="87.00" stop="108.00" spacing="100"/>
 +
    <country iso="it" start="87.00" stop="108.00" spacing="50"/>
 +
    <country iso="jp" start="76.00" stop="90.00" spacing="100"/>
 +
    <country iso="us" start="87.50" stop="108.00" spacing="200"/>
 +
    <country iso="xx" start="76.00" stop="108.00" spacing="10"/>
 +
</countries>
  
 
==Configuration Response==
 
==Configuration Response==

Latest revision as of 16:15, 2 November 2010

Introduction

chumbradiod is a small daemon application that hosts information about a Chumby radio over HTTP, and also allows for real time configuration of the FM radio parameters. Chumbradiod was build using the Chumby Radio API.

Status Usage

chumby:/# service_control chumbradiod start
You should then be able to access the status of the chumby radio by opening any web browser to the page
http://ip:8081/radio/status.xml

Status Response

You will receive an XML response giving the current FM radio status...

  • Example 1 (device found)
<radio found="1" tuned="1" station="104.7" stereo="0" signal="20" signal_max="256" volume="15" volume_max="15" seek_threshold="20" seek_threshold_max="255" spacing="200" band="US/Europe">
    <station freq="90.70"/>
    <station freq="94.10"/>
    <station freq="94.90"/>
    <station freq="95.70"/>
    <station freq="96.50"/>
    <station freq="102.10"/>
    <station freq="102.90"/>
    <station freq="103.70"/>
</radio>
  • Example 2 (device found, RDS enabled)
<radio found="1" tuned="1" station="105.3" stereo="1" signal="105" signal_max="256" seek_threshold="0" seek_threshold_max="255"
spacing="200" band="US/Europe" callsign="KCNL" programservice="RADIO   " ptycode="Rock" radiotext0=" SAVE YOUR RADIO DOT ORG" radiotext1=""
juliandate="0" hour="0" minute="0" localtime="0:00">
    <station freq="105.30"/>
    <station freq="105.50"/>
    <station freq="105.70"/>
    <station freq="106.50"/>
    <station freq="107.50"/>
</radio>
  • Example 3 (device not found)
<radio found="0"/>

Configuration Usage

You can also configure the radio using an HTTP query string

http://ip:8081/radio/configure

There are several commands available...

  • Set radio station
http://ip:8081/radio/configure?station=94.9
  • Seek radio up
http://ip:8081/radio/configure?seek_up=1
  • Seek radio down
http://ip:8081/radio/configure?seek_down=1
  • Enable RDS support in status messages. Note this will cause chumbradiod to use about 2% more CPU.
http://ip:8081/radio/configure?rds=1
  • Set seeking strength
http://ip:8081/radio/configure?seek_strength=20
  • Refresh the list of available stations
http://ip:8081/radio/configure?rescan=1
  • Turn on the radio and begin playing through the speakers
http://ip:8081/radio/configure?power=1
  • Set the country, which defines tuning frequency ranges. Note you'll probably want to issue a rescan at the same time.
http://ip:8081/radio/configure?country=us
http://ip:8081/radio/configure?country=jp
http://ip:8081/radio/configure?country=ch
http://ip:8081/radio/configure?country=eu
http://ip:8081/radio/configure?country=it
http://ip:8081/radio/configure?country=xx
  • Lock the configuration interface with key 12345. Note that once locked, you'll need to specify the same "key" every time you issue a "configure" request. Unlock by sending the key, along with "lock=0".
http://ip:8081/radio/configure?key=12345&lock=1


You may set multiple options at once. The last option part will take affect.

  • Configure multiple options
http://ip:8081/radio/configure?station=94.9&power=1

Country Listing

You can get a list of supported countries by calling
http://ip:8081/radio/countries
<countries>
    <country iso="ch" start="76.00" stop="108.00" spacing="100"/>
    <country iso="eu" start="87.00" stop="108.00" spacing="100"/>
    <country iso="it" start="87.00" stop="108.00" spacing="50"/>
    <country iso="jp" start="76.00" stop="90.00" spacing="100"/>
    <country iso="us" start="87.50" stop="108.00" spacing="200"/>
    <country iso="xx" start="76.00" stop="108.00" spacing="10"/>
</countries>

Configuration Response

You will receive a response in the form of XML, notifying the result of each configuration command...

  • example 1 [all success]
<result-list>
  <result command="station" status="success"/>
  <result command="power" status="success"/>
</result-list>


  • example 2 [partial success, partial failure]
<result-list>
  <result command="station" status="failure"/>
  <result command="power" status="success"/>
</result-list>

Note that you will only receive a result for commands you have sent in the query string.