Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDE21 DRIP 2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Viktor Norgren
TDDE21 DRIP 2023
Commits
3753de4b
Commit
3753de4b
authored
2 years ago
by
Hampus Rosenquist
Browse files
Options
Downloads
Patches
Plain Diff
Complete remaining commands for BT5 (unknown problem)
parent
2b3d1e0c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iroha-drip-general-master/bluetooth/beacon.py
+72
-11
72 additions, 11 deletions
iroha-drip-general-master/bluetooth/beacon.py
with
72 additions
and
11 deletions
iroha-drip-general-master/bluetooth/beacon.py
+
72
−
11
View file @
3753de4b
...
@@ -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: 0x0
8
00
(1.28
s)
Primary_Advertising_Interval_Min: 0x000
1e0 (480 m
s)
Primary_Advertising_Interval_Max: 0x0
8
00
(1.28
s)
Primary_Advertising_Interval_Max: 0x000
1e0 (480 m
s)
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 0
0
0
8
00 0
8
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 0
7
0
0
0
1 e
0 0
0
0
1 e
0 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment