Library for my home monitoring classes and serial communication protocol. It monitors temperature and movement on the mbed application board.
Communication/Communication.h@2:84432add9142, 2013-09-03 (annotated)
- Committer:
- groletter
- Date:
- Tue Sep 03 20:24:12 2013 +0000
- Revision:
- 2:84432add9142
- Parent:
- 0:3f846fc933a2
Added class documentation. Not sure how to do this for pure C code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
groletter | 0:3f846fc933a2 | 1 | #ifndef HOME_MON_COMM_H |
groletter | 0:3f846fc933a2 | 2 | #define HOME_MON_COMM_H |
groletter | 0:3f846fc933a2 | 3 | |
groletter | 0:3f846fc933a2 | 4 | #include "USBHomeMon.h" |
groletter | 0:3f846fc933a2 | 5 | #include <stdio.h> |
groletter | 0:3f846fc933a2 | 6 | #include <vector> |
groletter | 0:3f846fc933a2 | 7 | |
groletter | 2:84432add9142 | 8 | /** Function to send an alert to the host |
groletter | 2:84432add9142 | 9 | * |
groletter | 2:84432add9142 | 10 | * @param alert - enum of different allowed alert types |
groletter | 2:84432add9142 | 11 | * @param return - pass or fail based on ack from host |
groletter | 2:84432add9142 | 12 | */ |
groletter | 0:3f846fc933a2 | 13 | bool send_alert(alert_type alert); |
groletter | 2:84432add9142 | 14 | /** Function to wait for an ack from the host. |
groletter | 2:84432add9142 | 15 | * |
groletter | 2:84432add9142 | 16 | * @param return - true if host acked, false otherwise |
groletter | 2:84432add9142 | 17 | */ |
groletter | 0:3f846fc933a2 | 18 | bool host_wait(); |
groletter | 2:84432add9142 | 19 | /** Function to check if host is alive |
groletter | 2:84432add9142 | 20 | * |
groletter | 2:84432add9142 | 21 | * Checks to see if there is any data on the serial port. If so, |
groletter | 2:84432add9142 | 22 | * checks command to see if it is a "connect". |
groletter | 2:84432add9142 | 23 | * |
groletter | 2:84432add9142 | 24 | * @param return - true if host sent connect message, false otherwise |
groletter | 2:84432add9142 | 25 | */ |
groletter | 0:3f846fc933a2 | 26 | bool check_connection(); |
groletter | 2:84432add9142 | 27 | /** Function to get character over serial interface |
groletter | 2:84432add9142 | 28 | * |
groletter | 2:84432add9142 | 29 | * @param return - character received over serial interface |
groletter | 2:84432add9142 | 30 | */ |
groletter | 0:3f846fc933a2 | 31 | char rec_command() ; |
groletter | 2:84432add9142 | 32 | /** Function to send multiple data samples to the host |
groletter | 2:84432add9142 | 33 | * |
groletter | 2:84432add9142 | 34 | * @param samples - vector of strings representing an array of values to be sent to host |
groletter | 2:84432add9142 | 35 | * @param return - true if host properly received data, false otherwise |
groletter | 2:84432add9142 | 36 | */ |
groletter | 0:3f846fc933a2 | 37 | bool send_samples(std::vector<std::string> samples); |
groletter | 2:84432add9142 | 38 | /** Function to receive one sample from the host |
groletter | 2:84432add9142 | 39 | * |
groletter | 2:84432add9142 | 40 | * @param return - one sample value as a double |
groletter | 2:84432add9142 | 41 | */ |
groletter | 0:3f846fc933a2 | 42 | double get_sample(void); |
groletter | 2:84432add9142 | 43 | /** Function to parse messages from the host. It takes the |
groletter | 2:84432add9142 | 44 | * motion and temperature class references to be able to set and get values. |
groletter | 2:84432add9142 | 45 | * |
groletter | 2:84432add9142 | 46 | * @param temp - reference to temperature object |
groletter | 2:84432add9142 | 47 | * @param motion - reference to motion object storing motion db, thresholds, etc. |
groletter | 2:84432add9142 | 48 | */ |
groletter | 0:3f846fc933a2 | 49 | void host_command_resp(msg_type msg, Temperature &temp, Motion &motion); |
groletter | 2:84432add9142 | 50 | /** Function to parse the actual character received over serial interface |
groletter | 2:84432add9142 | 51 | * do error checking and if okay passes it on to host_command_resp() method |
groletter | 2:84432add9142 | 52 | * |
groletter | 2:84432add9142 | 53 | * @param msg - Character message received from the host |
groletter | 2:84432add9142 | 54 | */ |
groletter | 0:3f846fc933a2 | 55 | msg_type parse_msg(char msg) ; |
groletter | 0:3f846fc933a2 | 56 | |
groletter | 0:3f846fc933a2 | 57 | #endif |