FM radio API

From Chumby Wiki
Revision as of 17:24, 6 December 2009 by Scross (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

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
. To get debugging information, you need to first convince the controlpanel that chumbradiod is actually running. To do this, run
echo 1 > /var/services/chumbradiod/pids
, and then just run
chumbradiod
.

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. You probably want this to be very low.
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=usa
http://ip:8081/radio/configure?country=japan
http://ip:8081/radio/configure?country=china
  • 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

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.