1+ import configparser
12import time
2- from typing import Optional
33
44import requests
55from shed_pi_module_utils .base_protocol import BaseProtocol
@@ -18,23 +18,32 @@ class DeviceProtocol(BaseProtocol):
1818 def __init__ (
1919 self ,
2020 submission_service : ReadingSubmissionService ,
21- temp_probe_device_id : Optional [int ] = None ,
2221 ):
22+ config = self .get_config ()
23+ device_module_id : str = config ["device" ]["module_id" ]
24+ ext_temp_module_id : str = config ["external_temp" ]["module_id" ]
25+ cpu_temp_module_id : str = config ["cpu_temp" ]["module_id" ]
26+
2327 # Installed modules
2428 self .temp_probe = TempProbe ()
2529 self .rpi_device = RPIDevice (
2630 submission_service = submission_service ,
27- device_module_id = None ,
28- cpu_module_id = None ,
31+ device_module_id = device_module_id ,
32+ cpu_module_id = cpu_temp_module_id ,
2933 )
3034 self .submission_delay = TIME_TO_SLEEP
3135
32- # FIXME: Part of the migration of submission service out of the probe driver
3336 self .submission_service = submission_service
34- self .temp_probe_device_id = temp_probe_device_id
37+ self .temp_probe_device_id = ext_temp_module_id
38+
39+ def get_config (self ) -> dict :
40+ config = configparser .ConfigParser ()
41+ config .read ("config.ini" )
42+ return config
3543
3644 def stop (self ):
37- # FIXKE: This should be a threading event, to break when the execution is terminated, prevents leaving threads behind
45+ # FIXME: This should be a threading event, to break when the execution is terminated,
46+ # prevents leaving threads behind
3847 return False
3948
4049 def startup (self ):
@@ -51,7 +60,7 @@ def run(self):
5160 def shutdown (self ):
5261 self .rpi_device .submit_device_shutdown ()
5362
54- def get_reading (self ) -> bytes :
63+ def get_reading (self ) -> float :
5564 """
5665 Useful for collecting many readings from different modules, rather than submitting all
5766 at once
@@ -65,8 +74,6 @@ def submit_reading(self) -> requests.Response:
6574 :return:
6675 """
6776 probe_1_temp = self .get_reading ()
68-
69- # FIXME: Should this be a float or a string? Broke the test
7077 data = {"temperature" : str (probe_1_temp )}
7178
7279 response = self .submission_service .submit (
0 commit comments