Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rlab server class prototype
class Response {
public:
unsigned int status = 1; // 0 for success, other values for error codes
string payload; // the data to be transmitted, could be empty
}
/**
* This class implements the logic server side
* Should be instantiated in arduino and call runCommand(sensor_input)
*/
class Server {
public:
int counting, milisecondsPassed, current;
/**
* This is the constructor. It receives arduino control flags by reference
*/
Server(int &countingA, int &milisecondsPassedA, double &currentA){
counting = countingA;
milisecondsPassed = miliseconedsPassedA;
current = currentA;
}
/**
* This method receives a nibble and retuns a method
*
* Something like:
* switch(command):
* case 1:
* return getData();
* case F:
* return stopCount();
*/
Response runCommand(unsigned int command : 4){ // no idea on how to do this but this method should receive a nibble
}
private:
/**
* Returns sensor data
* 0001
*/
Response getStatus(){
}
/**
* Returns the current status of the count.
* 0010
*/
Response getCount(){
}
/**
* Starts a countdown from 300 seconds
* 0011
*/
Response startCount(){
}
/**
* Pauses counting
* 0100
*/
Response pauseCount(){
}
/**
* Resumes counting
* 0101
*/
Response continueCount(){
}
/**
* Stops counting
* 0110
*/
Response stopCount(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment