The IrcBot class can connect to a channel on an IRC network. Users on the same network can send messages to the bot that are parsed by message handlers. The included handlers read digital/analog inputs and write digital outputs or echo messages back to the command sender/channel. Users can write their own message handlers inheriting from the MessageHandler class to perform different actions.

Revision:
2:e4c74eb20586
Parent:
1:cf586c9bbb52
--- a/IrcMessageHandlers.h	Sat Aug 02 12:17:28 2014 +0000
+++ b/IrcMessageHandlers.h	Sat Aug 02 12:57:57 2014 +0000
@@ -2,9 +2,16 @@
 #define __mbed_irc_handlers_h__
 #include "IrcBot.h"
 
+///  DigitalOutHandler lets users control a DigitalOut using "WRITE <name> ON/OFF"
 class DigitalOutHandler : private MessageHandler {
     public:
-        DigitalOutHandler(char *, PinName, bool);
+        /** Create a DigitalOutHandler
+         * @param name Name of output used in command on IRC
+         * @param pin Pin the output is connected to.
+         * @param verbose Whether or not a reply is sent to IRC confirming the output state
+         */
+        DigitalOutHandler(char * name, PinName pin, bool verbose);
+        /// Set output pin on or off, reply "SET <name> ON/OFF" if verbose.
         IrcMessage handle(IrcMessage);
     private:
         DigitalOut pin;
@@ -12,19 +19,35 @@
         bool verbose;
 };
 
+///  DigitalInHandler lets users read a DigitalIn using "READ <name>"
 class DigitalInHandler : private MessageHandler {
     public:
-        DigitalInHandler(char *, PinName);
+        /** Create a DigitalInHandler
+         * @param name Name of input used in command on IRC
+         * @param pin Pin the input is connected to.
+         */
+        DigitalInHandler(char * name, PinName pin);
+        /// Reply "<name> IS ON/OFF"
         IrcMessage handle(IrcMessage);
     private:
         DigitalIn pin;
         char name[32];
 };
 
+///  AnalogInHandler lets users read a DigitalIn using "READ <name>"
 class AnalogInHandler : private MessageHandler {
     public:
-        AnalogInHandler(char *, PinName);
-        void scale(float, char *);
+        /** Create an AnalogInHandler
+         * @param name Name of input used in command on IRC
+         * @param pin Pin the input is connected to.
+         */
+        AnalogInHandler(char * name, PinName pin);
+        /** Define a scaling factor for the measured value [0.0 - 1.0]
+         * @param scale The scaling factor
+         * @param unit The units used in the message to IRC
+         */
+        void scale(float scale, char * unit);
+        /// Measure input, scale and reply "<name> = <value> <units>"
         IrcMessage handle(IrcMessage);
     private:
         AnalogIn pin;
@@ -33,9 +56,11 @@
         float scaleval;
 };
 
+/// A handler to echo back any messages of the form "ECHO <x>"
 class EchoHandler : private MessageHandler {
     public:
         EchoHandler(){};
+        /// Reply to "ECHO <x>" with "<x>"
         IrcMessage handle(IrcMessage msg);
 };