From 1ddb180344a1d9908aceaaaa559f03048de20a8e Mon Sep 17 00:00:00 2001 From: Julien Cluzel <julien.cluzel@imt-atlantique.net> Date: Tue, 22 Apr 2025 10:24:06 +0200 Subject: [PATCH] pingPong2 --- GW-custom/PingPong/.DS_Store | Bin 6148 -> 6148 bytes GW-custom/PingPong/Ping/boot.py | 0 GW-custom/PingPong/Pong/Pong.code-workspace | 8 ++++ GW-custom/PingPong/Pong/boot.py | 1 + GW-custom/PingPong/Pong/main.py | 41 ++++++++++++++++++++ GW-custom/PingPong/Pong/pymakr.conf | 11 ++++++ 6 files changed, 61 insertions(+) create mode 100644 GW-custom/PingPong/Ping/boot.py create mode 100644 GW-custom/PingPong/Pong/Pong.code-workspace create mode 100644 GW-custom/PingPong/Pong/boot.py create mode 100644 GW-custom/PingPong/Pong/main.py create mode 100644 GW-custom/PingPong/Pong/pymakr.conf diff --git a/GW-custom/PingPong/.DS_Store b/GW-custom/PingPong/.DS_Store index 9979d8b0454d3736f0b32db838e44ebf21bc0481..82a3fe5c31d0b2de64ad0864b9d6679cb1c01770 100644 GIT binary patch delta 309 zcmZoMXfc=|#>B)qF;Q%yo}wrR0|Nsi1A_nqLncEiLlJ`lLoq|*W=6*4jP)QXA%+x& ze1>9%Vq|HCJceQh1%?uaOokGMB8JqQbi?4}{M-Tt1RzRZZoZ34Qcivn0|Ns`>eYIU zBe#z^GB7Ye^~T`0G&es5k7oRO3o<6olG-?fopm!i2R{cB6X#||#_!CN`9%x`7#SEC Q8X#c;Vlr$F5ZS^E07Q&H-v9sr delta 71 zcmZoMXfc=|#>CJ*u~2NHo+3930|Nsi1A_oVPWt3HW<y4n&0m;=SvNN@XE1GM=iujH bVrbu7$o!poGQWr+Bg14H9_h_7A}g2yURx18 diff --git a/GW-custom/PingPong/Ping/boot.py b/GW-custom/PingPong/Ping/boot.py new file mode 100644 index 0000000..e69de29 diff --git a/GW-custom/PingPong/Pong/Pong.code-workspace b/GW-custom/PingPong/Pong/Pong.code-workspace new file mode 100644 index 0000000..35ce7eb --- /dev/null +++ b/GW-custom/PingPong/Pong/Pong.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "name": "Pong", + "path": "." + } + ] +} \ No newline at end of file diff --git a/GW-custom/PingPong/Pong/boot.py b/GW-custom/PingPong/Pong/boot.py new file mode 100644 index 0000000..b8e7bb0 --- /dev/null +++ b/GW-custom/PingPong/Pong/boot.py @@ -0,0 +1 @@ +# boot.py -- run on boot-up diff --git a/GW-custom/PingPong/Pong/main.py b/GW-custom/PingPong/Pong/main.py new file mode 100644 index 0000000..ea6e27c --- /dev/null +++ b/GW-custom/PingPong/Pong/main.py @@ -0,0 +1,41 @@ +# main.py -- put your code here! +from network import LoRa +import socket +import time + +# Please pick the region that matches where you are using the device + +lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868, adr=False) +print('Coding rate {}'.format(lora.coding_rate())) + +#lora.sf(12) +print('SF {}'.format(lora.sf())) + +s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) + +s.setblocking(False) + +# Code pour le Pong ; réception puis émission +i = 0 +while True: + if s.recv(64) == b'Ping': + print('je recois Ping du Node A') + print(lora.stats()) + #print(lora.coding_rate()) + s.send('Pong') + print('Pong {}'.format(i)) + i = i+1 + time.sleep(5) + +# Code pour le Ping ; uniquement émission +# msg = 'Ping' +# #msg = 'Ping hello i m devui' + (ubinascii.hexlify(lora.mac()).decode('ascii')) +# #print(msg) +# i = 0 +# while True: +# s.send(msg) +# print('Ping {}'.format(i)) +# print(lora.stats()) +# i= i+1 +# time.sleep(5) + diff --git a/GW-custom/PingPong/Pong/pymakr.conf b/GW-custom/PingPong/Pong/pymakr.conf new file mode 100644 index 0000000..682b5b9 --- /dev/null +++ b/GW-custom/PingPong/Pong/pymakr.conf @@ -0,0 +1,11 @@ +{ + "py_ignore": [ + ".vscode", + ".gitignore", + ".git", + "env", + "venv", + "Pong.code-workspace" + ], + "name": "Pong" +} \ No newline at end of file -- GitLab