Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add model field to the env box to support mobile gps #87

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion connectivity/src/sensors/environmental_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __post_init__(self) -> None:

super().__post_init__()
self.id = str(self.data["esp8266id"])
self.model = SDS011_MODEL
self.model = self.data.get("model", SDS011_MODEL)
self.public = self.generate_pubkey(str(self.id))
self.donated_by = str(self.data.get("donated_by", ""))
sensors_data = self.data["sensordatavalues"]
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sensors_connectivity"
version = "1.6.0"
version = "1.6.1"
description = "Robonomics package to read data from sensors and publish to different output channels"
authors = [
"Vadim Manaenko <vadim.razorq@gmail.com>",
Expand Down Expand Up @@ -42,6 +42,7 @@ test_environmental_box = "tests.environmental_box_test:main"
test_mobile_lab = "tests.mobile_lab_test:main"
test_many_sensors = "tests.many_environmental_boxes:main"
test_lora_sensors = "tests.lora_sensor_test:main"
test_gps_sensor = "tests.gps_sensor_test:main"

[build-system]
requires = ["poetry_core>=1.0.0"]
Expand Down
43 changes: 43 additions & 0 deletions tests/gps_sensor_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import json
import logging.config
import random
import time

import requests

from connectivity.config.logging import LOGGING_CONFIG

logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger(__name__)

header = {"Content-type": "application/json"}


def main():
lat = round(random.uniform(0.000000, 60.000000), 6)
lon = round(random.uniform(0.000000, 49.999999), 6)
humidity = round(random.uniform(0, 100))
temperature = round(random.uniform(-50, 50), 3)
id = 666
body = {
"esp8266id": id,
"software_version": "NRZ-2020-129",
"donated_by": "Robonomics",
"model": 3,
"sensordatavalues": [
{"value_type": "temperature", "value": temperature},
{"value_type": "humidity", "value": humidity},
{"value_type": "samples", "value": "890618"},
{"value_type": "min_micro", "value": "43"},
{"value_type": "max_micro", "value": "21069"},
{"value_type": "GPS_lat", "value": lat},
{"value_type": "GPS_lon", "value": lon},
{"value_type": "signal", "value": "-46"},
],
}

try:
response = requests.post("http://127.0.0.1:31112/", data=json.dumps(body), headers=header)
except Exception as e:
logger.warning(e)
pass
Loading