Skip to content
Snippets Groups Projects
Commit 3753de4b authored by Hampus Rosenquist's avatar Hampus Rosenquist
Browse files

Complete remaining commands for BT5 (unknown problem)

parent 2b3d1e0c
No related branches found
No related tags found
No related merge requests found
...@@ -104,10 +104,27 @@ def location_update(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id): ...@@ -104,10 +104,27 @@ def location_update(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id):
executor.submit( executor.submit(
iroha.set_account_details, "location", iroha_msg iroha.set_account_details, "location", iroha_msg
) )
# Set (Extended) Advertising command
if is_bt5: if is_bt5:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0037 (LE Set Extended Advertising Data command)
Advertising handle: 0x00 (Advertising set number)
Operation: 0x03 (Complete extended advertising data)
Fragment_Preference: 0x01 (The Controller should not fragment or should minimize fragmentation of Host advertising data)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 10 + payload
"""
subprocess.run( subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0037 1f 1e 16 fa ff 0d 00 10 {payload}".format(payload=payload), shell=True) # TODO "hcitool -i hci0 cmd 0x08 0x0037 00 03 01 1f 1e 16 fa ff 0d 00 10 {payload}".format(payload=payload), shell=True)
else: else:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0008 (LE Set Advertising Data command)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 10 + payload
"""
subprocess.run( subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d 00 10 {payload}".format(payload=payload), shell=True) "hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d 00 10 {payload}".format(payload=payload), shell=True)
...@@ -115,17 +132,61 @@ def location_update(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id): ...@@ -115,17 +132,61 @@ def location_update(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id):
def basic_id_update(hhit): def basic_id_update(hhit):
# ASTM F3-411 Basic ID message 0x0 with HHIT. # ASTM F3-411 Basic ID message 0x0 with HHIT.
print("basic_id_update") print("basic_id_update")
subprocess.run( # Set (Extended) Advertising Command
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d 00 00 §x42 {} 00 00 00 00 00 00 00".format(hhit), shell=True) if is_bt5:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0037 (LE Set Extended Advertising Data command)
Advertising handle: 0x00 (Advertising set number)
Operation: 0x03 (Complete extended advertising data)
Fragment_Preference: 0x01 (The Controller should not fragment or should minimize fragmentation of Host advertising data)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 10 + hhit
"""
subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0037 00 03 01 1f 1e 16 fa ff 0d 00 00 42 {} 00 00 00 00 00 00 00".format(hhit), shell=True)
else:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0008 (LE Set Advertising Data command)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 00 42 + hhit
"""
subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d 00 00 42 {} 00 00 00 00 00 00 00".format(hhit), shell=True)
time.sleep(0.5) time.sleep(0.5)
def auth_update(auth_pages): def auth_update(auth_pages, msg_number):
print("auth_update") print("auth_update")
for page in auth_pages: for page in auth_pages:
msg = separate_bytes(hexlify(page).decode("utf-8")) msg = separate_bytes(hexlify(page).decode("utf-8"))
subprocess.run( # Set (Extended) Advertising Command
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d {} 20 {}".format("00", msg), shell=True) if is_bt5:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0037 (LE Set Extended Advertising Data command)
Advertising handle: 0x00 (Advertising set number)
Operation: 0x03 (Complete extended advertising data)
Fragment_Preference: 0x01 (The Controller should not fragment or should minimize fragmentation of Host advertising data)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 20 + msg
"""
if msg_number == 1:
subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0037 00 01 01 1f 1e 16 fa ff 0d {} 20 {}".format("00", msg), shell=True)
elif msg_number == 2:
subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0037 00 02 01 1f 1e 16 fa ff 0d {} 20 {}".format("00", msg), shell=True)
else:
"""
OGF: 0x08 (LE controller commands)
OCF: 0x0008 (LE Set Advertising Data command)
Advertising_Data_Length: 0x1f
Advertising_Data: 1e 16 fa ff 0d 00 20 + msg
"""
subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d {} 20 {}".format("00", msg), shell=True)
time.sleep(0.2) time.sleep(0.2)
...@@ -245,8 +306,8 @@ def main(): ...@@ -245,8 +306,8 @@ def main():
OCF: 0x0036 (LE Set Extended Advertising Parameters command) OCF: 0x0036 (LE Set Extended Advertising Parameters command)
Advertising handle: 0x00 (Advertising set number) Advertising handle: 0x00 (Advertising set number)
Advertising_Event_Properties: 0x0000 (Non-connectable, non-scannable undirected and not legacy PDU) Advertising_Event_Properties: 0x0000 (Non-connectable, non-scannable undirected and not legacy PDU)
Primary_Advertising_Interval_Min: 0x0800 (1.28 s) Primary_Advertising_Interval_Min: 0x0001e0 (480 ms)
Primary_Advertising_Interval_Max: 0x0800 (1.28 s) Primary_Advertising_Interval_Max: 0x0001e0 (480 ms)
Primary_Advertising_Channel_Map: 0x07 (All three channels enabled) Primary_Advertising_Channel_Map: 0x07 (All three channels enabled)
Own_Address_Type: 0x00 (Public device address) Own_Address_Type: 0x00 (Public device address)
Peer_Address_Type: 0x00 (Public Device Address or Public Identity Address) Peer_Address_Type: 0x00 (Public Device Address or Public Identity Address)
...@@ -260,7 +321,7 @@ def main(): ...@@ -260,7 +321,7 @@ def main():
Scan_Request_Notification_Enable: 0x00 (Scan request notifications disabled) Scan_Request_Notification_Enable: 0x00 (Scan request notifications disabled)
""" """
subprocess.run( subprocess.run(
"hcitool -i hci0 cmd 0x08 0x0036 00 00 00 08 00 08 00 07 00 00 00 00 00 00 00 00 02 7f 03 00 03 00 00", shell=True) # TODO "hcitool -i hci0 cmd 0x08 0x0036 00 00 07 00 01 e0 00 01 e0 07 00 00 00 00 00 00 00 00 02 7f 03 00 03 00 00", shell=True)
else: else:
""" """
OGF: 0x08 (LE controller commands) OGF: 0x08 (LE controller commands)
...@@ -314,10 +375,10 @@ def main(): ...@@ -314,10 +375,10 @@ def main():
basic_id_update(hhit) basic_id_update(hhit)
# Send first half of auth pages second second # Send first half of auth pages second second
elif i % 3 == 1: elif i % 3 == 1:
auth_update(auth_pages[:2]) auth_update(auth_pages[:2], 1)
# Send last half of auth pages last second # Send last half of auth pages last second
elif i % 3 == 2: elif i % 3 == 2:
auth_update(auth_pages[2:]) auth_update(auth_pages[2:], 2)
# Location updates at least once every second. # Location updates at least once every second.
location_update(gpsd, iroha, flight_id) location_update(gpsd, iroha, flight_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment