Instrument Neutral Distributed Interface INDI 2.2.5
mbox.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3
4 INDI MBox Driver
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#pragma once
26
27#include "indiweather.h"
28
29class MBox : public INDI::Weather
30{
31 public:
32 MBox();
33
34 // Generic indi device entries
35 virtual bool Handshake() override;
36 virtual const char *getDefaultName() override;
37
38 virtual bool initProperties() override;
39 virtual bool updateProperties() override;
40 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
41 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
42
43 protected:
44 virtual IPState updateWeather() override;
45
46 private:
47 typedef enum { ACK_OK_STARTUP, ACK_OK_INIT, ACK_ERROR } AckResponse;
48 typedef enum { CAL_PRESSURE, CAL_TEMPERATURE, CAL_HUMIDITY } CalibrationType;
49 enum
50 {
51 SENSOR_PRESSURE = 2,
52 SENSOR_TEMPERATURE = 6,
53 SENSOR_HUMIDITY = 10,
54 SENSOR_DEW = 14,
55 FIRMWARE = 17,
56 };
57
58 AckResponse ack();
59
60 bool verifyCRC(const char *response);
61 bool getCalibration(bool sendCommand = true);
62 bool setCalibration(CalibrationType type);
63 bool resetCalibration();
64
65 std::vector<std::string> split(const std::string &input, const std::string &regex);
66
67 INDI::PropertyNumber CalibrationNP {3};
68
69 INDI::PropertySwitch ResetSP {1};
70
71 INDI::PropertyText FirmwareTP {1};
72
73
74
75};
Definition mbox.h:30
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
Definition mbox.cpp:135
MBox()
Definition mbox.cpp:42
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition mbox.cpp:87
virtual bool Handshake() override
perform handshake with device to check communication
Definition mbox.cpp:107
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition mbox.cpp:52
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition mbox.cpp:288
virtual const char * getDefaultName() override
Definition mbox.cpp:47
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition mbox.cpp:249
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint16_t type
Definition pwc-ioctl.h:0