Skip to content

Commit

Permalink
Improved Reticulum behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Oct 28, 2024
1 parent 7222677 commit 7d9435b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions assets/support/configdefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
"identity_file": "/home/pi/.reticulum/storage/identities/predator",
"instance_name": "My Car",
"events": {
"start_up": {
"enabled": true
},
"motion_detected": {
"enabled": true
},
Expand Down
3 changes: 3 additions & 0 deletions assets/support/configoutline.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@
"identity_file": "str",
"instance_name": "str",
"events": {
"start_up": {
"enabled": "bool"
},
"motion_detected": {
"enabled": "bool"
},
Expand Down
4 changes: 4 additions & 0 deletions dashcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,10 @@ def start_dashcam_recording(dashcam_devices, directory): # This function starts
iteration_counter += 1 # Iterate the counter. This value will be used to create unique file names for each recorded video.
print("Started dashcam recording on " + str(dashcam_devices[device]["index"])) # Inform the user that recording was initiation for this camera device.

if (config["dashcam"]["notifications"]["reticulum"]["enabled"] == True and config["dashcam"]["notifications"]["reticulum"]["events"]["start_up"]["enabled"] == True): # Check to see if Predator is configured to send start-up notifications over Reticulum.
for destination in config["dashcam"]["notifications"]["reticulum"]["destinations"]: # Iterate over each configured destination.
reticulum.lxmf_send_message(str(config["dashcam"]["notifications"]["reticulum"]["instance_name"]) + " has been started", destination) # Send a Reticulum LXMF message to this destination.

try:
if (config["dashcam"]["parked"]["enabled"] == True): # Check to see if parked mode functionality is enabled.
last_moved_time = utils.get_time() # This value holds the Unix timestamp of the last time the vehicle exceeded the parking speed threshold.
Expand Down
18 changes: 11 additions & 7 deletions reticulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@
new_identity = RNS.Identity()
new_identity.to_file(config["dashcam"]["notifications"]["reticulum"]["identity_file"])

debug_message("Loading Reticulum identity file")
config["dashcam"]["notifications"]["reticulum"]["identity_file"] = "/home/cvieira/.reticulum/storage/identities/predator"
identity = RNS.Identity().from_file(config["dashcam"]["notifications"]["reticulum"]["identity_file"])

debug_message("Announcing Reticulum source")
source = lxmf_router.register_delivery_identity(identity, display_name="Predator")
lxmf_router.announce(source.hash) # Announce this instance.
last_announce = time.time()

def lxmf_send_message(message, destination):
global lxmf_router
global config

debug_message("Loading Reticulum identity file")
config["dashcam"]["notifications"]["reticulum"]["identity_file"] = "/home/cvieira/.reticulum/storage/identities/predator"
identity = RNS.Identity().from_file(config["dashcam"]["notifications"]["reticulum"]["identity_file"])

debug_message("Announcing Reticulum source")
source = lxmf_router.register_delivery_identity(identity, display_name="Predator")
lxmf_router.announce(source.hash) # Announce this instance.
if (time.time() - last_announce > 30*60):
debug_message("Announcing Reticulum source")
lxmf_router.announce(source.hash) # Announce this instance.

debug_message("Identifying Reticulum destination")
recipient_hash = bytes.fromhex(destination)
Expand Down

0 comments on commit 7d9435b

Please sign in to comment.