Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60f2592

Browse files
cuca94Catalin Ioana
authored and
Catalin Ioana
committed
Fix/loramesh example (pycom#103)
* fixed receive callback function rc_cb needs two parameters, the callback routine and the sockets which should be checked for incoming data (https://docs.pycom.io/firmwareapi/pycom/network/lora/pymesh.html#meshrxcbhandler-argument) without fixing this, the example will crash after connecting to the mesh network see forum entry: https://forum.pycom.io/topic/4912/loramesh-example-crashing-on-lopy4 * added copyright notes
1 parent adb22c2 commit 60f2592

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/lora_mesh/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
break
4040

4141
# create UDP socket
42+
sockets = []
4243
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
4344
myport = 1234
4445
s.bind(myport)
46+
sockets.append(s)
4547

4648
# handler responisble for receiving packets on UDP Pymesh socket
47-
def receive_pack():
49+
def receive_pack(sockets):
4850
# listen for incomming packets
4951
while True:
5052
rcv_data, rcv_addr = s.recvfrom(128)
@@ -65,7 +67,7 @@ def receive_pack():
6567
pack_num = 1
6668
msg = "Hello World! MAC: " + MAC + ", pack: "
6769
ip = mesh.ip()
68-
mesh.mesh.rx_cb(receive_pack)
70+
mesh.mesh.rx_cb(receive_pack,sockets)
6971

7072
# infinite main loop
7173
while True:

0 commit comments

Comments
 (0)