10#include "../inc/database.h"
12PyObject *pName, *pModule, *pDict;
13PyObject *pFuncSend_notification_flag, *pFuncGet_live_flag, *pFuncGet_swing_flag, *pFuncSend_temp_hum, *pFuncSend_swing_flag,*pResult;
19 pResult = PyObject_CallFunction(pFuncSend_temp_hum,
"ff", temp, hum);
35 pResult = PyObject_CallFunction(pFuncGet_swing_flag, NULL);
44 int aux = (int)PyLong_AsLong(pResult);
50 printf(
"ERROR GETTING FLAG");
63 pResult = PyObject_CallFunction(pFuncGet_live_flag, NULL);
73 int aux = (int)PyLong_AsLong(pResult);
79 printf(
"ERROR GETTING FLAG");
92 pResult = PyObject_CallFunction(pFuncSend_notification_flag,
"i", notification_flag);
108 pResult = PyObject_CallFunction(pFuncSend_swing_flag,
"i", swing_flag);
123 pName = PyUnicode_FromString((
char*)
"database");
126 pModule = PyImport_Import(pName);
130 printf(
"No module with that name");
135 pDict = PyModule_GetDict(pModule);
140 pFuncSend_notification_flag = PyDict_GetItemString(pDict, (
char*)
"send_notification_flag");
143 if (!PyCallable_Check(pFuncSend_notification_flag))
149 pFuncSend_temp_hum = PyDict_GetItemString(pDict, (
char*)
"send_temp_hum");
152 if (!PyCallable_Check(pFuncSend_temp_hum))
158 pFuncGet_live_flag = PyDict_GetItemString(pDict, (
char*)
"get_live_flag");
161 if (!PyCallable_Check(pFuncGet_live_flag))
167 pFuncGet_swing_flag = PyDict_GetItemString(pDict, (
char*)
"get_swing_flag");
170 if (!PyCallable_Check(pFuncGet_swing_flag))
176 pFuncSend_swing_flag = PyDict_GetItemString(pDict, (
char*)
"send_swing_flag");
179 if (!PyCallable_Check(pFuncSend_swing_flag))
int send_swing_flag(int swing_flag)
Update swing flag in database.
int send_notification_flag(int notification_flag)
Update notification flag in database.
int send_temp_hum(float temp, float hum)
Update temperature and humidity in database.
int initDatabase()
Initializes all the functions.
int get_swing_flag()
Get the swing flag from database.
int get_live_flag()
Get the live flag from database.