Instrument Neutral Distributed Interface INDI  1.9.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 
29 class 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  INumber CalibrationN[3];
68  INumberVectorProperty CalibrationNP;
69 
70  ISwitch ResetS[1];
71  ISwitchVectorProperty ResetSP;
72 
73  IText FirmwareT[1] {};
74  ITextVectorProperty FirmwareTP;
75 
76 
77 
78 };
MBox::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: mbox.cpp:84
MBox::updateWeather
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
Definition: mbox.cpp:132
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
INumber
One number descriptor.
MBox::MBox
MBox()
Definition: mbox.cpp:42
INDI::Weather
Definition: indiweather.h:68
MBox::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: mbox.cpp:285
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
type
__le16 type
Definition: pwc-ioctl.h:2
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
MBox::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: mbox.cpp:246
IText
One text descriptor.
MBox::getDefaultName
virtual const char * getDefaultName() override
Definition: mbox.cpp:47
MBox::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: mbox.cpp:52
MBox::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: mbox.cpp:104
name
const char * name
Definition: indiserver.c:116
MBox
Definition: mbox.h:29
ISState
ISState
Switch state.
Definition: indiapi.h:148
indiweather.h
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365