Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jatanjay committed Apr 29, 2024
1 parent 0a4dbf5 commit e758e89
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
9 changes: 6 additions & 3 deletions Downlink/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"BOOT_MODE": "DEFAULT",
"N": "10",
"FREQ": "5",
"SEP": "-"
"SEP": "-",
"DEVICE_ID": "5ac752d9-a6ab-4ba0-bef5-304a0cc41c9b"
},
"routine1": {
"Buzzer_Set": "LOW",
Expand All @@ -23,7 +24,8 @@
"BOOT_MODE": "TRUE",
"N": "40",
"FREQ": "2",
"SEP": ""
"SEP": "",
"DEVICE_ID": "5ac752d9-a6ab-4ba0-bef5-304a0cc41c9C"
},
"routine2": {
"Buzzer_Set": "MEDIUM",
Expand All @@ -36,6 +38,7 @@
"BOOT_MODE": "FALSE",
"N": "30",
"FREQ": "10",
"SEP": ":"
"SEP": ":",
"DEVICE_ID": "5ac752d9-a6ab-4ba0-bef5-304a0cc41c9A"
}
}
44 changes: 26 additions & 18 deletions Downlink/downlinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ def __init__(
NFC_Merch_Set="DEFAULT",
BOOT_MODE="DEFAULT",
SEP="<SEP>",
DEVICE_ID="DEFAULT"
):
self.Buzzer_Set = Buzzer_Set
self.NFC_Set = NFC_Set
self.Bin_Level = Bin_Level
self.UHF_Power = UHF_Power
self.Display_Set = Display_Set
self.BinID_Set = BinID_Set
self.NFC_Merch_Set = NFC_Merch_Set
self.Buzzer_Set = Buzzer_Set.lower()
self.NFC_Set = NFC_Set.lower()
self.Bin_Level = Bin_Level.lower()
self.UHF_Power = UHF_Power.lower()
self.Display_Set = Display_Set.lower()
self.BinID_Set = BinID_Set.lower()
self.NFC_Merch_Set = NFC_Merch_Set.lower()
self.BOOT_MODE = BOOT_MODE
self.DEVICE_ID = DEVICE_ID

# Config vars
self.SEP = SEP
Expand All @@ -89,6 +91,7 @@ def __str__(self):
f"NFC Merchant Setting: {self.NFC_Merch_Set}\n"
f"Boot Mode: {self.BOOT_MODE}\n"
f"<SEP>: '{self.SEP}'\n"
f"DEVICE_ID: '{self.DEVICE_ID}'\n"
f"========================\n"
)

Expand All @@ -114,44 +117,44 @@ def configure(self):
"VENUE": {"pepsi_east": "PEPSIEASTNYC01", "pepsi_west": "PEPSIWESTSF03", "pepsi_mid": "PEPSIMIDCHI07"},
}

if self.Buzzer_Set.lower() in SetMap["LEVEL"]:
self.Buzzer_Set = SetMap["LEVEL"][self.Buzzer_Set.lower()]
if self.Buzzer_Set in SetMap["LEVEL"]:
self.Buzzer_Set = SetMap["LEVEL"][self.Buzzer_Set]
elif self.Buzzer_Set == "DEFAULT":
pass
else:
raise ValueError(
f"Acceptable parameters for <Buzzer_Set> are {', '.join(SetMap['LEVEL'].keys())}"
)

if self.NFC_Set.lower() in SetMap["FLAG"]:
self.NFC_Set = SetMap["FLAG"][self.NFC_Set.lower()]
if self.NFC_Set in SetMap["FLAG"]:
self.NFC_Set = SetMap["FLAG"][self.NFC_Set]
elif self.NFC_Set == "DEFAULT":
pass
else:
raise ValueError(
f"Acceptable parameters for <NFC_Set> are {', '.join(SetMap['FLAG'].keys())}"
)

if self.Bin_Level.lower() in SetMap["LEVEL"]:
self.Bin_Level = SetMap["LEVEL"][self.Bin_Level.lower()]
if self.Bin_Level in SetMap["LEVEL"]:
self.Bin_Level = SetMap["LEVEL"][self.Bin_Level]
elif self.Bin_Level == "DEFAULT":
pass
else:
raise ValueError(
F"Acceptable parameters for <Bin_Level> are {', '.join(SetMap['LEVEL'].keys())}"
)

if self.UHF_Power.lower() in SetMap["LEVEL"]:
self.UHF_Power = SetMap["LEVEL"][self.UHF_Power.lower()]
if self.UHF_Power in SetMap["LEVEL"]:
self.UHF_Power = SetMap["LEVEL"][self.UHF_Power]
elif self.UHF_Power == "DEFAULT":
pass
else:
raise ValueError(
f"Acceptable parameters for <UHF_Power> are {', '.join(SetMap['LEVEL'].keys())}"
)

if self.Display_Set.lower() in SetMap["VENUE"]:
self.Display_Set = SetMap["VENUE"][self.Display_Set.lower()]
if self.Display_Set in SetMap["VENUE"]:
self.Display_Set = SetMap["VENUE"][self.Display_Set]
elif self.Display_Set == "DEFAULT":
pass
else:
Expand Down Expand Up @@ -190,10 +193,13 @@ def prep(self):
self.encoder()

def awsDownlink(self, N, freq,
device_id="5ac752d9-a6ab-4ba0-bef5-304a0cc41c9b"):
device_id=None):
self.prep()
transmit_mode = 1

if device_id is None:
device_id = self.DEVICE_ID

for i in range(1, N + 1):
wireless_metadata = {
"Sidewalk": {
Expand Down Expand Up @@ -231,6 +237,7 @@ def main():
"--routine",
default="default",
help="Routine to use from the config file")

args = parser.parse_args()

config_file = args.config
Expand All @@ -252,6 +259,7 @@ def main():
NFC_Merch_Set=config.get("NFC_Merch_Set", "DEFAULT"),
BOOT_MODE=config.get("BOOT_MODE", "DEFAULT"),
SEP=config.get("SEP", "<SEP>"),
DEVICE_ID=config.get("DEVICE_ID", "DEFAULT")
)

print(dl)
Expand Down

0 comments on commit e758e89

Please sign in to comment.