Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OC Robotique
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Info_Sismondi
OC Robotique
Commits
0e6beaa9
Commit
0e6beaa9
authored
3 months ago
by
Vincent Namy (EDU_GE)
Browse files
Options
Downloads
Patches
Plain Diff
Protocole v1.1
parent
50e164be
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Protocole/main.py
+20
-12
20 additions, 12 deletions
Protocole/main.py
Protocole/protocole.py
+23
-21
23 additions, 21 deletions
Protocole/protocole.py
with
43 additions
and
33 deletions
Protocole/main.py
+
20
−
12
View file @
0e6beaa9
'''
Protocole Réseau Pour Micro:bit OC Robotique 2025
Fichier de test de la lib
Auteur·ice : Vincent Namy
Version : 1.0
Date : 28.1.25
TODO :
- Encryption
- passer trame en bytes ?
'''
...
...
@@ -15,21 +13,31 @@ import music
userId
=
0
def
ackedVisualFeedback
(
acked
):
if
acked
:
display
.
show
(
Image
.
HAPPY
)
else
:
display
.
show
(
Image
.
SAD
)
sleep
(
100
)
display
.
clear
()
while
True
:
# Messages à envoyer
destId
=
1
if
button_a
.
was_pressed
():
if
send_msg
(
1
,[],
userId
,
1
):
display
.
show
(
Image
.
HAPPY
)
else
:
display
.
show
(
Image
.
SAD
)
sleep
(
100
)
display
.
clear
()
send_msg
(
1
,[
60
],
userId
,
destId
)
elif
button_b
.
was_pressed
():
send_msg
(
1
,[
120
],
userId
,
destId
)
# Reception des messages
m
=
receive_msg
(
userId
)
if
m
and
m
.
msgId
==
1
:
music
.
pitch
(
600
,
duration
=
100
,
pin
=
pin0
)
print
(
m
.
msgStr
())
music
.
pitch
(
m
.
payload
[
0
]
*
10
,
duration
=
100
,
pin
=
pin0
)
elif
m
and
m
.
msgId
==
2
:
display
.
show
(
Image
.
SQUARE
)
This diff is collapsed.
Click to expand it.
Protocole/protocole.py
+
23
−
21
View file @
0e6beaa9
...
...
@@ -5,8 +5,11 @@ Version : 1.0
Date : 28.1.25
TODO :
-
Encryption
-
plusieurs messages
- passer trame en bytes ?
- doc string
- template
- Encryption
'''
#### Libraries ####
...
...
@@ -16,7 +19,7 @@ import radio
#### Variables globales ####
seqNum
=
0
tryTime
=
100
Timeout
=
5
00
Timeout
=
3
00
ackMsgId
=
0
#### Start radio module ####
...
...
@@ -90,16 +93,16 @@ def send_msg(msgId, payload: List[int], userId:int, dest:int):
acked
=
False
t0
=
running_time
()
#
print("Envoyé : ", msg.msgStr())
print
(
"
Envoyé :
"
,
msg
.
msgStr
())
while
not
acked
and
running_time
()
-
t0
<
Timeout
:
#
print("envoi")
print
(
"
envoi
"
)
radio
.
send_bytes
(
bytes
(
msg_to_trame
(
msg
)))
sleep
(
tryTime
//
2
)
display
.
clear
()
sleep
(
tryTime
//
2
)
acked
=
receive_ack
(
msg
)
#
print("acked : ", acked)
print
(
"
acked :
"
,
acked
)
#print(running_time()-t0)
seqNum
+=
1
...
...
@@ -119,21 +122,20 @@ if __name__ == '__main__':
userId
=
0
while
True
:
# Messages à envoyer
destId
=
1
if
button_a
.
was_pressed
():
send_msg
(
1
,[
60
],
userId
,
destId
)
elif
button_b
.
was_pressed
():
send_msg
(
1
,[
120
],
userId
,
destId
)
if
button_a
.
was_pressed
():
if
send_msg
(
1
,[
10
,
22
],
userId
,
1
):
display
.
show
(
Image
.
HAPPY
)
else
:
display
.
show
(
Image
.
SAD
)
sleep
(
100
)
display
.
clear
()
m
=
receive_msg
(
userId
)
if
m
and
m
.
msgId
==
1
:
display
.
show
(
Image
.
SQUARE
)
sleep
(
100
)
display
.
clear
()
# Reception des messages
m
=
receive_msg
(
userId
)
if
m
and
m
.
msgId
==
1
:
print
(
m
.
msgStr
())
music
.
pitch
(
m
.
payload
[
0
]
*
10
,
duration
=
100
,
pin
=
pin0
)
elif
m
and
m
.
msgId
==
2
:
display
.
show
(
Image
.
SQUARE
)
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