Samstag, 4. Mai 2013

Orientierungshilfe

English version below

Es gibt zwei Versionen dieses Blogs. Die deutsche Version beginnt am 1. Januar 2013. Die englische Version startet am 01.Februar 2013.

Zur deutschen Version => hier klicken 
Zur englischen Version => hier klicken

01.01.2013  Heute soll es losgehen oder der WAF  (anzeigen)
02.01.2013  Was Dynamo Dresden mit dem Projekt zu tun hat  (anzeigen)
03.01.2013  Die RadioCard spielt die Musik  (anzeigen)
04.01.2013  Die Eingeweide des Duinosqueeze  (anzeigen)
05.01.2013  Der RFID-Karte auf den Zahn gefühlt  (anzeigen)
06.01.2013  Das Platinenlayout von ID:789  (anzeigen)
07.01.2013  So sieht die RadioCard von innen aus  (anzeigen)
08.01.2013  Software-Settings und die DeviceCard  (anzeigen)
09.01.2013  Die DeviceCard sendet eine Nachricht  (anzeigen)
10.01.2013  Die RadioCard als "Stationstaste"  (anzeigen)
11.01.2013  Die CDCard und die Playlist für Squeezebox  (anzeigen)
12.01.2013  Eine neue DeviceCard wird hinzugefügt (anzeigen)
-----------------------------------------------------------------------------------------------------------------------


There are two different version in this blog. The german version starts on the 1st of January 2013, and the english version starts on the 1st of February 2013.

Go to the german version by clicking here.
Go to the english version by clicking here

01.02.2013 Off we go or the WAF  (show)
02.02.2013  What the German football Club 'Dynamo Dresden' has to do with the project.  (show)
03.02.2013  The RadioCard plays the music  (show)
04.02.2013  The guts of the Duinosqueeze  (show)
05.02.2013  Sound the RFID-card out  (show)
06.02.2013  The PCB-layout of the ID:789  (show)
07.02.2013  Inside the RadioCard  (show)
08.02.2013  Software Settings and the DeviceCard  (show)
09.02.2013  The DeviceCard sends a message (show)
10.02.2013  The RadioCard as a 'Station Button' (show)
11.02.2013  The CDCard and the playlists for Squeezeboxes (show)
12.02.2013  A new DeviceCard is added (show)

Dienstag, 12. Februar 2013

12. A new DeviceCard is added.

A kind people gave me an iPhone, which is an elderly Version. The App iPeng makes it a fully-flegdes Squeezedevice. This Device we want to add to the Squeezeduino-Software.

I wondered a long time, why my deviceCard does not work with my iPhone. The german Squeezeforum - especially pippin - helped me troubleshooting my problems. At this point sincere thanks is given to all.

You should note the following fact: The description below does only work, if the in iPeng choosen device is the master!!! That means, the name of the device is displayed at the top of the screen. See the following pcture:



1. Step: The iPhone gets its name
We have to give a name to the iPhone, because we want to receive a conformation that the datastream ist reroutet to the iPhone. I will call my device SB-iPhone.


2. Step: The 2-dimensional array is adapted
The 2-dimensional array in the program has to be adapted and should look like the lines below. The blue types mark the changes:

//**2-dimensionales Array der Namen der Squeeezegeräte-Namen
char namSbox[8][18]={             // von 7 nach 8 verändert
{"SB-Classic%2001"},
{"SB-Classic%2002"},
{"SB-Touch"},
{"SB-Touch%20PC"},
{"SB-Touch%20Mac"},
{"SB-Classic%20PC"},
{"SB-iPod"},
{"SB-iPhone"} };                  // hinzugefügt


3. Step: The Mac-Adress of the iPhone
Wir need the Mac-adress of the iPhone. You can find this under settings - General - About - Wi-Fi Adress. My Mac-Adress is: 64:B9:E8:28:23:9A, and now we enter this:

//**2-dimensionales Array für alle Mac-Adressen
byte macAdrSbox[8][6]={
{0x00,0x04,0x20,0x12,0xde,0x14},
{0x00,0x04,0x20,0x12,0xdc,0x55},
{0x00,0x04,0x20,0x23,0x72,0x16},
{0x00,0x15,0xaf,0xb8,0xac,0x25},
{0x00,0x26,0xbb,0x0b,0x59,0x2d},
{0xe3,0xf8,0xd4,0xd8,0xae,0xce},
{0x00,0x24,0x36,0x89,0xc4,0x87},
{0x64,0xB9,0xE8,0x28,0x23,0x9A} };


4.Step: The Intergration of the DeviceCard
I always have some RFID-Cards in stock, of which the the UID/PZ already readout. I choose the card with the number 62-222-174-209-159 and intergrate it into the software:

//**2-dimensionales Array für alle Squeezeboxen (Gerätekarten)
const uchar Squeezebox[8][5]= {
  {110,190,163,209,162},
  {222,225,153,209,119},
  {30,211,170,209,182},
  {94,111,152,209,120},
  {158,29,168,209,250},
  {222,91,164,209,240},
  {142,72,165,209,178},
  {62,222,174,209,159}   };

That was it? No in the progarm something has to be changed.


5. Step:One more change of the program
There is a while-loop that samples the UID/PZ of all kown DeviceCards. The loop-counter has to be changed from '7' to '8'.

 while( i<8)            // es werden 8 DeviceCards überprüft
{
  if (memcmp(Squeezebox[i],serNum,5)==0) //Wenn eine DeviceCard gefunden wurde
  {
    memcpy(namTmp,namSbox[i],18);        // Der Name der SBox wird in eine temporäre Variable geschrieben


6. Step: Updating the software
you should know how to do, therefore no comment :-)


7. Step: Testing the new DeviceCard
Please note, the softwared oes not interpret the repeatedly placing of the same card. That means, if you want to test the new device card twice or more you have to place a different  card in between.

If everything is done properly, the following message is shown on the SB-iPhone after you place the new deviceCard on your reader






So far for today .. the planned video is still in process.

Montag, 11. Februar 2013

11. The CDCard - and the playlists for Squeezeboxes

When I started the first experiments in this project, the ultimate target consisted of a quick access to the music of my CD's. That it has evolved in this way, I was not aware. So let us turn to the CDCard .

Actually, the theoretical side clear: we need an advanced playlist in m3u format.. How has the look basically, we saw yesterday. So basically there are no problems. No problems? Most of the playlists of other programs are not expanded - they do not work. So I adapted a working method for me. I would imagine at this point for all those who struggle with the playlist just like me.

I assume that ripping a CD is very well known to almost everyone. FYI: I rib with Audiograbber. The files are then in mp3 format in a dedicated CD folder.

I received this week from my heating oil suppliers a CD "Après Ski Classics" gift that will serve me now as an example. When grabbing can Audiograbber also create a playlist m3u . Which looks like this - simply poor:  

01 - Tim Toupet - Du hast die Haare schön-1.mp3
02 - K2 - Der Berg ruft (Remix 2000).mp3
03 - Olaf Henning - Cowboy & Indianer (komm hol das Lasso raus).mp3
04 - Jürgen Drews - König an der Schneebar.mp3
05 - The BossHoss - Hey Ya!.mp3
06 - Peter Wackel - Après Ski.mp3
07 - Helmut Aus Mallorca - Der alte Holzmichel.mp3
08 - A-Teens - Gimme! Gimme! Gimme!.mp3
09 - Scooter - The Question is what is the Question.mp3
10 - Didi Diesel - I bin der Champ.mp3
11 - Henning & Holm - Maddalena 2001 (Du Luder).mp3
12 - Bata Illic - Michaela.mp3
13 - Sonthofen Allstars - Alles Wunderbar.mp3
14 - Cascada - Everytime we touch.mp3
15 - Hermes House Band - I will Survive (Radio Edit).mp3



This is definitely not the extended format! The LMS will roar with laughter! WE can do this in a better way.. Therefore we need the best editing program for MP3's for me - MP3Tag . At the time of this blog with the version 2.54. The RFID card is already identified and has the UID/CS 78-12-179-209-32. I have now added a new field to the ID3 tags: RFID-Karte (RFID-card).

MP3Tag with the new fields EAN code and RFID-Card


We need this field later in the export yet. MP3Tag in there under File - Export the ability to describe an export file. My export is called of course Squeezebox-Playlist (what else). The syntax is:  

$filename(U:\playlists\%RFID_CARD%.m3u,utf-8)
#CURTRACK 0
#EXTM3U$loop(%track%)
#EXTURL:file:///volume1/music/$cutLeft($replace(%_path%,\,/, ,'%20'),3)
#EXTINF:%_length_seconds%,%title%
/volume1/music/$cutLeft($replace(%_path%,\,/),3)$loopend()


We definitely have not MP3Tag as a focus, take it as it is and create yourselves your own export. During the export the following window will be displayed. It is important, that the file name is entered as shown in the picture on the left. Then the program automatically retrieves the RFID number from the ID3 tag. If  we now press OK we get THE playlist we need and already saved in the correct folder. Wow! The playlist now has the following content:

#CURTRACK 0
#EXTM3U
#EXTURL:file:///volume1/music/Pop/Sampler/Après%20Ski%20Classics/01%20-%20Tim%20Toupet%20-%20Du%20hast%20die%20Haare%20schön.mp3
#EXTINF:223,Du hast die Haare schön
/volume1/music/Pop/Sampler/Après Ski Classics/01 - Tim Toupet - Du hast die Haare schön.mp3
#EXTURL:file:///volume1/music/Pop/Sampler/Après%20Ski%20Classics/02%20-%20K2%20-%20Der%20Berg%20ruft%20(Remix%202000).mp3
#EXTINF:236,Der Berg ruft (Remix 2000)
/volume1/music/Pop/Sampler/Après Ski Classics/02 - K2 - Der Berg ruft (Remix 2000).mp3
...
etc,

This looks definitely more like an extended playlist - and it works . Here it is in the directory playlist with all the otherplaylists.




Does it work?? No! An error message is spreading. Not these error now!!

"Problem: File cannot be opened for:"

This is certainly an error in the playlist script. I noticed it immediately.

#EXTURL:file:///volume1/music/Pop/Sampler/Après%20Ski%20Classics/01%20-%20Tim%20Toupet%20-%20Du%20hast%20die%20Haare%20schön.mp3

The first track includes a German special characters. And the LMS does not like special characters. The "ö" makes trouble! For this english version of the script this fact is not really important, but there are people from other countries with special characters.

In the script the following line

#EXTURL:file:///volume1/music/$cutLeft($replace(%_path%,\,/,,'% 20'),3)

a "\" is replaced by a "/" and a " " by a "20%" , is changed as follows:
#EXTURL:file:///volume1/music/$cutLeft($replace(%_path%,\,/, ,'%20',ä,%C3%A4,ö,%C3%B6,ü,%C3%BC),3) 

The error message has gone! Should such an error messages appear you have to search in this environment first!

The RFID card is now hidden in the CD cover and can not be seen from outside.




I did that with all my CD's: Ripping - storing in the database - preparing the RID-card - creating the playlist and storing them - CDCard hiding in the CD covers. DONE!   With over 300 CD's not a work for one day - that lasts! :-) But the result is always a pleasure.

I had thought at the beginning that it will last a whil to find a specific playlist in this crowd. The opposite is the case! Because the contents are sorted in a special directory, everything is serially numbered! Bother to write the UID and CS on the Card. The troubleshooting is much easier.

We walk slowly to the finish line. How a PlaylistCard is built, you should not have, according to the reading of the last blogs, any difficulties. I leave this to you!

Next time we want to see the DuinoSqueeze  in action. Video? Let's wait and see. It will definitely take some time.


Sonntag, 10. Februar 2013

10. The RadioCard as a "Station button"

Sometimes it's annoying to select his favorite station. Admittedly favorites help a lot. So we're back to the WAF (see blog dated 01/01/13). Navigating, probably  through a large directory tree (because everything is sorted so beautiful :-) ), is sometimes more than a nuisance. Here comes the RadioCard into the breach. Put a RadioCard on the desk and and your favourite radiostation starts playing.

Let's have a look at the SW part. Upon testing the RFID-Card that no DeviceCard is present, it must be one of those cards, for which playlist has been deposited in a special directory.

if (deviceCard == 0)                 // If it is not a DeviceCard, the playliste can be called
{

  Serial.println("DeviceCard ist 0");
  // dsplRFID(macAdrTmp);            // may be activated by using an Arduino Mega
  playPlaylist(macAdrTmp);


That's it and and we can go to the subroutine (now we take the temporary MAC address with us). Here the subroutine in its full splendor:

void playPlaylist(byte* macAdrTmp)
{
snprintf(SBox, 150, "GET /status?p0=playlist&p1=resume&p2=%d-%d-%d-%d-%d&player=%02x:%02x:%02x:%02x:%02x:%02x HTTP/1.1", serNum[0], serNum[1], serNum[2], serNum[3], serNum[4], macAdrTmp[0], macAdrTmp[1], macAdrTmp[2], macAdrTmp[3], macAdrTmp[4], macAdrTmp[5]);
  Serial.println(SBox);
  client.stop();
  Serial.println();
  Serial.println("client stopped");
  client.connect(server,9002);
  delay(1000);
  Serial.println(F("connecting..."));
  if (client.connected())
    {
      Serial.println(F("connected"));
      while (client.available())
      {
        char c = client.read();
      }
    Serial.println(SBox);
    client.println(SBox); //Squeezeplay
    client.println();
    Serial.println(F("abgesetzt"));
    }
   
  else
    {
    Serial.println(F("connection failed"));
    }
    Serial.println(F("Serverdaten lesen"));

  if (!client.connected())
    {
    Serial.println();
    Serial.println(F("disconnecting."));
    client.stop();
    }

}


That which here is sent to the server, is probably familiar only the transmitted parameters are different.

Now the following string will be sent (for example)
? GET / status p0=playlist & p1=resume & p2=254-122-179-209-230 & player=00:15:af:b8:ac:25 HTTP/1.1


Short explanation:
p0=playlist means, that a playlist should be played
p1=resume means that a current playlist will be canceled and will be replaced by the playlist decribed under
p2= filename of the playlist without extension

The playlist with the filname under p2 has to exist with the extension  .m3u in a dirctory that is defindes in the LMS. On this place the hyphens between the UID values ​​are generated. The command playlist knows a lot more parameters. Here again we refer to the Command Line Interface (CLI). See yesterday (9.). On the server there is a directory music / playlists  where the playlist 254-122-179-209-230.m3u   "lives" with the content:

#EXTM3U
http://opml.radiotime.com/Tune.ashx?id=s96815&formats=aac,ogg,mp3,wmpro&partnerId=16&serial=158f087abcf88503358ccf826d66a5b0

Here we deal with an extended M3U-playlist. This is a quote from German-Wiki translated into english language (http://de.wikipedia.org/wiki/M3U).

The first line # EXTM3U is the introduction of the head data and specifies the format of M3U's. In extended M3U''s you always find the first line # EXTM3U is  in use. The first line is followed by the actual content of the M3U . Each media  listed in the M3U-file consits two lines:
  • The 1st Line always begins with # EXTINF: , followed by the length of the media file in whole seconds. After the length of a comma is used as a separator, followed by the name of the media file, which is used for display in the media player. If the length specified is less than the actual length, as in PLS format the specified length is not observed. (Putting the length to -1, it is also not considered.)
  • The 2nd Line is identical to the specification of simple M3U's. Here is the full file name listed with absolute or relative path or URL to a specified file on a Webserver.
So we start to tinker a play list for the friends of WDR4 (german radio, not my favourite) . A new RFID card will simply read with the Arduino Serial Monitor that is open. There the command in its complete form shown:
GET / status p0 = playlist & p1 = p2 = & resume?
238-8-172-209-155 & player = 00:15: af: b8: ac: 25 HTTP/1.1
So must the name of the playlist must be: 238-8-172-209-155.m3u . Therefore we need a blank document, which we generate an editor. Into this document we write we write the both first lines:

  #EXTM3U
  #EXTINF: -1,


Now we need the link to the external stream. There are links with and without station logo. The best link is still generated by the LMS. For this purpose we are looking for the radio station WDR4 at the Squeezedevice Radio and add the station to the Favorites. If we now go into the LMS and there select the Home - Favorites. Click and select WDR4.  Click. Now you can see the following picture:




We paste the link from the clipboard into our document. Finally, at 238-8-172-209-155.m3u folder music / playlists /  save and READY! After placing the RadioCard on the Duinosqueeze it shows the SqueezePlay player with the following screen:



Next time it comes to the CDCard . We look at how the playlists can be generated quickly from the music-database.


Samstag, 9. Februar 2013

9. The DeviceCard sends a message


Today we take a look at the code snippet, which is responsible for the message shown in the blog yesterday. I had already mentioned that before a CDCard   or RadioCard can be processed, it must be ensured that the detcted RFID-card is no DeviceCard. The result of the check is stored in the variable boolean device card = 0 . The variable we had yesterday in the Squeezebox settings. The following code can be find in the void loop (void)

// ****** This block checks whether the card is a card devices.

i = 0;

while (i <7) {
   if (memcmp (Squeezebox [i], SerNum , 5) == 0) // check if device card for SB3 01
...


Here is a classic comparison of two memory locations (memory compare). Squeezebox [i] is read from the 2-dimensional array in which all UID / CS, are included. SerNum has been defined with 5 bytes. The result of the comparison must be zero. If the result is zero, the beginning preparations for displaying the message start.

For Squeezebox fans: I can recommend at this point the information about the Command Line Interpreter (CLI). To find: Help> Technical Information> command line interface of the LMS. The Help button is on the bottom left on the entrance side of the Logitech Media Server. 


We require the following character string:

"GET / status display & p0 = p1 = p2 = & <Nachricht1.Zeile> <Nachricht second line> & p3 = <duration in seconds> & player? = <player's MAC address> HTTP/1.0 "


Let#s start building the message
memcpy (namTmp, namSbox [i], 18); the name of the SB is stored in a temporary variable. So after the next iteration of the loop the name of the squeeze-device is known as well
memcpy (macAdrTmp, macAdrSbox [i], 6), 

same to the Mac address.

Now we have all the things we need for displaying.all there is, what do I need to vernünftgen ads. So I call the subroutine

dsplMsgSB() .

Thus it is clear that we will find ourselves in a subroutine, the code is written in blue letters.

dsplMsgSB void () {


Now we need to urgently deal with the parameters p1, p2 and player.
p1 = RFID-Steuerung%%20wurde%% 20erfolgreich%% 20nach  (the%%20are the spaces between between two words. We use double%% because the single %-character is used otherwise)
english version: 
p1 = The%%20RFID-controlling%%20has%%20been%%29rerouted 

p2 =%s%% 20umgeleitet (%s is the variable namTmp)
english version:
p2 = to%%20%s%%20sucessfully
 
player = 02x%:% 02x:% 02x:% 02x :% 02x:.% 02x (02x in place of the% number is entered after a variable So macAdrTmp [0] , macAdrTmp [1], macAdrTmp [2], ... etc to macAdrTmp [5]

We write now in an orderly manner in a designated memory area.
snprintf(SBox, 150, "GET /status?p0=display&p1=RFID-Steuerung%%20wurde%%20erfolgreich%%20nach&p2=%s%%20umgeleitet&p3=10&player=%02x:%02x:%02x:%02x:%02x:%02x HTTP/1.0",
namTmp, macAdrTmp[0], macAdrTmp[1], macAdrTmp[2], macAdrTmp[3], macAdrTmp[4], macAdrTmp[5]);

Everything in "" is being followed in the 150 bytes variable named SBox saved The rest is easy. Connect to the server and send the message placed in SBox

client.connect (server, 9002);  
if (client.connected ())  
  {    
  while (client.available())
   {      
    char c = client.read ();
       }  
  client.println (SBox);
 
  client.println ();
  }  
else
  {    
  Serial.println (F ("connection failed"));
  }  
client.stop ();
}

... and now returning to the main-program! !

device card = 1;

Serial.println ("Device Card is 1") // for testing
break;  

 i++; 
}

The variable deviceCard will be set to true (1) and ready. With deviceCard =1 the subsequent rest of this programpart will not be executed.

What if the card remains lying on the reader? SBox is sent again and again - if not checked at each iteration if a new (other) UID/CS exists. If this is not the case, everthing what is decribed above will not be executed.
if (memcmp (data, SerNum, 5) = 0!)    {
   memcpy (SerNum, data, 5),

The first loop pass is SerNum is empty and the comparison will be  != 0. After that the received data (data)  will be copied to serNum. The next loop cycle you find data == serNum , that means everything is skipped. This applies to the Device Card as well as for the RadioCard or CDCard .  

Finally, a little exercise: On the  display the message   "Best regards from Duckburg, Dagobert" should appear for 30 seconds.
The MacAddress is  00:15:AF: AC:B8:25 . Since we "only" have a constant message the line  

snprintf(SBox, 150, "GET /status?p0=display&p1=Best%%20regards%%20from&p2=Duckburg,%%20Dagobert&p3=30&player=00:15:af:b8:ac:25 HTTP/1.0");

  ... and that looks on a Squeezebox Touch in german language like this:



Unimagined possibilities are opening up now. With an Arduino and an Ethernet shield you can display any system messages on on your Squeeze-device. Who likes listening to loud music and gets a visitor at the door the display says  "There is the bell ringing!". The possibilities are unlimited, thanks to the disclosure of the interface. This can also be seen in the many add-ons that are available for the LMS. Next time, we turn to the radio card. This is really simple.

Freitag, 8. Februar 2013

8. Software Settings and the Device Card

The software is downloadable at Google.code. Here is the


The software is a functional version that need to be adjusted in some respects to your own needs. If you have problems, dicovered errors or improvements you should  drop me a line.

The general query of a RFID-card is very simple because of the downloadable Adafruit-Sketch (link already blogged).Now let's have a lokk to the controlling of Squeezedevices and the cooperation with the Logitech Media Server = LMS (formerly SqueezeCenter).

Fundamentals
All media devices of the Squeezegroup need for playing music content the support of a server. This is either the server on the internet (mysqueezbox.com) or as in my case, the LMS that runs on a device in the home network. individual devices have a server in the internal software (Squeezebox Touch).

I consider only the LMS variant in the local network . The most commonly used mode of operation is likely the individual control.


Individual Controlling of Squeeze-devices

Each player will be individually controlled by the LMS. To keep its individuality, is required for an RFID-control in the network, to tell the server to which device  the following command(s) are intended. This message to the LMS, which target device is desired, takes over the DeviceCard  .

If there is a single control system, there must be a group control system. Via the setup of the Squeeze-devices you can form individual groups or switch all devices logically together. The group formation can not be made ​​with this software!   Unfortunately there is not enough capacity in the memory of the Arduino.  



Group Controlling of Squeeze-devices

All actions on a device within a group affect every other out in the same way! I like calling the group-controlling as Party Mode. In all rooms the same music!

Once all devices run into control group, it is irrelevant which device is passed to the data stream. It affects all devices anyway. So you can save the DeviceCard.

The software:
I describe the SW in that substantial parts that are project-specific

// ***** Squeezebox-Settings *****
uchar serNum[5]; // Serial Number of the RFID-Card 
char namTmp[20]="SB%20Touch PC";  // device-name with default
char SBox[150]; // character arry for the message to the server
boolean deviceCard = 0; // Flag, if DeviceCard
 

In this part memory areas for specific content are reserved . I do not work with strings, because of the uncontrolled assignment of memoryspace. On my place that led me to the fact, that sometimes the sketch aborted. So I switched with the help of the German forum to the char-array. Now the locations shown above are "filled" targeted.


// + + + + + + + + + + + + + + + + + + + + + + + + + + + For information + + + + + + + + + + + + + + + + + + + + + + + + + + + +
/**** devices card IDs under which the devices are accessed ****
* const uchar Squeezebox01 [5] = {110,190,163,209,162} // = Squeezebox1 SBClassic livingroom

* const uchar Squeezebox02 [5] = {222,225,153,209,119} // = Squeezebox2 SBClassic kitchen
*
const uchar Squeezebox03 [5] = {30,211,170,209,182} // = Squeezebox3 SBTouch
*
const uchar SqueezeplayPC [5] = {94,111,152,209,120} // = Squeezebox4 SBTouch PC (Squeezeplay)
* const uchar SqueezeplayMAC [5] = {158,29,168,209,250
} // = Squeezebox5 SBTouchMAC (Squeezeplay)
* const uchar SoftsqueezePC [5] = {222,91,164,209,240} // = Squeezebox6 SBClassic PC (Softsqueeze)
* const uchar iPengIPOD [5] = {142,72,165,209,178} // = Squeezebox7 SBiPeng (iPOD) */



In this area, all the UID/CS for the Squeeze-devices are listed informative. You can delete, if you want.
 


//**2-dimensional array for alle Squeezeboxes (Devicecards)
const uchar Squeezebox[7][5]= {
  {110,190,163,209,162},
  {222,225,153,209,119},
  {30,211,170,209,182},
  {94,111,152,209,120},
  {158,29,168,209,250},
  {222,91,164,209,240},
  {142,72,165,209,178}   };


There is a request in the program, where is checked the if detected Card is a DeviceCard. For this purpose, all the UID of the DeviceCards has to be known.

//**2-dimensional  array for alle Mac-adresses
byte macAdrSbox[7][6]={
{0x00,0x04,0x20,0x12,0xde,0x14},
{0x00,0x04,0x20,0x12,0xdc,0x55},
{0x00,0x04,0x20,0x23,0x72,0x16},
{0x00,0x04,0x20,0xb8,0xac,0x25},
{0x00,0x04,0x20,0x0b,0x59,0x2d},
{0x00,0x04,0x20,0xd8,0xae,0xce},
{0x00,0x04,0x20,0x89,0xc4,0x87} };

 

The command to the Logitech Media Server contains the target address of the selected Squeezebox. This address must be set up in the software. Therefore there is always a default adress selected. That is the reason why I always choose a default-Squeezebox.

// +++++++++++++++++++++++++ Einstellen des aktuellen Default-Wertes ++++++++++++++++++++++++
//byte macAdrTmp[6]= {0x00,0x04,0x20,0x12,0xde,0x14}; //default SBClassic Wohnzimmer
//byte macAdrTmp[6]= {0x00,0x04,0x20,0x12,0xdc,0x55}; //default SBClassic Küche
byte macAdrTmp[6]= {0x00,0x04,0x20,0x23,0x72,0x16}; //default SBTouch
//byte macAdrTmp[6]= {0x00,0x15,0xaf,0xb8,0xac,0x25}; //default SBTouch PC (Squeezeplay)
//byte macAdrTmp[6]= {0x00,0x04,0x20,0x23,0x72,0x16}; //default SBTouch MAC (Squeezeplay)
//byte macAdrTmp[6]= {0x00,0x04,0x20,0x23,0x72,0x16}; //default SBClassic PC (Softsqueeze)
//byte macAdrTmp[6]= {0x00,0x04,0x20,0x23,0x72,0x16}; //default SBiPeng (iPod)

 

So is it easier, I've listed all possibilities in advance , from which I choose one. For my tests, the test was very helpful.
 

/ / ** 2-dimensional array of the names of Squeeezegeräte name
/ / this can not exceed 18 characters! Otherwise change!

char namSbox[7][18]={
  {"SB-Classic%20(WZ)"},
  {"SB-Classic%20(KU)"},
  {"SB-Touch"},
  {"SB-Touch%20PC"},
  {"SB-Touch%20Mac"},
  {"SB-Classic%20PC"},
  {"SB-iPeng%20iPOD"}   };



If the stream was diverted to another Squeezebox device, a message is generated for the new device, the data stream it f was diverted olgreich. How this is done I will show you later.


Message on SB-Touch PC :
"RFID Controlling has been rerouted to SB-Touch PC sucessfully"

Message on SB Classic PC:
"RFID Controlling has been rerouted to SB-Classic PC sucessfully"


The pictures show the software versions of the SB Touch and the SB Classic. Next time we have a look onto the code snippet, which is responsible for this message.

Donnerstag, 7. Februar 2013

7. Inside the RadioCard

Now I've wired my board. As you can see, it was really no big deal. Not pretty, but functional. For additional plug the hole grid is perfect to use.





Unfortunately, blurred















Now quickly connected to the Arduino and let's go for the first test. I have previously downloaded the files from github and put the files in the folder C: \ arduino \ arduino-1.0.3 \ libraries . I want to show me a hex dump of the 1K memory on the card. Therefore I loaded the sketch mifareclassic_memdump.pde to the Arduino. Our RadioCard placed near the RFID-board and already the Arduino starts working!

My RFID board lives!
The Serial Monitor shows the following result:


This looks very good! All HEX values ​​:-( . But I was longing for decimal numbers. But step by step. My Mifare S50 card has a 1K memory and is divided into 16 sectors (0-15) Each sector. has 4 blocks of 16 bytes (0-15). If we calculate:


16 sectors * 4 blocks * 16 bytes = 1024 bytes = 1KByte
In the picture above I only displayed the first four sectors, the remaining 12 blocks look the same - promised! The sector "0" is a special one. it containes the block "0", which belongs to the manufacturer. The first four bytes of the UID (here: FE 48 98 D1) followed by the checksum (here: FF). This is exactly the information that needs to be tinkered it to my playlist number. If I convert the hex values ​​FF FE 48 98 D1 to decimal values, I get:

 
254 72 152 209 255  ... and that is very familiar to me! The Radio Card !


Mittwoch, 6. Februar 2013

6. The PCB layout of ID: 789

The previous day, I left with a reference to the .brd file. The .brd file has nothing to do with the Bunderepublik Deutschland but shows the layout of the board. Here's an overview:


Copyright Adafruit

Along with the .sch file you can find all the relevant points on the board. The .brd file includes all components, names, even those that are not printed on the shield. I summarized all major components and platinum points in the following image.


In general I can say: There are enough ways available to connect the board to whatever. It is well recognized that many inputs and outputs are not used, but only because to make the board stackable. For those who use the board as a shield , it's really plug 'n play. But those who wants "outsource" the shield -like me- it would be necessary to deal with the pinout.

On the photo it looks like you have four solder points to connect ground (Gnd). Really four? Let's have a look at the layout. Wow! Only one single platinum point is possible to use. That's exactly what I said yesterday: A look at the layout is worth it!

Short explanation to the yellow boxes:
Q1 = level converter SDA
Q2 = level converter SCL
Q3 = level converter SCK
Q4 = level converter RSTP
FSR = Voltage regulator 5V/3.3V
IRQ = Connected to an LED, showing the status of the interrupt (IRQ)  

The green lines represent the two lines SDA and SCL They can be picked up at five different points:  
SDA: Top left 2x (SDA), MOSI (separate power strip), and the bottom right 2x (Analog In 4)
SCL: Top right 2x (SCL), SS (SPI socket) and the bottom right 2x (Analog In 5)  

The yellow lines are the points that I will connect to a 5-pin male header.

Next, it the blog goes on with the " Wiring" and the first test run.

<= one step back                                                                                             go ahead =>

Dienstag, 5. Februar 2013

5. Sound the RFID-card out

And so I have bought the following RFID-card : Adafruit ID:789. As it should be, I first checked out what is available for it at Adafruit. In this moment I'm only interested in hardware-informations.  In the data specifications you can find several tabs. Let's have a look one after another:

Tab "Description"
Here you can find descriptions and valuable information on the structure of the board. Those who intend to use the SPI interfacesghoul read those informations. In short: Reading required  

Tab "Technical Details"
Only showing the size specification is IMHO definitely a little poor. I had always expected data on power consumption in different states. What voltages are / can be used? Sorry, no answers.  

Tab "Tutorials"

  • Very good additional information about RFID. Here I was able to find more in-depth data of the RFID card, which I will use. I use Mifare S50 Classic - cards. In that document there is more to find. Really worth reading!
  • Since I will not use the function of NFC phones and I have not looked in there ', I can not judging this point.
  • The other information are data sheets and time charts. The data sheets can answer many questions, if you don't know how to go on.I come back again to the data sheets
"Download"
Here I have been led on a false trail. At this point you have to be extremely careful!

The links to the libraries guide us to the required I2C-sketches. I will try them at a later date.

The antenna design is based on the use of the RFID chip from NXP PN532. This one is used on my board. So far ok

It is said that the schematic diagram will follow later, but there is a link that works - and point on the diagram of the breakout boards (ID: 364) ! I have not noticed it right away, and asked me how it is with the power supply and the levels on the inputs and outputs. The data sheet tells me that the max. voltage is 3.6 V. Input and output levels are at 3.3V. The question Is: How can I adjust the voltage? The tutorail shows namely the breakout board with an additional level adjustment. Do I need it? Then I searched the forum at Adafruit and had been successful. In a post dated 11/13/2012 someone asks for a diagram of the NFC Shield. In response, there is a link to github, where there is among others a *.brd and a *.sch file. What the hell I have to/can do with the file? The program associated with this format is called eagle and is available in the Internet for download. During installation, you can choose a free version with limited options (eagle-light). And then I see in the diagram (*.sch file) what I need:



Copyright Adafruit
Both lines the SDA and the SCL have ever used a level shifter. The IRQ line, does not require a level converter, as it is an output of the RFID-board and the input of the Arduino will work properly with this voltage. The same question what to do with the 3.3V supply voltage is cleared by the diagram:


Copyright Adafruit
The Shield has a fixed voltage contrller "onboard". It converts the 5V into the necessary 3.3V.  

Therefore the board has everything my heart desires!

But where is what on the board? This time tomorrow I'll have look at the *. brd file.


Montag, 4. Februar 2013

4. The guts of the DuinoSqueeze

In the overview diagram of yesterday, I listed the required modules. In the following picture you can see them in all its glory.

From the left: The Ethernet Shield, the Arduino Uno and the RFID-card


The Arduino Uno
To this module it is to say the least because this is the best known on the net. I purchased my Uno from China and it works properly me until now. I'm still thinking about whether or not it should give way to a lack of space to a Nano. I would suggest that we decide this at a later date, when the DuinoSqueeze runs.

The Ethernet Shield
As well a board from China. The most famous two Ethernet Shields have either the ENC28J60 or WIZnet W5100 chip installed. I opted for the Wiznet-variant, because it is easier to handle. The Shield will be mounted piggyback on the Arduino. Arduino and the Ethernet-shield operates together via the SPI interface.

The RFID Shield 
I do not intend to use the RFID-reader piggyback, but slightly offset from the other electronics. The reasons are alone in optics. The electronics and the I will hide in the closet somewhere. So definitely an interface is to be used, which allows such a remote operation. There I decided to use the I2C interface. So I need a board / shield which uses this interface. The assortment of shilds with a I2C-Interface is not really abundant. If man / woman still needs a reading distance of at least 5 cm, the antenna size is already playing a major role.   So I ultimately decided on the RFID-board of Adafruit (ID: 789) . The board is delivered already prepared for the I2C interface using the Arduino ports

So as to avoid collisions on the ports between the the shields/boards, you should plan the using of the ports carefully.  
 
The SPI-interface is natively using the following pins:  
MOSI ( M aster O ut / S lave I n) pin D11 (fixed)  
MISO ( M aster I n / S lave O ut) pin D12 (not changeable)

SCK (Slave Clock) pin D13 (fixed)
SS / CS ( S lave S elect or C hip S elect) Pin Dx (changeable)

The I2C interface of the reader consists of:

 
SDA (serial data),
SCL (serial clock)  


In addition to the ports above we use  the IRQ (interrupt). It does not belong to the I2C interface.

The following table shows the proposed pinout:


Dx = Digital I / O, Ax = Analog I / O

Who is interested in more profound information of the  SPI and I2C interface, should have a look at the  this german seminar .

All devices on the I2C bus must have a unique address by which they can be identified and addressed on the bus. It would be important to know what address has the RFID reader. We'll do that later. There are so-called sniffer (sniffer).

Next time we look at the RFID board and have closer look to the inner life. Now you could say "unimportant", but it isn't as unimportant as you think .

Sonntag, 3. Februar 2013

3. The RadioCard plays the music

Today I would like to explain you the intended mode of operation by means of the following diagram:

Overview diagram of the home network for DuinoSqueeze

First I will explain you the sequence of operation which a RadioCard represents. The RadioCard has a UID incl check sum (CS), as we we met short time ago:

254 72 152 209 255

Behind this card hides the Internet Radio Channel  MemoryhitsFM . So here we go

  1. The RFID reader will detect the card and sends the UID as a string 25472152209255 to the Arduino.
  2. The Arduino stores the UID and CS internally as a variable.
  3. The Arduino converts the string 25472152209255 into 254-72-152-209-255 . This string is our desired playlist number (PL-No.)!
  4. The Arduino now has a PL-No, to send it via Ethernet Shield to the music server: Logitech Media Server (formerly SqueezeCenter) . Where is the graph of the Logitech Media Server ? The Logitech Media Server "lives" in my home network to the NAS Synology 409 +. If you google the term Logitech Media Server, surely you will find a free version for Windows or Linux.
  5. The Logitech Media Server (from now on LMS) manages the communication to the connected media players- in the graph, the Squeezebox Touch and Squeezebox Classic (SB3).
  6. LMS checks, whether there is a playlist called 254-72-152-209-255.m3u in the database. Finding the right LMS Playlist, it sends the data stream to one or more players.
This is the simple operation of a RadioCard . The function of a CDCard or PlaylistCard is dealt in principle identical. Only the contents of the playlists are different. That is, when it is used, explained in more details.

In the Playlist 254-72-152-209-255.m3u you see (only) the following text:

#EXTM3U
#EXTINF: -1, - Memory Hits FM, DE
http:// www.surfmusik.de/m3u/memoryhits-fm, 13851.m3u

This playlist is created by me "by hand". For any other internet radio channel, the RadioCard works on the same principle.

This is all, to play the internet music!

In addition, there is a DeviceCard, with, if necessary, you may route the above data stream to other Squeezeboxes.

Samstag, 2. Februar 2013

2. What the German Football Club ‘Dynamo Dresden’ has to do with the project

Dynamo Dresden? Yes! Dynamo Dresden is a German football club. This club ordered every year its annual entrance cards at a Distributer of its confidence. That was the same in the season 2011/2012. The Distributer had printed the RFID-based annual cards. But unfortunately, all the cards were printed incorrectly. Lots of RFID cards, which were waiting for a new assignment. By chance (you also have to get lucky in life) I now could purchase the required number of tickets for a good price. Although the cards were printed, they were technically in a perfect condition. Just as new!



Basically one word to the cards. These cards are no season tickets! The club Dynamo Dresden make them to what they should be. I have only the pure cards! They are personalized at Dynamo Dresden and there the cards get their datas. No unauthorized people can have access to the datas.

The cards do have a memory of 1KByte. Two different passwords are there to protect the contents. Without those keys you do not have any access to the contents. In a "virgin" card that's different. They are equipped with a so-called transport code, that is well known and is "FF FF FF FF FF FF". These transport codes can be overridden with new specific passwords, if required. My application does not need specific security requirements, so I will use the card exclusively with the transport code.

Additionally to the two possible passwords each card has its own "ID", the UID Number (UID = U nique ID entification). This consists of four bytes and a check sum. Since it is stored on a card in binary, it is in its present form not reasonable to use. So either I will use in the UID in HEX numbers or decimal values. I opted for the decimal version. So I have 4 numbers in between the number range of 0-255. Among the four numerical UID values the check value will still join, which also will be read out. Here is an example of an RFID card UID: 254 72 152 209 255 .

Such digits sequences will meet us again in the future.

Freitag, 1. Februar 2013

1. Off we go or the WAF



Today I decided to create a blog of my project. If it works I do not know. The first few days are a test object. They are also used to test the settings of the blog.



Every reader wonders rightly: Why the umpteen-millionth blog. The blog is not for me but for everyone out there who are doing it as well as me. I have (or had) to fight in my project with many uncertainties, of which I would like to preserve the interested reader.



What is this blog about?



Projects always arise when man / woman think anything could be simpler or more beautiful as today. As a music lover I have scattered around my home media player the variety squeezebox-euipment. These are: two classic Squeezebox 3 one Squeezebox Touchtwo Squeezplay on PCs with the operating systems Windows and OSX. Concluding an iPhone and an iPod together with the controller / player iPeng .



This all is easy to handle for me, who set up the whole hardware to use. Only the wife of the home will not operate the squeezeboxes, but listen - and that as simple as possible. This is admittedly not the case, and so the wonderful devices are easily viewed from my wife very suspicious.



To make a long story short: The WAF is, on the open-topped popularity scale, on carpet level (ie at the bottom). The WAF is the W omens- A cceptance- F actor. Apparently the WAF seems to be inversely proportional to the male enthusiasm with technical innovations.



Back to the topic.



Based on this Youtube video https://www.youtube.com/watch?v=m-0Zj8fJz8U   where the documentation was not really to find. I'm aiming to develop my own non-contact control , not only to play all my CD's, but also forall the  internet radio stations,. The basis are small RFID transponders in card form, whose information is read and performs, depending on  the found information, specific activities.



Requirements for the RFID control:

Play all CDs by CDCards

Playing playlists by PlaylistCards

Target selection of streaming through the use of so-called DeviceCards

Direct selection of Internet radio stations by RadioCards



... and the next time the function is illustrated and explained what the German Football Club Dynamo Dresden has to do with my project.