thermferm/mqtt.h

Thu, 02 May 2024 15:49:16 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 02 May 2024 15:49:16 +0200
changeset 716
5c30c8ef83a8
parent 689
f94b525f7563
permissions
-rw-r--r--

Version 0.9.19b3. The simulator thread can be paused to be able to add and delete simulators. Added simulated door and PSU status. Devices can now fully use multiple simulators. Better rounding of simulated temperature values. The server SIMULATOR DEL and ADD commands pause the simulator when the linked list is manipulated. Fixed SIGSEGV when a simulator is added. Added socket SO_REUSEADDR again to the server socket.

#ifndef	_MQTT_H
#define	_MQTT_H


#define STATUS_CONNECTING 0
#define STATUS_CONNACK_RECVD 1
#define STATUS_WAITING 2

#ifndef HAVE_WIRINGPI_H

// Pi model types and version numbers
//      Intended for the GPIO program Use at your own risk.

#define PI_MODEL_A               0
#define PI_MODEL_B               1
#define PI_MODEL_AP              2
#define PI_MODEL_BP              3
#define PI_MODEL_2               4
#define PI_ALPHA                 5
#define PI_MODEL_CM              6
#define PI_MODEL_07              7
#define PI_MODEL_3B              8
#define PI_MODEL_ZERO            9
#define PI_MODEL_CM3            10
#define PI_MODEL_ZERO_W         12
#define PI_MODEL_3BP            13
#define PI_MODEL_3AP            14
#define PI_MODEL_CM3P           16

#define PI_VERSION_1            0
#define PI_VERSION_1_1          1
#define PI_VERSION_1_2          2
#define PI_VERSION_2            3

#define PI_MAKER_SONY           0
#define PI_MAKER_EGOMAN         1
#define PI_MAKER_EMBEST         2
#define PI_MAKER_UNKNOWN        3


#endif


/*
 * Public functions
 */
void pub_domoticz_temp(int, int);
void pub_domoticz_output(int, int);
void mqtt_connect(void);
void mqtt_disconnect(void);

char *global_json(void);
char *unit_data(units_list *unit, bool birth);

/**
 * @brief Publish DBIRTH for all active units. If there are no active units, don't
 *        publish anything. This function should be called at program start.
 */
void publishDBirthAll(void);

/**
 * @brief Publish unit data.
 * @param unit Unit data structure.
 */
void publishDData(units_list *unit);

/**
 * @brief Publish unit birth.
 * @param unit Unit data structure.
 */
void publishDBirth(units_list *unit);

/**
 * @brief Publish death of a unit.
 * @param unit Unit data structure.
 */
void publishDDeath(units_list *unit);

/**
 * @brief Publish log data.
 * @param unit Unit data structure.
 */
void publishDLog(units_list *unit);

/**
 * @brief Publish Node data or birth message.
 * @param birth If true send a birh message, else a regular data update.
 * @param flag Bit flag to enable control messages.
 */
void publishNData(bool birth, int flag);


#endif

mercurial