-
Notifications
You must be signed in to change notification settings - Fork 0
/
astroberry-mqtt.h
56 lines (48 loc) · 2.26 KB
/
astroberry-mqtt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
Copyright(c) 2021 Radek Kaczorek <rkaczorek AT gmail DOT com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*******************************************************************************/
#pragma once
#include <libindi/baseclient.h>
class mqttClient : public INDI::BaseClient
{
public:
mqttClient();
~mqttClient() = default;
protected:
void newDevice(INDI::BaseDevice *dp) override;
void removeDevice(INDI::BaseDevice */*dp*/) override {}
void newProperty(INDI::Property *property) override;
void removeProperty(INDI::Property */*property*/) override {}
void newSwitch(ISwitchVectorProperty *svp) override;
void newNumber(INumberVectorProperty *nvp) override;
void newText(ITextVectorProperty *tvp) override;
void newLight(ILightVectorProperty *lvp) override;
void newBLOB(IBLOB */*dp*/) override {}
void newMessage(INDI::BaseDevice *dp, int messageID) override;
void serverConnected() override {}
void serverDisconnected(int /*exit_code*/) override {}
private:
char* getDeviceType(uint16_t deviceType);
};
struct mosquitto *mosq = NULL;
char *mqtt_root_topic = NULL;
char mqtt_clientid[32] = {};
void handleSignal(int s);
void mqttConnectCallback(struct mosquitto *mosq, void *obj, int result);
void mqttDisconnectCallback(struct mosquitto *mosq, void *obj, int result);
void mqttSubscribeCallback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos);
void mqttMsgCallback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message);
void mqttPublish(char* topic, char* msg);