Skip to content

Commit

Permalink
Merge pull request #87 from airalab/dev
Browse files Browse the repository at this point in the history
add model field to the env box to support mobile gps
  • Loading branch information
tubleronchik authored Apr 25, 2024
2 parents e2f7fc2 + 22aa472 commit fea4c40
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
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 <[email protected]>",
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

0 comments on commit fea4c40

Please sign in to comment.