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
BluetoothComm.h
- Committer:
- mzling
- Date:
- 2015-02-06
- Revision:
- 3:14050370593a
- Parent:
- 2:be605799793f
- Child:
- 8:57d988783b45
File content as of revision 3:14050370593a:
#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 read_data_from_sd(); void read_params_from_sd(); bool parity(short c); 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 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 //Map containing values of Exo parameters std::map<std::string, short> _paramMap; //Maps parameter indices to param names std::string _indexMap[50]; //Last received MSG char _msg[50]; //Value of Exo parameters, stored locally // _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; static const char KPSTANCE_IND = 0x0; static const char KPSWING_IND = 0x1; static const char KPSTAND_IND = 0x2; static const char KPSIT_IND = 0x3; static const char KPUP_IND = 0x4; static const char KPDOWN_IND = 0x5; static const char KDSTANCE_IND = 0x6; static const char KDSWING_IND = 0x7; static const char KDSTAND_IND = 0x8; static const char KDSIT_IND = 0x9; static const char KDUP_IND = 0xa; static const char KDDOWN_IND = 0xb; static const char STAND_IND = 0xc; static const char SIT_IND = 0xd; static const char BENT_IND = 0xe; static const char FORWARD_IND = 0xf; static const char REAR_IND = 0x10; static const char IMU_IND = 0x11; static const char RETRACT_IND = 0x12; static const char EXTEND_IND = 0x13; static const char LOCK_IND = 0x14; static const char RATE_IND = 0x15; //Indicates a readonly request static const char READONLY_IND = 0x1f; //Error codes static const char START_ERR = 1; static const char END_ERR = 2; static const char PARITY_ERR = 3; static const char CHECKSUM_ERR = 4; static const char VAR_ERR = 5; static const char DATA_ERR = 6; static const char RW_ERR = 7; }; #endif