bmsd/mysql.h

Sun, 05 Jan 2020 17:04:56 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 05 Jan 2020 17:04:56 +0100
changeset 579
1253a237b620
parent 567
6bf0afc33e70
child 680
0bb48333d133
permissions
-rw-r--r--

Added check for database changes for iSpindels such as a new beer, or changing mode. Added denity in Plato and SG to the iSpindel web screen. The iSpindels must be calibrated in Plato! A bit of documentation updated.

/**
 * @file mysql.h
 */
#ifndef _MYSQL_H
#define _MYSQL_H


/**
 * @brief Connect to the MySQL server and select the database. All parameters must be
 *        set in the $HOME/.bms/bms.conf file.
 * @return 0 if success, any other value if the connection failed.
 */
int  bms_mysql_init(void);

/**
 * @brief Close MySQL connection and free resources.
 */
void bms_mysql_end(void);

/**
 * @brief Send query to the MySQL server with one reconnect attempt.
 * @param query The SQL query to send.
 * @return Return 0 if no error, else the error code.
 */
int bms_mysql_query(const char *query);

/**
 * @brief Ping MySQL connection and try to reconnect if the connection is broken.
 */
void bms_mysql_ping(void);

void node_mysql_insert(sys_node_list *node);
void node_mysql_update(sys_node_list *node);
void node_mysql_death(char *node);

void fermenter_mysql_insert(sys_fermenter_list *fermenter);
void fermenter_mysql_update(sys_fermenter_list *fermenter);
void fermenter_mysql_death(char *node, char *alias);

void co2meter_mysql_insert(sys_co2meter_list *co2meter);
void co2meter_mysql_update(sys_co2meter_list *co2meter);
void co2meter_mysql_death(char *node, char *alias);

void ispindel_mysql_insert(sys_ispindel_list *ispindel);
void ispindel_mysql_update(sys_ispindel_list *ispindel);
void ispindel_mysql_death(char *alias);

/**
 * @brief Check state changes in the database for all iSpindels and
 *        update the internal memory array. Called every 5 seconds from
 *        the main server thread.
 */
void ispindel_mysql_check(void);


#endif

mercurial