date time fixed
This commit is contained in:
parent
8fa5cae836
commit
612e3b1b93
5
.idea/deployment.xml
generated
5
.idea/deployment.xml
generated
@ -1,14 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="PublishConfigData" serverName="backend" remoteFilesAllowedToDisappearOnAutoupload="false">
|
<component name="PublishConfigData" autoUpload="Always" serverName="backend" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||||
<serverData>
|
<serverData>
|
||||||
<paths name="backend">
|
<paths name="backend">
|
||||||
<serverdata>
|
<serverdata>
|
||||||
<mappings>
|
<mappings>
|
||||||
<mapping deploy="/home/lego/SMARTGARDENING" local="$PROJECT_DIR$/software" web="/" />
|
<mapping deploy="/home/lego/SMARTGARDENING" local="$PROJECT_DIR$" web="/" />
|
||||||
</mappings>
|
</mappings>
|
||||||
</serverdata>
|
</serverdata>
|
||||||
</paths>
|
</paths>
|
||||||
</serverData>
|
</serverData>
|
||||||
|
<option name="myAutoUpload" value="ALWAYS" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
Binary file not shown.
@ -6,7 +6,7 @@ Every function should return json format with the wanted data from the database
|
|||||||
"""
|
"""
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
from plantdatabase import PlantDataBase
|
from plantdatabase import PlantDataBase
|
||||||
from software.defines import Topics, MAX_PLANT_COUNT
|
from defines import Topics, MAX_PLANT_COUNT
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Union
|
from typing import Union
|
||||||
@ -98,6 +98,12 @@ def action_getposition(client: mqtt.Client, userdata, message: mqtt.MQTTMessage,
|
|||||||
def action_getbattery(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
def action_getbattery(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
||||||
client.publish(Topics['ROBOT_ACTION_GETBATTERY'])
|
client.publish(Topics['ROBOT_ACTION_GETBATTERY'])
|
||||||
logging.info("BACKEND_ACTION_GETBATTERY message forwarded to Robot")
|
logging.info("BACKEND_ACTION_GETBATTERY message forwarded to Robot")
|
||||||
|
battery_data = {
|
||||||
|
"Battery": 66,
|
||||||
|
"Timestamp": str(datetime.now())
|
||||||
|
}
|
||||||
|
print(battery_data)
|
||||||
|
client.publish(Topics['BACKEND_DATA_BATTERY'], json.dumps(battery_data))
|
||||||
|
|
||||||
|
|
||||||
def action_getalldata(client: mqtt.Client, userdata, message: Union[mqtt.MQTTMessage, list], mydatabase: PlantDataBase):
|
def action_getalldata(client: mqtt.Client, userdata, message: Union[mqtt.MQTTMessage, list], mydatabase: PlantDataBase):
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
import software.defines
|
import software.backend.defines
|
||||||
from software.defines import MQTT_BROKER_LOCAL
|
from software.backend.defines import MQTT_BROKER_LOCAL
|
||||||
from random import randrange, uniform
|
from random import randrange, uniform
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
from software.defines import Topics, PLANTDATA
|
from software.backend.defines import Topics, PLANTDATA
|
||||||
mqttBroker = software.defines.MQTT_BROKER_GLOBAL
|
mqttBroker = software.backend.defines.MQTT_BROKER_GLOBAL
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
@ -22,10 +22,18 @@ client.on_connect = on_connect
|
|||||||
client.connect(mqttBroker)
|
client.connect(mqttBroker)
|
||||||
|
|
||||||
plantdata = {
|
plantdata = {
|
||||||
"PlantName": "Kemal"
|
"AirTemperature": 1.0,
|
||||||
|
"AirHumidity": 1.0,
|
||||||
|
"SoilMoisture": 1.0,
|
||||||
|
"Brightness": 1,
|
||||||
|
"PlantID": 2,
|
||||||
|
"Timestamp": "",
|
||||||
|
"MeasurementID": 0,
|
||||||
|
"PlantName": "test"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print(type(PLANTDATA))
|
print(type(PLANTDATA))
|
||||||
client.publish("BACKEND/ACTION/GETBATTERY", json.dumps(plantdata))
|
client.publish(Topics['BACKEND_ACTION_NEWPLANT'], json.dumps(plantdata))
|
||||||
print(json.dumps(plantdata))
|
print(json.dumps(plantdata))
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import time
|
import time
|
||||||
from software.defines import Topics
|
from software.backend.defines import Topics
|
||||||
|
from software.backend.defines import MQTT_BROKER_GLOBAL
|
||||||
|
|
||||||
|
|
||||||
def on_message(client, userdata, message):
|
def on_message(client, userdata, message):
|
||||||
@ -14,12 +15,12 @@ def on_connect(client, userdata, flags, rc):
|
|||||||
print("Connection failed")
|
print("Connection failed")
|
||||||
|
|
||||||
|
|
||||||
mqttBroker = "192.168.178.182"
|
mqttBroker = ""
|
||||||
|
|
||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
client.connect(mqttBroker, 1883)
|
client.connect(MQTT_BROKER_GLOBAL, 1883)
|
||||||
|
|
||||||
client.on_message = on_message
|
client.on_message = on_message
|
||||||
|
|
||||||
client.subscribe("TEST")
|
client.subscribe(Topics['BACKEND_ACTION_GETALLDATA'])
|
||||||
client.loop_forever()
|
client.loop_forever()
|
||||||
|
@ -9,7 +9,7 @@ Used protocol for interaction: mqtt (paho-mqtt module)
|
|||||||
|
|
||||||
# imports
|
# imports
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
from software.defines import MQTT_BROKER_LOCAL, MQTT_BROKER_GLOBAL, Topics, BACKEND_CLIENT_ID, DATABASE_NAME
|
from defines import MQTT_BROKER_LOCAL, MQTT_BROKER_GLOBAL, Topics, BACKEND_CLIENT_ID, DATABASE_NAME
|
||||||
from plantdatabase import PlantDataBase
|
from plantdatabase import PlantDataBase
|
||||||
import data_functions
|
import data_functions
|
||||||
import logging
|
import logging
|
||||||
|
@ -27,7 +27,7 @@ class PlantDataBase:
|
|||||||
|
|
||||||
table_config = "CREATE TABLE IF NOT EXISTS measurement_values " \
|
table_config = "CREATE TABLE IF NOT EXISTS measurement_values " \
|
||||||
"(measurementID INTEGER PRIMARY KEY," \
|
"(measurementID INTEGER PRIMARY KEY," \
|
||||||
"Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP," \
|
"Timestamp DATETIME DEFAULT (datetime('now', 'localtime'))," \
|
||||||
"PlantID INTEGER, " \
|
"PlantID INTEGER, " \
|
||||||
"AirTemperature REAL," \
|
"AirTemperature REAL," \
|
||||||
"AirHumidity REAL," \
|
"AirHumidity REAL," \
|
||||||
|
Binary file not shown.
@ -56,5 +56,5 @@ To send requests to your service, https://www.postman.com/downloads/ is a good a
|
|||||||
|
|
||||||
|
|
||||||
## Passwords:
|
## Passwords:
|
||||||
- Backend PC: Lego_Ohm1
|
- Backend PC: Lego?Ohm1
|
||||||
- Raspy: OHM_123.!
|
- Raspy: OHM_123.!
|
Loading…
x
Reference in New Issue
Block a user