Skip to content

Commit 5b75529

Browse files
committed
Make sure hardware clock (external RTC) is set when setting time; when checking if SSD is; also check if it is correctly mounted; remove amber from version naming
1 parent a29e0de commit 5b75529

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "amber-kenya-0.0.1"
1+
__version__ = "ami-cellular-0.0.3"

amitrap.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,23 @@ def get_memory_info(self):
258258

259259
def _is_ssd_connected(self):
260260
"""
261-
Checks if a drive is connected.
261+
Checks if an SSD is connected and mounted at /media/pi/PiImages.
262262
263263
Returns:
264-
bool: True if at least one drive is connected, False otherwise.
264+
bool: True if /dev/sda is connected and mounted at /media/pi/PiImages, False otherwise.
265265
"""
266-
output = subprocess.check_output(['lsblk', '-o', 'NAME,TYPE'])
267-
# Decode the output from bytes to string
268-
output = output.decode('utf-8')
269-
return "sda" in output
266+
try:
267+
# Check if /dev/sda is mounted at /media/pi/PiImages
268+
output = subprocess.check_output(['lsblk', '-o', 'NAME,MOUNTPOINT'], text=True)
269+
270+
for line in output.splitlines():
271+
if "sda" in line and "/media/pi/PiImages" in line:
272+
return True
273+
274+
return False
275+
276+
except subprocess.CalledProcessError:
277+
return False
270278

271279
def get_bluetooth_info(self):
272280
"""
@@ -405,6 +413,17 @@ def set_time(self, time=None, zone=None):
405413
print("Could not set RTC time. Is there an issue with the WittyPi?")
406414
print()
407415

416+
try:
417+
# Set system time from RTC
418+
bash_cmd = f"sudo hwclock -w"
419+
print(bash_cmd)
420+
print()
421+
subprocess.run(bash_cmd, check=True, shell=True, timeout=2)
422+
except Exception as e:
423+
print(e)
424+
print("Could not set RTC time. Is there an issue with the DS3231? Ignore if you are not using a DS3231.")
425+
print()
426+
408427
def get_serial_number(self):
409428
"""
410429
Gets the serial number of the Raspberry Pi / Rock Pi.

amitrap_cellular.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def cellular_configure(i2c_path="/dev/i2c-1"):
4141
"""
4242

4343
# Notehub (cloud) project unique identifier
44-
productUID = "todo:replace-with-your-product-uid"
44+
#productUID = "todo:replace-with-your-product-uid"
4545

4646
# Synchronization mode
4747
# Must be one of 'periodic', 'continous', 'minimum', 'off', or 'dfu'
@@ -60,7 +60,7 @@ async def cellular_configure(i2c_path="/dev/i2c-1"):
6060
print()
6161
# Configure cellular module (Notecard)
6262
hub.set(nCard,
63-
product=productUID,
63+
#product=productUID,
6464
mode=sync_mode,
6565
outbound=outbound_interval_minutes,
6666
inbound=inbound_interval_minutes)

0 commit comments

Comments
 (0)