Bert Gereels / Mbed 2 deprecated ProjectOne

Dependencies:   C12832 LM75B mbed EthernetInterface mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers slave.h Source File

slave.h

00001 #pragma once
00002 
00003 #include "mbed.h"
00004 #include "temperature.h"
00005 #include "buzzer_music.h"
00006 #include "lcd.h"
00007 #include "rgb.h"
00008 #include "potentiometer.h"
00009 
00010 namespace ProjectOne{
00011     
00012     class Slave{
00013         public:
00014             /*
00015             * Constructor for Slave class.
00016             *
00017             @param The id for the slave that is selected on boot.
00018             @param Pointer to temperature class object.
00019             @param Pointer to potentiometer class object.
00020             @param Pointer to lcd class object.
00021             @param Pointer to rgb class object.
00022             @param Pointer to buzzermusic class object.
00023             @return Nothing.
00024             */
00025             Slave(int slave_id, Temperature *temperature, Potentiometer *potentiometer, LCD *lcd, RGB *rgb, BuzzerMusic *buzzerMusic);
00026             
00027             /*
00028             * Method that contains the slave state-machine.
00029             * Waits for incoming UDP packets from master.
00030             * Determines what type of command is received.
00031             * Executes method according to received command.
00032             * Sends acknowledgement back to the master.
00033             *
00034             @param Nothing.
00035             @return Nothing.
00036             */
00037             void handleIncomingFrame(void);
00038             
00039         private:
00040             enum slaveStates{
00041                 STATE_INIT,
00042                 STATE_WAIT_FOR_FRAME,
00043                 STATE_HANDLE_FRAME,
00044                 STATE_HANDLE_REQUEST,
00045                 STATE_SEND_ACKNOWLEDGEMENT
00046             };
00047             
00048             slaveStates CurrentSlaveState;
00049 
00050             const static char *MASK;
00051             const static char *GATEWAY;
00052         
00053             int slaveId;
00054             
00055             Temperature *slaveTemp;
00056             Potentiometer *slavePot;
00057             LCD *slaveLcd;
00058             RGB *slaveRgb;
00059             BuzzerMusic *slaveBuzzerMusic;
00060             
00061             char ip_address[14];
00062             char *command_info[3];
00063             
00064             float temperatureValue;
00065             float potentiometerValue;
00066             string response;
00067         
00068     };
00069     
00070 };