Custom Channel Plan version of MTDOT Box firmware

Dependencies:   DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-Custom mDot_Channel_Plans

Fork of MTDOT-BOX-EVB-Factory-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Mode.h Source File

Mode.h

00001 /* Copyright (c) <2016> <MultiTech Systems>, MIT License
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
00004  * and associated documentation files (the "Software"), to deal in the Software without restriction, 
00005  * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
00006  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
00007  * furnished to do so, subject to the following conditions:
00008  *
00009  * The above copyright notice and this permission notice shall be included in all copies or 
00010  * substantial portions of the Software.
00011  *
00012  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
00013  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00014  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00015  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00016  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017  */
00018 
00019 #ifndef __MODE_H__
00020 #define __MODE_H__
00021 
00022 #include "DOGS102.h"
00023 #include "ButtonHandler.h"
00024 #include "mDot.h"
00025 #include "LoRaHandler.h"
00026 #include "GPSPARSER.h"
00027 #include "SensorHandler.h"
00028 #include "ISL29011.h"
00029 #include "MMA845x.h"
00030 #include "MPL3115A2.h"
00031 #include "FileName.h"
00032 
00033 class Mode {
00034     public:
00035         typedef enum {
00036             single = 0,
00037             sweep
00038         } DataType;
00039 
00040         typedef struct {
00041             DataType type;
00042             int32_t index;
00043             bool status;
00044         bool gps_lock;
00045             int32_t gps_sats;
00046             GPSPARSER::longitude gps_longitude;
00047             GPSPARSER::latitude gps_latitude;
00048             int16_t gps_altitude;
00049             struct tm gps_time;
00050             LoRaHandler::LoRaLink link;
00051             uint8_t data_rate;
00052             uint32_t power;
00053         } DataItem;
00054 
00055         typedef struct {
00056             MMA845x_DATA accel_data;
00057             MPL3115A2_DATA baro_data;
00058             uint16_t lux_data_raw;
00059             uint32_t pressure_raw;
00060             float light;
00061             float pressure;
00062             float altitude;
00063             float temperature;          
00064         } SensorItem;       
00065 
00066         Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors);
00067         ~Mode();
00068 
00069         virtual bool start() = 0;
00070 
00071     protected:
00072         bool deleteDataFile();
00073         bool appendDataFile(const DataItem& data);
00074         void updateData(DataItem& data, DataType type, bool status);
00075         void updateSensorData(SensorItem& data);
00076         uint32_t getIndex(DataType type);
00077 
00078         std::vector<uint8_t> formatSurveyData(DataItem& data);
00079         std::vector<uint8_t> formatSensorData(SensorItem& data);
00080 
00081         DOGS102* _lcd;
00082         ButtonHandler* _buttons;
00083         mDot* _dot;
00084         LoRaHandler* _lora;
00085     GPSPARSER* _gps;
00086     SensorHandler* _sensors;
00087         osThreadId _main_id;
00088         uint32_t _index;
00089         uint8_t _band;
00090         uint8_t _sub_band;
00091         int8_t _data_rate;
00092         uint32_t _power;
00093         uint32_t _next_tx;
00094         ButtonHandler::ButtonEvent _be;
00095         LoRaHandler::LoRaStatus _ls;
00096         LoRaHandler::LoRaLink _link_check_result;
00097         uint8_t _state;
00098         bool _send_data;
00099     bool _gps_available;
00100     uint8_t _initial_data_rate;
00101     uint8_t _initial_power;
00102 };
00103 
00104 #endif