ents 2.3.2__tar.gz → 2.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ents-2.3.2 → ents-2.3.4}/PKG-INFO +2 -2
- {ents-2.3.2 → ents-2.3.4}/pyproject.toml +2 -2
- {ents-2.3.2 → ents-2.3.4}/src/ents/cli.py +3 -3
- ents-2.3.4/src/ents/demo/demoPullRequests.py +119 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/proto/decode.py +4 -2
- ents-2.3.4/src/ents/proto/soil_power_sensor_pb2.py +90 -0
- {ents-2.3.2 → ents-2.3.4}/tests/test_generic.py +23 -2
- ents-2.3.2/src/ents/calibrate/requirements.txt +0 -9
- ents-2.3.2/src/ents/proto/soil_power_sensor_pb2.py +0 -72
- {ents-2.3.2 → ents-2.3.4}/.gitignore +0 -0
- {ents-2.3.2 → ents-2.3.4}/LICENSE +0 -0
- {ents-2.3.2 → ents-2.3.4}/README.md +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/PingSMU.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/PingSPS.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/README.md +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/linear_regression.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/plots.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/calibrate/recorder.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/config/README.md +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/config/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/config/adv_trace.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/config/user_config.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/proto/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/proto/encode.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/proto/esp32.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/simulator/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/src/ents/simulator/node.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/tests/__init__.py +0 -0
- {ents-2.3.2 → ents-2.3.4}/tests/test_simulator.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ents
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: Python package for Environmental NeTworked Sensor (ENTS)
|
|
5
5
|
Project-URL: Homepage, https://github.com/jlab-sensing/soil-power-sensor-firmware
|
|
6
6
|
Project-URL: Issues, https://github.com/jlab-sensing/soil-power-sensor-firmware/issues
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Requires-Python: >=3.11
|
|
13
13
|
Requires-Dist: matplotlib
|
|
14
14
|
Requires-Dist: pandas
|
|
15
|
-
Requires-Dist: protobuf
|
|
15
|
+
Requires-Dist: protobuf==6.31.1
|
|
16
16
|
Requires-Dist: pyserial
|
|
17
17
|
Requires-Dist: requests
|
|
18
18
|
Requires-Dist: scikit-learn
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ents"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.4"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="John Madden", email="jmadden173@pm.me" },
|
|
10
10
|
]
|
|
@@ -17,7 +17,7 @@ classifiers = [
|
|
|
17
17
|
"Operating System :: OS Independent",
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
|
-
'protobuf
|
|
20
|
+
'protobuf==6.31.1',
|
|
21
21
|
'matplotlib',
|
|
22
22
|
'pandas',
|
|
23
23
|
'pyserial',
|
|
@@ -464,9 +464,9 @@ def calibrate(args):
|
|
|
464
464
|
V_STOP = 2.0
|
|
465
465
|
V_STEP = 0.5
|
|
466
466
|
|
|
467
|
-
I_START = -0.
|
|
468
|
-
I_STOP = 0.
|
|
469
|
-
I_STEP = 0.
|
|
467
|
+
I_START = -0.0009
|
|
468
|
+
I_STOP = 0.0009
|
|
469
|
+
I_STEP = 0.00045
|
|
470
470
|
|
|
471
471
|
def record_calibrate(start, stop, step, name: str):
|
|
472
472
|
"""Record and calibrate
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from datetime import datetime, timezone
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from tabulate import tabulate
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DirtVizClient:
|
|
8
|
+
BASE_URL = "https://dirtviz.jlab.ucsc.edu/api/"
|
|
9
|
+
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self.session = requests.Session()
|
|
12
|
+
|
|
13
|
+
def cell_from_name(self, name, start=None, end=None):
|
|
14
|
+
"""Get power data for a specific cell"""
|
|
15
|
+
|
|
16
|
+
def get_power_data(self, cell_id, start=None, end=None):
|
|
17
|
+
"""Get power data for a specific cell"""
|
|
18
|
+
endpoint = f"power/{cell_id}"
|
|
19
|
+
params = {}
|
|
20
|
+
|
|
21
|
+
if start and end:
|
|
22
|
+
params = {
|
|
23
|
+
"startTime": start.strftime("%a, %d %b %Y %H:%M:%S GMT"),
|
|
24
|
+
"endTime": end.strftime("%a, %d %b %Y %H:%M:%S GMT"),
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
response = self.session.get(f"{self.BASE_URL}{endpoint}", params=params)
|
|
28
|
+
response.raise_for_status()
|
|
29
|
+
return response.json()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def format_data_display(df, cell_id):
|
|
33
|
+
"""Format the data output with timestamp as first column"""
|
|
34
|
+
|
|
35
|
+
# Ensure timestamp exists and is first column
|
|
36
|
+
if "timestamp" in df.columns:
|
|
37
|
+
cols = ["timestamp"] + [col for col in df.columns if col != "timestamp"]
|
|
38
|
+
df = df[cols]
|
|
39
|
+
|
|
40
|
+
# Format timestamp nicely
|
|
41
|
+
df["timestamp"] = pd.to_datetime(df["timestamp"])
|
|
42
|
+
df["timestamp"] = df["timestamp"].dt.strftime("%m-%d-%Y %H:%M:%S")
|
|
43
|
+
|
|
44
|
+
# Calculate statistics
|
|
45
|
+
stats = {
|
|
46
|
+
"Cell ID": cell_id,
|
|
47
|
+
"Time Range": (
|
|
48
|
+
f"{df['timestamp'].iloc[0]} to {df['timestamp'].iloc[-1]}"
|
|
49
|
+
if len(df) > 0
|
|
50
|
+
else "N/A"
|
|
51
|
+
),
|
|
52
|
+
"Data Points": len(df),
|
|
53
|
+
"Avg Voltage (mV)": f"{df['v'].mean():.2f}" if "v" in df.columns else "N/A",
|
|
54
|
+
"Max Voltage (mV)": f"{df['v'].max():.2f}" if "v" in df.columns else "N/A",
|
|
55
|
+
"Avg Current (µA)": f"{df['i'].mean():.2f}" if "i" in df.columns else "N/A",
|
|
56
|
+
"Avg Power (µW)": f"{df['p'].mean():.2f}" if "p" in df.columns else "N/A",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
column_rename = {
|
|
60
|
+
"timestamp": "Measurement Times",
|
|
61
|
+
"v": "Voltage (mV)",
|
|
62
|
+
"i": "Current (µA)",
|
|
63
|
+
"p": "Power (µW)",
|
|
64
|
+
}
|
|
65
|
+
# Apply renaming
|
|
66
|
+
df = df.rename(columns=column_rename)
|
|
67
|
+
|
|
68
|
+
# Display header
|
|
69
|
+
print("\n" + "=" * 60)
|
|
70
|
+
print(f"CELL {cell_id} POWER DATA SUMMARY".center(60))
|
|
71
|
+
for key, value in stats.items():
|
|
72
|
+
print(f"• {key:<20}: {value}") # Display the summary information
|
|
73
|
+
print("=" * 60 + "\n")
|
|
74
|
+
|
|
75
|
+
# Display sample data with timestamp first
|
|
76
|
+
if len(df) > 0:
|
|
77
|
+
print("DATA BY TIMESTAMPS:")
|
|
78
|
+
print(
|
|
79
|
+
tabulate(
|
|
80
|
+
df,
|
|
81
|
+
headers="keys",
|
|
82
|
+
tablefmt="grid", # Changed to grid for better column alignment
|
|
83
|
+
stralign="center", # Right-align numbers
|
|
84
|
+
showindex=False,
|
|
85
|
+
numalign="center",
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
else:
|
|
89
|
+
print("No data available to display")
|
|
90
|
+
|
|
91
|
+
print("\n" + "=" * 80)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if __name__ == "__main__":
|
|
95
|
+
client = DirtVizClient()
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
cell_id = 893 # Figure out how to do by name on DirtViz
|
|
99
|
+
start = datetime(2025, 8, 12, tzinfo=timezone.utc)
|
|
100
|
+
end = datetime.now(timezone.utc)
|
|
101
|
+
|
|
102
|
+
print(f"\nFetching power data for cell {cell_id}...")
|
|
103
|
+
data = client.get_power_data(cell_id, start, end)
|
|
104
|
+
|
|
105
|
+
if data:
|
|
106
|
+
df = pd.DataFrame(data)
|
|
107
|
+
format_data_display(df, cell_id)
|
|
108
|
+
|
|
109
|
+
# Save to CSV with timestamp first
|
|
110
|
+
# df.to_csv(f"cell_{cell_id}_power_data.csv", index=False)
|
|
111
|
+
# print(f"Data saved to cell_{cell_id}_power_data.csv")
|
|
112
|
+
else:
|
|
113
|
+
print("No data received for the specified time range.")
|
|
114
|
+
|
|
115
|
+
except requests.exceptions.HTTPError as e:
|
|
116
|
+
print(f"\nHTTP Error: {e}")
|
|
117
|
+
print(f"Response: {e.response.text[:500]}...")
|
|
118
|
+
except Exception as e:
|
|
119
|
+
print(f"\n⚠️ Unexpected error: {str(e)}")
|
|
@@ -51,13 +51,15 @@ def decode_measurement(data: bytes, raw: bool = True) -> dict:
|
|
|
51
51
|
# convert meta into dict
|
|
52
52
|
if not meas.HasField("meta"):
|
|
53
53
|
raise KeyError("Measurement missing metadata")
|
|
54
|
-
meta_dict = MessageToDict(meas.meta)
|
|
54
|
+
meta_dict = MessageToDict(meas.meta, always_print_fields_with_no_presence=True)
|
|
55
55
|
|
|
56
56
|
# decode measurement
|
|
57
57
|
if not meas.HasField("measurement"):
|
|
58
58
|
raise KeyError("Measurement missing data")
|
|
59
59
|
measurement_type = meas.WhichOneof("measurement")
|
|
60
|
-
measurement_dict = MessageToDict(
|
|
60
|
+
measurement_dict = MessageToDict(
|
|
61
|
+
getattr(meas, measurement_type), always_print_fields_with_no_presence=True
|
|
62
|
+
)
|
|
61
63
|
|
|
62
64
|
# store measurement type
|
|
63
65
|
meta_dict["type"] = measurement_type
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: soil_power_sensor.proto
|
|
5
|
+
# Protobuf Python Version: 6.31.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
6,
|
|
15
|
+
31,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'soil_power_sensor.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x17soil_power_sensor.proto\"E\n\x13MeasurementMetadata\x12\x0f\n\x07\x63\x65ll_id\x18\x01 \x01(\r\x12\x11\n\tlogger_id\x18\x02 \x01(\r\x12\n\n\x02ts\x18\x03 \x01(\r\"4\n\x10PowerMeasurement\x12\x0f\n\x07voltage\x18\x02 \x01(\x01\x12\x0f\n\x07\x63urrent\x18\x03 \x01(\x01\"P\n\x12Teros12Measurement\x12\x0f\n\x07vwc_raw\x18\x02 \x01(\x01\x12\x0f\n\x07vwc_adj\x18\x03 \x01(\x01\x12\x0c\n\x04temp\x18\x04 \x01(\x01\x12\n\n\x02\x65\x63\x18\x05 \x01(\r\"6\n\x12Teros21Measurement\x12\x12\n\nmatric_pot\x18\x01 \x01(\x01\x12\x0c\n\x04temp\x18\x02 \x01(\x01\"<\n\x13Phytos31Measurement\x12\x0f\n\x07voltage\x18\x01 \x01(\x01\x12\x14\n\x0cleaf_wetness\x18\x02 \x01(\x01\"L\n\x11\x42ME280Measurement\x12\x10\n\x08pressure\x18\x01 \x01(\r\x12\x13\n\x0btemperature\x18\x02 \x01(\x05\x12\x10\n\x08humidity\x18\x03 \x01(\r\"7\n\x12SEN0308Measurement\x12\x0f\n\x07voltage\x18\x01 \x01(\x01\x12\x10\n\x08humidity\x18\x02 \x01(\x01\"7\n\x12SEN0257Measurement\x12\x0f\n\x07voltage\x18\x01 \x01(\x01\x12\x10\n\x08pressure\x18\x02 \x01(\x01\"\"\n\x12YFS210CMeasurement\x12\x0c\n\x04\x66low\x18\x01 \x01(\x01\"\xfc\x02\n\x0bMeasurement\x12\"\n\x04meta\x18\x01 \x01(\x0b\x32\x14.MeasurementMetadata\x12\"\n\x05power\x18\x02 \x01(\x0b\x32\x11.PowerMeasurementH\x00\x12&\n\x07teros12\x18\x03 \x01(\x0b\x32\x13.Teros12MeasurementH\x00\x12(\n\x08phytos31\x18\x04 \x01(\x0b\x32\x14.Phytos31MeasurementH\x00\x12$\n\x06\x62me280\x18\x05 \x01(\x0b\x32\x12.BME280MeasurementH\x00\x12&\n\x07teros21\x18\x06 \x01(\x0b\x32\x13.Teros21MeasurementH\x00\x12&\n\x07sen0308\x18\x07 \x01(\x0b\x32\x13.SEN0308MeasurementH\x00\x12&\n\x07sen0257\x18\x08 \x01(\x0b\x32\x13.SEN0257MeasurementH\x00\x12&\n\x07yfs210c\x18\t \x01(\x0b\x32\x13.YFS210CMeasurementH\x00\x42\r\n\x0bmeasurement\"X\n\x08Response\x12$\n\x04resp\x18\x01 \x01(\x0e\x32\x16.Response.ResponseType\"&\n\x0cResponseType\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\"\xe9\x01\n\x0c\x45sp32Command\x12$\n\x0cpage_command\x18\x01 \x01(\x0b\x32\x0c.PageCommandH\x00\x12$\n\x0ctest_command\x18\x02 \x01(\x0b\x32\x0c.TestCommandH\x00\x12$\n\x0cwifi_command\x18\x03 \x01(\x0b\x32\x0c.WiFiCommandH\x00\x12*\n\x0fmicrosd_command\x18\x04 \x01(\x0b\x32\x0f.MicroSDCommandH\x00\x12\x30\n\x12irrigation_command\x18\x05 \x01(\x0b\x32\x12.IrrigationCommandH\x00\x42\t\n\x07\x63ommand\"\xb6\x01\n\x0bPageCommand\x12.\n\x0c\x66ile_request\x18\x01 \x01(\x0e\x32\x18.PageCommand.RequestType\x12\x17\n\x0f\x66ile_descriptor\x18\x02 \x01(\r\x12\x12\n\nblock_size\x18\x03 \x01(\r\x12\x11\n\tnum_bytes\x18\x04 \x01(\r\"7\n\x0bRequestType\x12\x08\n\x04OPEN\x10\x00\x12\t\n\x05\x43LOSE\x10\x01\x12\x08\n\x04READ\x10\x02\x12\t\n\x05WRITE\x10\x03\"\x82\x01\n\x0bTestCommand\x12\'\n\x05state\x18\x01 \x01(\x0e\x32\x18.TestCommand.ChangeState\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x05\"<\n\x0b\x43hangeState\x12\x0b\n\x07RECEIVE\x10\x00\x12\x13\n\x0fRECEIVE_REQUEST\x10\x01\x12\x0b\n\x07REQUEST\x10\x02\"\xfe\x01\n\x0bWiFiCommand\x12\x1f\n\x04type\x18\x01 \x01(\x0e\x32\x11.WiFiCommand.Type\x12\x0c\n\x04ssid\x18\x02 \x01(\t\x12\x0e\n\x06passwd\x18\x03 \x01(\t\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x0c\n\x04port\x18\x08 \x01(\r\x12\n\n\x02rc\x18\x05 \x01(\r\x12\n\n\x02ts\x18\x06 \x01(\r\x12\x0c\n\x04resp\x18\x07 \x01(\x0c\"o\n\x04Type\x12\x0b\n\x07\x43ONNECT\x10\x00\x12\x08\n\x04POST\x10\x01\x12\t\n\x05\x43HECK\x10\x02\x12\x08\n\x04TIME\x10\x03\x12\x0e\n\nDISCONNECT\x10\x04\x12\x0e\n\nCHECK_WIFI\x10\x05\x12\r\n\tCHECK_API\x10\x06\x12\x0c\n\x08NTP_SYNC\x10\x07\"\x86\x03\n\x0eMicroSDCommand\x12\"\n\x04type\x18\x01 \x01(\x0e\x32\x14.MicroSDCommand.Type\x12\x10\n\x08\x66ilename\x18\x02 \x01(\t\x12&\n\x02rc\x18\x03 \x01(\x0e\x32\x1a.MicroSDCommand.ReturnCode\x12\x1c\n\x04meas\x18\x04 \x01(\x0b\x32\x0c.MeasurementH\x00\x12 \n\x02uc\x18\x05 \x01(\x0b\x32\x12.UserConfigurationH\x00\" \n\x04Type\x12\x08\n\x04SAVE\x10\x00\x12\x0e\n\nUSERCONFIG\x10\x01\"\xab\x01\n\nReturnCode\x12\x0b\n\x07SUCCESS\x10\x00\x12\x11\n\rERROR_GENERAL\x10\x01\x12\x1e\n\x1a\x45RROR_MICROSD_NOT_INSERTED\x10\x02\x12#\n\x1f\x45RROR_FILE_SYSTEM_NOT_MOUNTABLE\x10\x03\x12\x1d\n\x19\x45RROR_PAYLOAD_NOT_DECODED\x10\x04\x12\x19\n\x15\x45RROR_FILE_NOT_OPENED\x10\x05\x42\x06\n\x04\x64\x61ta\"\x94\x01\n\x11IrrigationCommand\x12%\n\x04type\x18\x01 \x01(\x0e\x32\x17.IrrigationCommand.Type\x12\'\n\x05state\x18\x02 \x01(\x0e\x32\x18.IrrigationCommand.State\"\x11\n\x04Type\x12\t\n\x05\x43HECK\x10\x00\"\x1c\n\x05State\x12\x08\n\x04OPEN\x10\x00\x12\t\n\x05\x43LOSE\x10\x01\"\xdc\x02\n\x11UserConfiguration\x12\x11\n\tlogger_id\x18\x01 \x01(\r\x12\x0f\n\x07\x63\x65ll_id\x18\x02 \x01(\r\x12$\n\rUpload_method\x18\x03 \x01(\x0e\x32\r.Uploadmethod\x12\x17\n\x0fUpload_interval\x18\x04 \x01(\r\x12\'\n\x0f\x65nabled_sensors\x18\x05 \x03(\x0e\x32\x0e.EnabledSensor\x12\x15\n\rVoltage_Slope\x18\x06 \x01(\x01\x12\x16\n\x0eVoltage_Offset\x18\x07 \x01(\x01\x12\x15\n\rCurrent_Slope\x18\x08 \x01(\x01\x12\x16\n\x0e\x43urrent_Offset\x18\t \x01(\x01\x12\x11\n\tWiFi_SSID\x18\n \x01(\t\x12\x15\n\rWiFi_Password\x18\x0b \x01(\t\x12\x18\n\x10\x41PI_Endpoint_URL\x18\x0c \x01(\t\x12\x19\n\x11\x41PI_Endpoint_Port\x18\r \x01(\r*O\n\rEnabledSensor\x12\x0b\n\x07Voltage\x10\x00\x12\x0b\n\x07\x43urrent\x10\x01\x12\x0b\n\x07Teros12\x10\x02\x12\x0b\n\x07Teros21\x10\x03\x12\n\n\x06\x42ME280\x10\x04*\"\n\x0cUploadmethod\x12\x08\n\x04LoRa\x10\x00\x12\x08\n\x04WiFi\x10\x01\x62\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'soil_power_sensor_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_ENABLEDSENSOR']._serialized_start=2759
|
|
35
|
+
_globals['_ENABLEDSENSOR']._serialized_end=2838
|
|
36
|
+
_globals['_UPLOADMETHOD']._serialized_start=2840
|
|
37
|
+
_globals['_UPLOADMETHOD']._serialized_end=2874
|
|
38
|
+
_globals['_MEASUREMENTMETADATA']._serialized_start=27
|
|
39
|
+
_globals['_MEASUREMENTMETADATA']._serialized_end=96
|
|
40
|
+
_globals['_POWERMEASUREMENT']._serialized_start=98
|
|
41
|
+
_globals['_POWERMEASUREMENT']._serialized_end=150
|
|
42
|
+
_globals['_TEROS12MEASUREMENT']._serialized_start=152
|
|
43
|
+
_globals['_TEROS12MEASUREMENT']._serialized_end=232
|
|
44
|
+
_globals['_TEROS21MEASUREMENT']._serialized_start=234
|
|
45
|
+
_globals['_TEROS21MEASUREMENT']._serialized_end=288
|
|
46
|
+
_globals['_PHYTOS31MEASUREMENT']._serialized_start=290
|
|
47
|
+
_globals['_PHYTOS31MEASUREMENT']._serialized_end=350
|
|
48
|
+
_globals['_BME280MEASUREMENT']._serialized_start=352
|
|
49
|
+
_globals['_BME280MEASUREMENT']._serialized_end=428
|
|
50
|
+
_globals['_SEN0308MEASUREMENT']._serialized_start=430
|
|
51
|
+
_globals['_SEN0308MEASUREMENT']._serialized_end=485
|
|
52
|
+
_globals['_SEN0257MEASUREMENT']._serialized_start=487
|
|
53
|
+
_globals['_SEN0257MEASUREMENT']._serialized_end=542
|
|
54
|
+
_globals['_YFS210CMEASUREMENT']._serialized_start=544
|
|
55
|
+
_globals['_YFS210CMEASUREMENT']._serialized_end=578
|
|
56
|
+
_globals['_MEASUREMENT']._serialized_start=581
|
|
57
|
+
_globals['_MEASUREMENT']._serialized_end=961
|
|
58
|
+
_globals['_RESPONSE']._serialized_start=963
|
|
59
|
+
_globals['_RESPONSE']._serialized_end=1051
|
|
60
|
+
_globals['_RESPONSE_RESPONSETYPE']._serialized_start=1013
|
|
61
|
+
_globals['_RESPONSE_RESPONSETYPE']._serialized_end=1051
|
|
62
|
+
_globals['_ESP32COMMAND']._serialized_start=1054
|
|
63
|
+
_globals['_ESP32COMMAND']._serialized_end=1287
|
|
64
|
+
_globals['_PAGECOMMAND']._serialized_start=1290
|
|
65
|
+
_globals['_PAGECOMMAND']._serialized_end=1472
|
|
66
|
+
_globals['_PAGECOMMAND_REQUESTTYPE']._serialized_start=1417
|
|
67
|
+
_globals['_PAGECOMMAND_REQUESTTYPE']._serialized_end=1472
|
|
68
|
+
_globals['_TESTCOMMAND']._serialized_start=1475
|
|
69
|
+
_globals['_TESTCOMMAND']._serialized_end=1605
|
|
70
|
+
_globals['_TESTCOMMAND_CHANGESTATE']._serialized_start=1545
|
|
71
|
+
_globals['_TESTCOMMAND_CHANGESTATE']._serialized_end=1605
|
|
72
|
+
_globals['_WIFICOMMAND']._serialized_start=1608
|
|
73
|
+
_globals['_WIFICOMMAND']._serialized_end=1862
|
|
74
|
+
_globals['_WIFICOMMAND_TYPE']._serialized_start=1751
|
|
75
|
+
_globals['_WIFICOMMAND_TYPE']._serialized_end=1862
|
|
76
|
+
_globals['_MICROSDCOMMAND']._serialized_start=1865
|
|
77
|
+
_globals['_MICROSDCOMMAND']._serialized_end=2255
|
|
78
|
+
_globals['_MICROSDCOMMAND_TYPE']._serialized_start=2041
|
|
79
|
+
_globals['_MICROSDCOMMAND_TYPE']._serialized_end=2073
|
|
80
|
+
_globals['_MICROSDCOMMAND_RETURNCODE']._serialized_start=2076
|
|
81
|
+
_globals['_MICROSDCOMMAND_RETURNCODE']._serialized_end=2247
|
|
82
|
+
_globals['_IRRIGATIONCOMMAND']._serialized_start=2258
|
|
83
|
+
_globals['_IRRIGATIONCOMMAND']._serialized_end=2406
|
|
84
|
+
_globals['_IRRIGATIONCOMMAND_TYPE']._serialized_start=2359
|
|
85
|
+
_globals['_IRRIGATIONCOMMAND_TYPE']._serialized_end=2376
|
|
86
|
+
_globals['_IRRIGATIONCOMMAND_STATE']._serialized_start=2378
|
|
87
|
+
_globals['_IRRIGATIONCOMMAND_STATE']._serialized_end=2406
|
|
88
|
+
_globals['_USERCONFIGURATION']._serialized_start=2409
|
|
89
|
+
_globals['_USERCONFIGURATION']._serialized_end=2757
|
|
90
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -120,8 +120,8 @@ class TestDecode(unittest.TestCase):
|
|
|
120
120
|
self.assertEqual(123, meas_dict["data"]["ec"])
|
|
121
121
|
self.assertEqual(int, meas_dict["data_type"]["ec"])
|
|
122
122
|
|
|
123
|
-
def
|
|
124
|
-
"""Test decoding of
|
|
123
|
+
def test_bme280(self):
|
|
124
|
+
"""Test decoding of bme280 measurement"""
|
|
125
125
|
|
|
126
126
|
meas = Measurement()
|
|
127
127
|
meas.meta.CopyFrom(self.meta)
|
|
@@ -208,6 +208,27 @@ class TestDecode(unittest.TestCase):
|
|
|
208
208
|
with self.assertRaises(KeyError):
|
|
209
209
|
decode_measurement(data=meas_str)
|
|
210
210
|
|
|
211
|
+
def test_missing_default_values(self):
|
|
212
|
+
"""Test to ensure that default valued fields are included in the
|
|
213
|
+
decoded dictionary
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
meas = Measurement()
|
|
217
|
+
meas.meta.CopyFrom(self.meta)
|
|
218
|
+
|
|
219
|
+
meas.teros12.vwc_raw = 2141.52
|
|
220
|
+
meas.teros12.vwc_adj = 0.45
|
|
221
|
+
meas.teros12.temp = 25.0
|
|
222
|
+
|
|
223
|
+
# set integer to default value of 0
|
|
224
|
+
meas.teros12.ec = 0
|
|
225
|
+
|
|
226
|
+
meas_str = meas.SerializeToString()
|
|
227
|
+
|
|
228
|
+
meas_dict = decode_measurement(data=meas_str)
|
|
229
|
+
|
|
230
|
+
self.assertIn("ec", meas_dict["data"])
|
|
231
|
+
|
|
211
232
|
|
|
212
233
|
class TestEsp32(unittest.TestCase):
|
|
213
234
|
def test_cmd_not_implemented(self):
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
-
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
-
# source: soil_power_sensor.proto
|
|
5
|
-
# Protobuf Python Version: 6.30.1
|
|
6
|
-
"""Generated protocol buffer code."""
|
|
7
|
-
from google.protobuf import descriptor as _descriptor
|
|
8
|
-
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
-
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
-
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
-
from google.protobuf.internal import builder as _builder
|
|
12
|
-
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
-
_runtime_version.Domain.PUBLIC,
|
|
14
|
-
6,
|
|
15
|
-
30,
|
|
16
|
-
1,
|
|
17
|
-
'',
|
|
18
|
-
'soil_power_sensor.proto'
|
|
19
|
-
)
|
|
20
|
-
# @@protoc_insertion_point(imports)
|
|
21
|
-
|
|
22
|
-
_sym_db = _symbol_database.Default()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x17soil_power_sensor.proto\"E\n\x13MeasurementMetadata\x12\x0f\n\x07\x63\x65ll_id\x18\x01 \x01(\r\x12\x11\n\tlogger_id\x18\x02 \x01(\r\x12\n\n\x02ts\x18\x03 \x01(\r\"4\n\x10PowerMeasurement\x12\x0f\n\x07voltage\x18\x02 \x01(\x01\x12\x0f\n\x07\x63urrent\x18\x03 \x01(\x01\"P\n\x12Teros12Measurement\x12\x0f\n\x07vwc_raw\x18\x02 \x01(\x01\x12\x0f\n\x07vwc_adj\x18\x03 \x01(\x01\x12\x0c\n\x04temp\x18\x04 \x01(\x01\x12\n\n\x02\x65\x63\x18\x05 \x01(\r\"6\n\x12Teros21Measurement\x12\x12\n\nmatric_pot\x18\x01 \x01(\x01\x12\x0c\n\x04temp\x18\x02 \x01(\x01\"<\n\x13Phytos31Measurement\x12\x0f\n\x07voltage\x18\x01 \x01(\x01\x12\x14\n\x0cleaf_wetness\x18\x02 \x01(\x01\"L\n\x11\x42ME280Measurement\x12\x10\n\x08pressure\x18\x01 \x01(\r\x12\x13\n\x0btemperature\x18\x02 \x01(\x05\x12\x10\n\x08humidity\x18\x03 \x01(\r\"\x84\x02\n\x0bMeasurement\x12\"\n\x04meta\x18\x01 \x01(\x0b\x32\x14.MeasurementMetadata\x12\"\n\x05power\x18\x02 \x01(\x0b\x32\x11.PowerMeasurementH\x00\x12&\n\x07teros12\x18\x03 \x01(\x0b\x32\x13.Teros12MeasurementH\x00\x12(\n\x08phytos31\x18\x04 \x01(\x0b\x32\x14.Phytos31MeasurementH\x00\x12$\n\x06\x62me280\x18\x05 \x01(\x0b\x32\x12.BME280MeasurementH\x00\x12&\n\x07teros21\x18\x06 \x01(\x0b\x32\x13.Teros21MeasurementH\x00\x42\r\n\x0bmeasurement\"X\n\x08Response\x12$\n\x04resp\x18\x01 \x01(\x0e\x32\x16.Response.ResponseType\"&\n\x0cResponseType\x12\x0b\n\x07SUCCESS\x10\x00\x12\t\n\x05\x45RROR\x10\x01\"\x8b\x01\n\x0c\x45sp32Command\x12$\n\x0cpage_command\x18\x01 \x01(\x0b\x32\x0c.PageCommandH\x00\x12$\n\x0ctest_command\x18\x02 \x01(\x0b\x32\x0c.TestCommandH\x00\x12$\n\x0cwifi_command\x18\x03 \x01(\x0b\x32\x0c.WiFiCommandH\x00\x42\t\n\x07\x63ommand\"\xb6\x01\n\x0bPageCommand\x12.\n\x0c\x66ile_request\x18\x01 \x01(\x0e\x32\x18.PageCommand.RequestType\x12\x17\n\x0f\x66ile_descriptor\x18\x02 \x01(\r\x12\x12\n\nblock_size\x18\x03 \x01(\r\x12\x11\n\tnum_bytes\x18\x04 \x01(\r\"7\n\x0bRequestType\x12\x08\n\x04OPEN\x10\x00\x12\t\n\x05\x43LOSE\x10\x01\x12\x08\n\x04READ\x10\x02\x12\t\n\x05WRITE\x10\x03\"\x82\x01\n\x0bTestCommand\x12\'\n\x05state\x18\x01 \x01(\x0e\x32\x18.TestCommand.ChangeState\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x05\"<\n\x0b\x43hangeState\x12\x0b\n\x07RECEIVE\x10\x00\x12\x13\n\x0fRECEIVE_REQUEST\x10\x01\x12\x0b\n\x07REQUEST\x10\x02\"\xc1\x01\n\x0bWiFiCommand\x12\x1f\n\x04type\x18\x01 \x01(\x0e\x32\x11.WiFiCommand.Type\x12\x0c\n\x04ssid\x18\x02 \x01(\t\x12\x0e\n\x06passwd\x18\x03 \x01(\t\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\x0c\n\x04port\x18\x08 \x01(\r\x12\n\n\x02rc\x18\x05 \x01(\r\x12\n\n\x02ts\x18\x06 \x01(\r\x12\x0c\n\x04resp\x18\x07 \x01(\x0c\"2\n\x04Type\x12\x0b\n\x07\x43ONNECT\x10\x00\x12\x08\n\x04POST\x10\x01\x12\t\n\x05\x43HECK\x10\x02\x12\x08\n\x04TIME\x10\x03\"\xdc\x02\n\x11UserConfiguration\x12\x11\n\tlogger_id\x18\x01 \x01(\r\x12\x0f\n\x07\x63\x65ll_id\x18\x02 \x01(\r\x12$\n\rUpload_method\x18\x03 \x01(\x0e\x32\r.Uploadmethod\x12\x17\n\x0fUpload_interval\x18\x04 \x01(\r\x12\'\n\x0f\x65nabled_sensors\x18\x05 \x03(\x0e\x32\x0e.EnabledSensor\x12\x15\n\rVoltage_Slope\x18\x06 \x01(\x01\x12\x16\n\x0eVoltage_Offset\x18\x07 \x01(\x01\x12\x15\n\rCurrent_Slope\x18\x08 \x01(\x01\x12\x16\n\x0e\x43urrent_Offset\x18\t \x01(\x01\x12\x11\n\tWiFi_SSID\x18\n \x01(\t\x12\x15\n\rWiFi_Password\x18\x0b \x01(\t\x12\x18\n\x10\x41PI_Endpoint_URL\x18\x0c \x01(\t\x12\x19\n\x11\x41PI_Endpoint_Port\x18\r \x01(\r*O\n\rEnabledSensor\x12\x0b\n\x07Voltage\x10\x00\x12\x0b\n\x07\x43urrent\x10\x01\x12\x0b\n\x07Teros12\x10\x02\x12\x0b\n\x07Teros21\x10\x03\x12\n\n\x06\x42ME280\x10\x04*\"\n\x0cUploadmethod\x12\x08\n\x04LoRa\x10\x00\x12\x08\n\x04WiFi\x10\x01\x62\x06proto3')
|
|
28
|
-
|
|
29
|
-
_globals = globals()
|
|
30
|
-
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
-
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'soil_power_sensor_pb2', _globals)
|
|
32
|
-
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
-
DESCRIPTOR._loaded_options = None
|
|
34
|
-
_globals['_ENABLEDSENSOR']._serialized_start=1790
|
|
35
|
-
_globals['_ENABLEDSENSOR']._serialized_end=1869
|
|
36
|
-
_globals['_UPLOADMETHOD']._serialized_start=1871
|
|
37
|
-
_globals['_UPLOADMETHOD']._serialized_end=1905
|
|
38
|
-
_globals['_MEASUREMENTMETADATA']._serialized_start=27
|
|
39
|
-
_globals['_MEASUREMENTMETADATA']._serialized_end=96
|
|
40
|
-
_globals['_POWERMEASUREMENT']._serialized_start=98
|
|
41
|
-
_globals['_POWERMEASUREMENT']._serialized_end=150
|
|
42
|
-
_globals['_TEROS12MEASUREMENT']._serialized_start=152
|
|
43
|
-
_globals['_TEROS12MEASUREMENT']._serialized_end=232
|
|
44
|
-
_globals['_TEROS21MEASUREMENT']._serialized_start=234
|
|
45
|
-
_globals['_TEROS21MEASUREMENT']._serialized_end=288
|
|
46
|
-
_globals['_PHYTOS31MEASUREMENT']._serialized_start=290
|
|
47
|
-
_globals['_PHYTOS31MEASUREMENT']._serialized_end=350
|
|
48
|
-
_globals['_BME280MEASUREMENT']._serialized_start=352
|
|
49
|
-
_globals['_BME280MEASUREMENT']._serialized_end=428
|
|
50
|
-
_globals['_MEASUREMENT']._serialized_start=431
|
|
51
|
-
_globals['_MEASUREMENT']._serialized_end=691
|
|
52
|
-
_globals['_RESPONSE']._serialized_start=693
|
|
53
|
-
_globals['_RESPONSE']._serialized_end=781
|
|
54
|
-
_globals['_RESPONSE_RESPONSETYPE']._serialized_start=743
|
|
55
|
-
_globals['_RESPONSE_RESPONSETYPE']._serialized_end=781
|
|
56
|
-
_globals['_ESP32COMMAND']._serialized_start=784
|
|
57
|
-
_globals['_ESP32COMMAND']._serialized_end=923
|
|
58
|
-
_globals['_PAGECOMMAND']._serialized_start=926
|
|
59
|
-
_globals['_PAGECOMMAND']._serialized_end=1108
|
|
60
|
-
_globals['_PAGECOMMAND_REQUESTTYPE']._serialized_start=1053
|
|
61
|
-
_globals['_PAGECOMMAND_REQUESTTYPE']._serialized_end=1108
|
|
62
|
-
_globals['_TESTCOMMAND']._serialized_start=1111
|
|
63
|
-
_globals['_TESTCOMMAND']._serialized_end=1241
|
|
64
|
-
_globals['_TESTCOMMAND_CHANGESTATE']._serialized_start=1181
|
|
65
|
-
_globals['_TESTCOMMAND_CHANGESTATE']._serialized_end=1241
|
|
66
|
-
_globals['_WIFICOMMAND']._serialized_start=1244
|
|
67
|
-
_globals['_WIFICOMMAND']._serialized_end=1437
|
|
68
|
-
_globals['_WIFICOMMAND_TYPE']._serialized_start=1387
|
|
69
|
-
_globals['_WIFICOMMAND_TYPE']._serialized_end=1437
|
|
70
|
-
_globals['_USERCONFIGURATION']._serialized_start=1440
|
|
71
|
-
_globals['_USERCONFIGURATION']._serialized_end=1788
|
|
72
|
-
# @@protoc_insertion_point(module_scope)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|