Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Data-Management-Honka
Diff: BluetoothComm.h
- Revision:
- 3:14050370593a
- Parent:
- 2:be605799793f
- Child:
- 8:57d988783b45
--- a/BluetoothComm.h Wed Dec 17 21:46:45 2014 +0000 +++ b/BluetoothComm.h Fri Feb 06 20:45:47 2015 +0000 @@ -1,45 +1,68 @@ -#include "mbed.h" -#include "MODSERIAL.h" -//#include "init.h" +#ifndef BLUETOOTHCOMM_H +#define BLUETOOTHCOMM_H #include <map> #include <string> +#include "mbed.h" +#include "MODSERIAL.h" +/** +* @file BluetoothComm.h +* @brief This header file describes BluetoothComm, an object that receives and processes messages through Bluetooth. +* @author Michael Ling +* @date 2/4/2015 +*/ class BluetoothComm { public: BluetoothComm(PinName pwm, PinName dirpin); - void readDataFromSD(); - void readParamsFromSD(); + void read_data_from_sd(); + void read_params_from_sd(); bool parity(short c); - char* checkSum(char* b, int len); - void sendError(char errCode); - void setCharge(short level); - void setValues(std::map<string, short> newValues); - void writeParamsToSDCard(); - void writeDataToSDCard(); + char* get_checksum(char* b, int len); + void send_error(char errCode); + //void setCharge(short level); + void set_values(std::map<string, short> newValues); + void write_params_to_sd_card(); + void write_data_to_sd_card(); void send(char* cmd); - void sendValues(char* paramList); - void sendReadOnlyValues(); - bool msgCheck(char* msg, int len); - void processReadOnly(char* message, int len); - void processRead(char* message, int len); - void processWrite(char* message, int len); + void send_values(char* paramList); + void send_read_only_values(); + bool msg_check(char* msg, int len); + void process_read_only(char* message, int len); + void process_read(char* message, int len); + void process_write(char* message, int len); void process(char* message, int len); void attachment(); int main(); + private: - MODSERIAL rn42; // serial object to read data coming in + MODSERIAL _rn42; // serial object to read data coming in //Map containing values of Exo parameters - std::map<std::string, short> paramMap; + std::map<std::string, short> _paramMap; //Maps parameter indices to param names - std::string indexMap[50]; + std::string _indexMap[50]; //Last received MSG - char msg[50]; + char _msg[50]; //Value of Exo parameters, stored locally - char localValues[50]; - char curMsg[50]; + // _localValues[50]; + char _curMsg[50]; + int _numVars; + //Last sent command + char _lastCmd[50]; + int _failures; + //Readonly Parameters + int _numReadOnlyParams; + short _readOnlyParams[12]; + //Indices where an escape char. is needed + int _escapeNeeded[9]; + int _escapesNeeded; + int _len; + int _counter; + bool _inMsg; + int _data; + //START/END bytes, parameter indices static const char START = 0xff; static const char END = 0xfe; @@ -65,10 +88,10 @@ static const char EXTEND_IND = 0x13; static const char LOCK_IND = 0x14; static const char RATE_IND = 0x15; - int numVars; - //Last sent command - char lastCmd[50]; - int failures; + + //Indicates a readonly request + static const char READONLY_IND = 0x1f; + //Error codes static const char START_ERR = 1; static const char END_ERR = 2; @@ -77,16 +100,6 @@ static const char VAR_ERR = 5; static const char DATA_ERR = 6; static const char RW_ERR = 7; - //Readonly Parameters - int numReadOnlyParams; - short readOnlyParams[12]; - //Indices where an escape char. is needed - int escapeNeeded[9]; - int escapesNeeded; - //Indicates a readonly request - static const char READONLY_IND = 0x1f; - int len; - int counter; - bool inMsg; - int data; -}; \ No newline at end of file + +}; +#endif