In this case, the protocol name is SAMSUNG, the length of the command code
is 32 bits, and the command code is E0E040BF (the hexadecimal number we
grabbed in
Grabbing Remote Control Codes, on page
We already used the Arduino as a web client in
Arduino, on page
163, but now we need to turn it into a web server. The server
waits for new HTTP requests like the one shown previously, parses the URL,
and emits the corresponding infrared signal.
We ll hide all of these details in a class named
as easy and as concise as possible, we ll make use of both the Ethernet and
the IRremote library. The
sophisticated examples of Arduino code. Here s its interface:
RemoteControl/InfraredProxy/infrared_proxy.h
#include <SPI.h>
#include <Ethernet.h>
#include <IRremote.h>
class
InfraredProxy {
private:
IRsend _infrared_sender;
void
read_line(EthernetClient& client, char* buffer,
bool send_ir_data(const
bool
handle_command(char* line);
public:
void
receive_from_server(EthernetServer server);
};
After including all libraries needed, we declare the
a member variable named
to emit infrared control codes. Then we declare three private helper methods
and the
receive_from_server
InfraredProxy
class.
Let s have a look at the implementation of all methods. We ll start with
InfraredProxy
InfraredProxy
class is still one of the book s most
char* protocol,
const int
_infrared_sender
that stores an
method, which is the only public method of the
www.it-ebooks.info
Building an Infrared Proxy
203).
Chapter 10, Networking with
, and to keep things
const int
buffer_length);
bits,
const long
value);
InfraredProxy
class. We define
IRsend
object we need
read_line
217
:
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?