Pour une meilleur compréhension de mon problème, voici mon programme Arduino :
// variable pour l'ethernet
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 192,168,1,36 };
byte Ethernet::buffer[500];
BufferFiller bfill;
RCSwitch mySwitch = RCSwitch(); //Création d'un objet pour l'éméteur RF
IRsend irsend;
#define RAWBUF 100
unsigned int tvOnOff[51] = {3900,3950,500,2000,400,2050,450,2000,400,2050,400,1050,450,1000,450,2000,450,1000,500,1950,500,1000,450,2000,450,1000,450,1000,500,1000,450,1000,450,1000,500,1950,500,1950,500,1000,450,2000,450,1000,450,2000,450,1000,500,1950,500};
unsigned int tvchp[51] = {3950,3950,500,1950,500,1950,500,1950,500,1950,500,1000,450,1000,500,1950,500,950,450,2000,450,2000,450,1000,500,1950,500,1000,400,1050,450,1000,450,1000,450,2050,450,2000,450,1000,500,1950,450,1000,450,1000,500,1950,500,1000,450};
unsigned int tvchm[51] = {3900,4000,500,1950,450,2000,500,1950,500,1950,450,1000,500,950,500,2000,450,1000,450,2000,450,2000,450,1000,500,1000,500,950,450,1000,500,950,500,1000,450,2000,500,1950,450,1000,500,1950,450,1000,450,1050,400,2050,450,2000,450};
unsigned int tvmute[51] = {3900,4000,400,2050,450,2000,400,2050,450,2000,450,1000,500,1000,400,2000,400,2050,500,1950,450,2000,500,1950,500,1950,500,1000,450,1000,450,1000,450,1050,450,2000,450,2000,450,1000,500,950,450,1000,550,950,450,1000,500,1000,400};
unsigned int tvsource[51] = {3900,4000,450,2000,500,1950,500,1950,500,1950,500,1950,450,1000,450,2000,450,1000,500,950,500,1000,500,1950,450,2000,500,950,450,1000,500,950,500,1000,450,1000,450,2000,500,950,500,1950,500,1950,500,1950,500,1000,450,1000,450};
unsigned int tvok[51] = {3900,4000,500,1950,450,2000,450,2000,450,2000,450,2000,450,2000,450,2000,450,2000,450,1050,400,2050,400,1050,450,1000,450,1050,400,1050,450,1000,450,1050,400,1050,450,1000,450,1000,450,1050,400,2050,400,1050,450,2000,450,2000,450};
unsigned int tv1[51] = {3950,3950,500,1950,500,1950,500,1950,500,1950,500,1000,450,1000,450,2000,450,2000,500,950,450,1000,500,1000,450,2000,450,1000,500,950,450,1000,500,1000,450,2000,450,2000,450,1000,450,1000,500,1950,500,1950,500,1950,500,1000,450};
unsigned int tv2[51] = {3900,4000,450,2000,500,1950,500,1950,500,1950,450,1000,500,1000,450,2000,450,2000,400,1050,450,1000,450,2000,450,1050,400,1050,450,1000,450,1000,450,1050,450,2000,450,2000,450,1000,450,1000,450,2000,450,2050,400,1050,450,2000,400};
unsigned int tv3[51] = {3900,4000,500,1950,500,1950,500,1950,500,1950,500,950,500,1000,500,1950,500,1950,500,950,450,1000,500,1950,500,1950,550,900,500,1000,500,950,450,1000,500,1950,450,2000,500,1000,500,950,450,2000,450,2000,550,900,500,1000,500};
int RVB_R = 10;
int RVB_G = 9;
int RVB_B = 6;
int temps = 0;
void setup () {
pinMode(RVB_R, OUTPUT);
pinMode(RVB_G, OUTPUT);
pinMode(RVB_B, OUTPUT);
Serial.begin(9600);
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) //verification du module ethernet
Serial.println( "Failed to access Ethernet controller");
ether.staticSetup(myip);
mySwitch.enableTransmit(5);
mySwitch.setRepeatTransmit(5);
RGB(0,255,0);
temps=millis();
}
static word homePage() {
bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"<title>Domoduino</title>"));
return bfill.position();
}
void loop () {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(strstr((char *)Ethernet::buffer + pos, "GET /?priseOn") != 0) { // PRISE RF ON
signal();
mySwitch.send(983232, 24);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?priseOff") != 0) { // PRISE RF OFF
signal();
mySwitch.send(983040, 24);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?vol-") != 0) { //AMPLI +
signal();
irsend.sendNEC(0xa55ad02f, 32);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?vol+") != 0) { //AMPLI -
signal();
irsend.sendNEC(0xa55a50af, 32);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?volmute") != 0) { //AMPLI MUTE
signal();
irsend.sendNEC(0xa55a48b7, 32);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?tvon") != 0) { //TV-ON/OFF
signal();
irsend.sendRaw(tvOnOff,51,38);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?tvmute") != 0) { // TV MUTE
signal();
irsend.sendRaw(tvmute, 51, 38);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?tvsource") != 0) { // TV SOURCE
signal();
irsend.sendRaw(tvsource, 51, 38);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?ch+") != 0) { // TV CH+
signal();
irsend.sendRaw(tvchp, 51, 38);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?ch-") != 0) { // TV CH-
signal();
irsend.sendRaw(tvchm, 51, 38);
}
/*if(strstr((char *)Ethernet::buffer + pos, "GET /?tv1") != 0) { // TV 1
RGB(255,0,255);
irsend.sendRaw(tv1, 51, 32);
}
/*if(strstr((char *)Ethernet::buffer + pos, "GET /?tv2") != 0) { // TV 2
signal();
irsend.sendRaw(tv2, 51, 38);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /?tv3") != 0) { // TV 3
signal();
irsend.sendRaw(tv3, 51, 38);
}*/
if (pos){
envoiePage();}
if (millis()-temps > 500){
RGB(0,0,0);
}
}
void RGB(int rouge, int vert, int bleu){
analogWrite(RVB_R, rouge);
analogWrite(RVB_G, vert);
analogWrite(RVB_B, bleu);
}
void signal(){
RGB(0,0,255);
temps = millis();
}
void envoi(unsigned int*a){
irsend.sendRaw(a, 51, 38);
}
void envoiePage(){
ether.httpServerReply(homePage()); // send web page data
}
Pour ajouter de nouveaux signaux IR, j'agis directement sur le programme que je télévise après.
Et pour l'enregistrement les signaux Raw, ils sont aussi dans le programme Arduino.