-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recording metadata using the Bluetooth application #11
Comments
Added the elements to the App. It's currently a dummy box that doesn't modify anything on the pi yet. Do you also want me to implement writing to the |
Hi @JonasBchrt, that looks brilliant, thanks very much for your help! It would be brilliant if the values could be written to the following fields in the config.json here. The location of the config.json file varies slightly depending on AMI version, but I would like it to be located in the home/pi or home/bird-pi directory. You can modify the fields in the config.json file using the following:
The config.json will be stored in the home directory of the raspberry Pi (and only the Raspberry Pi, as we transition away from the Rock Pi). Please let me know if you have any other questions, thanks again, Dylan |
Everything should now be implemented in the |
This uses a slightly more generic approach to setting the metadata, which also allows to set other fields (e.g., setting location via the BLE app should also work now) def set_metadata(self, metadata, path="/home/pi/config.json"):
"""
Updates the metadata of the Ami-Trap in the config.json file.
If the file doesn't exist, it is created.
Args:
metadata (dict): A dictionary containing the metadata.
"""
# Read config.json, if it exists
try:
with open(path, "r") as f:
config = json.load(f)
except FileNotFoundError:
config = {}
# Go through all fields in metadata and update config
for top_level_key, top_level_value in metadata.items():
# Chdck if key exists already in conig.json
if top_level_key in config:
# If it's a dictionary, update only the keys that are present in the metadata
if isinstance(top_level_value, dict):
for low_level_key, low_level_value in top_level_value.items():
config[top_level_key][low_level_key] = low_level_value
else:
# If it's not a dictionary, update the value
config[top_level_key] = top_level_value
else:
# If it doesn't exist, create it
config[top_level_key] = top_level_value
# Write config to config.json. Format.
with open(path, "w") as f:
json.dump(config, f, indent=4) It currently only checks the path |
I will leave the issue open for you to ask for changes to my current implementation. If everything is fine, you can close it. |
Thank you very much for this Jonas! I will run your implementation when I am next in the office, and close if there are no issues. |
Hi @JonasBchrt, Thanks again for all your help, I transferred my config.json file to the "home/pi" directory, connected to it via the Bluetooth app, and attempted to transfer habitat name and location remarks metadata. Unfortunately, I was given an error saying it could not read the metadata to the AMI device. Am I taking the wrong approach? I was able to perform other actions, such as to shut down the AMI. If you can spare the time, could we have a quick meeting next Tuesday to sort out this remaining error? Thanks, Dylan |
Hi @DylanCarbone, I can't do Tuesday because I am at AIUK, but we can do another time - just find a slot in my calendar. Can you try not putting a JSON file in the folder? Then, one should be created. I'd be curious if that works. Ultimately, we should read your config.json, of course. |
You can also send me your specific config.json and I try. Don't wanna bother you too much. |
I tried to reproduce the issue, but couldn't. Here's what I did:
Let's have a look together on your system. |
Hi @JonasBchrt,
I hope you are well,
I'm sorry this has taken me so long to post. As we discussed in our meeting last month, when you have the time, could you please add a 'Metadata' section to your Bluetooth app interface. This metadata section should include the following fields:
'Habitat name' - A simple text field asking the user to state the survey habitat. In future it would be useful to encourage choosing habitat names from a dropdown, with names obtained from a standard such as the IUCN Habitat Classification Scheme, but this scheme is still a draft version, and Darwin Core does not enforce a habitat standard, so a written habitat name for now will do.
'Location remarks' - A simple text field asking the user to describe any unexpected characteristics of the deployment environment that they feel may effect results. In most situations this field will be left blank. However, there may be corner cases when the field is needed. For example, the survey design may have strict placement coordinates for the AMI, but the placement is near a large light source and the surveyor wants to make a record of this.
At the end of the section, please add a 'Save metadata' button.
In a second corner case, I can imagine the user repeatedly pressing the 'Save metadata' button out of uncertainty over whether the metadata information has correctly synced. To prevent any crashes, I think the 'Save metadata' button should become locked after each press, until a short timer runs out, or until the Pi relays confirmation of an updated config.json file.
If you have any questions or comments please let me know, thanks.
The text was updated successfully, but these errors were encountered: