telecomando per VDR via ethernet con Arduino.
L'idea di usarlo come telecomando in se è abbastanza inutile, ma nell'ottica di un'integrazione domotica invece secondo me ha senso (es. pulsanti per regolare il volume incassati vicino all'interruttore per accendere la luce quando si usa VDR come fonte audio per la diffusione sonora in tutta la casa)
hardware necessario:
- Arduino 2009
- ethernet shield per Arduino
software:
- vdr con svdrphost.conf che lasci accedere dall'IP impostato per il client realizzato con arduino
Per ora ho fatto solo un test molto semplice, giusto per testare il funzionamento del protocollo:
- mi connetto a VDR tramite SVDRP
- invio il comando per fare scrivere il messaggio CIAO con l'OSD sulla TV
- mi disconnetto da VDR
Come base ho utilizzato lo sketch per il telnet client, così modificato:
Codice: Seleziona tutto
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 97); // IP di Arduino
IPAddress gateway(192, 168, 1, 1);
// Enter the IP address of the server you're connecting to:
IPAddress server(192, 168, 1, 98); // IP della VDR BOX
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 23 is default for telnet;
// if you're using Processing's ChatServer, use port 10002):
EthernetClient client;
void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip, gateway);
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");
// if you get a connection, report back via serial:
// porta 2001: SVDRP
if (client.connect(server, 2001)) {
Serial.println("connected");
client.println("MESG CIAO");
client.println("QUIT");
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// as long as there are bytes in the serial queue,
// read them and send them out the socket if it's open:
while (Serial.available() > 0) {
char inChar = Serial.read();
if (client.connected()) {
client.print(inChar);
}
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
// do nothing:
while(true);
}
}
Codice: Seleziona tutto
connecting...
connected
220 mediacenter SVDRP VideoDiskRecorder 1.7.22; Mon Oct 15 15:00:59 2012; UTF-8
250 Message queued
221 mediacenter closing connection
disconnecting.
Alle prossime evoluzioni