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

Skip to content

Commit c372c91

Browse files
author
Catalin Ioana
committed
[pymesh] updated to match Pymesh release v1.20.2.r1
1 parent b10a173 commit c372c91

File tree

7 files changed

+171
-239
lines changed

7 files changed

+171
-239
lines changed

pymesh/pymesh_frozen/lib/ble_rpc.py

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,8 @@ def resolve(self, obj):
212212
#print('message', message)
213213
self.rx_worker.put(message)
214214

215-
def demo_fn(self, *args):
216-
return { 'res': 'demo_fn' }
217-
218-
def demo_echo_fn(self, *args):
219-
return args
215+
# def demo_echo_fn(self, *args):
216+
# return args
220217

221218
def mesh_is_connected(self):
222219
# True if Node is connected to Mesh; False otherwise
@@ -312,50 +309,50 @@ def receive_message(self):
312309
} """
313310
return self.mesh.get_rcv_message()
314311

315-
def send_image(self, data):
316-
""" sends an image
317-
return True if there is buffer to store it (to be sent)"""
318-
print("Send Image ---------------------->>>>>>>> ", data)
319-
start = 0
320-
filename = 'dog_2.jpg'
321-
to = 0
322-
# packsize = 500
323-
image = list()
324-
325-
try:
326-
filename = data.get('fn', "image.jpg")
327-
start = int(data['start'])
328-
image = bytes(data['image'])
329-
except:
330-
print('parsing failed')
331-
return False
332-
333-
print("Image chunk size: %d"%len(image))
334-
file_handling = "ab" # append, by default
335-
if start == 0:
336-
file_handling = "wb" # write/create new
337-
338-
with open("/flash/" + filename, file_handling) as file:
339-
print("file open")
340-
file.write(image)
341-
print("file written")
342-
343-
print("done")
344-
return True
345-
346-
def stat_start(self, data):
347-
# do some statistics
348-
#data = {'mac':6, 'n':3, 't':30}
349-
res = self.mesh.statistics_start(data)
350-
print("rpc stat_start? ", res)
351-
return res
352-
353-
def stat_status(self, data):
354-
print("rpc stat_status ", data)
355-
try:
356-
id = int(data)
357-
except:
358-
id = 0
359-
res = self.mesh.statistics_get(id)
360-
print("rpc stat_status id:"+ str(id) + ", res: " + str(res))
361-
return res
312+
# def send_image(self, data):
313+
# """ sends an image
314+
# return True if there is buffer to store it (to be sent)"""
315+
# print("Send Image ---------------------->>>>>>>> ", data)
316+
# start = 0
317+
# filename = 'dog_2.jpg'
318+
# to = 0
319+
# # packsize = 500
320+
# image = list()
321+
322+
# try:
323+
# filename = data.get('fn', "image.jpg")
324+
# start = int(data['start'])
325+
# image = bytes(data['image'])
326+
# except:
327+
# print('parsing failed')
328+
# return False
329+
330+
# print("Image chunk size: %d"%len(image))
331+
# file_handling = "ab" # append, by default
332+
# if start == 0:
333+
# file_handling = "wb" # write/create new
334+
335+
# with open("/flash/" + filename, file_handling) as file:
336+
# print("file open")
337+
# file.write(image)
338+
# print("file written")
339+
340+
# print("done")
341+
# return True
342+
343+
# def stat_start(self, data):
344+
# # do some statistics
345+
# #data = {'mac':6, 'n':3, 't':30}
346+
# res = self.mesh.statistics_start(data)
347+
# print("rpc stat_start? ", res)
348+
# return res
349+
350+
# def stat_status(self, data):
351+
# print("rpc stat_status ", data)
352+
# try:
353+
# id = int(data)
354+
# except:
355+
# id = 0
356+
# res = self.mesh.statistics_get(id)
357+
# print("rpc stat_status id:"+ str(id) + ", res: " + str(res))
358+
# return res

pymesh/pymesh_frozen/lib/cli.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, mesh):
3636
# lamda functions
3737
self.sleep = None
3838
return
39-
39+
4040
def process(self, arg1, arg2):
4141
last_mesh_pairs = []
4242
last_mesh_mac_list = []
@@ -46,13 +46,6 @@ def process(self, arg1, arg2):
4646
while True:
4747
time.sleep(.1)
4848
cmd = input('>')
49-
# cmd = " "
50-
# time.sleep(3)
51-
# print("cli")
52-
53-
# if cmd == 'rb':
54-
# print('resetting unpacker buffer')
55-
# self.rpc_handler = RPCHandler(rx_worker, tx_worker, mesh, ble_comm)
5649

5750
if cmd == 'ip':
5851
print(self.mesh.ip())
@@ -96,18 +89,17 @@ def process(self, arg1, arg2):
9689
elif cmd == 's':
9790
try:
9891
to = int(input('(to)<'))
99-
typ = input('(type, 0=text, 1=file, Enter for text)<')
100-
if not typ:
101-
typ = 0
102-
else:
103-
typ = int(typ)
104-
txt = input('(text/filename)<')
92+
# typ = input('(type, 0=text, 1=file, Enter for text)<')
93+
# if not typ:
94+
# typ = 0
95+
# else:
96+
# typ = int(typ)
97+
txt = input('(message)<')
10598
except:
106-
print("Command parsing failed")
10799
continue
108100
data = {
109101
'to': to,
110-
'ty': typ,
102+
# 'ty': 0,
111103
'b': txt,
112104
'id': 12345,
113105
'ts': int(time.time()),
@@ -132,7 +124,7 @@ def process(self, arg1, arg2):
132124
except:
133125
print("Gps:", (Gps.lat, Gps.lon))
134126
continue
135-
127+
136128
Gps.set_location(lat, lon)
137129
print("Gps:", (Gps.lat, Gps.lon))
138130

@@ -177,7 +169,7 @@ def process(self, arg1, arg2):
177169
self.mesh.mesh.mesh.mesh.deinit()
178170
if self.sleep:
179171
self.sleep(1)
180-
172+
181173
# elif cmd == "pyb":
182174
# # print("Pybytes debug menu, Pybytes connection is ", Pybytes_wrap.is_connected())
183175
# state = 1
@@ -228,14 +220,14 @@ def process(self, arg1, arg2):
228220
data = {
229221
'ip': ip,
230222
'port': port,
231-
'b': payload
223+
'b': payload
232224
}
233225
print("Send BR message:", data)
234226
self.mesh.send_message(data)
235227

236228
elif cmd == "buf":
237229
print("Buffer info:",self.mesh.mesh.mesh.mesh.cli("bufferinfo"))
238-
230+
239231
elif cmd == "ot":
240232
cli = input('(openthread cli)<')
241233
print(self.mesh.mesh.mesh.mesh.cli(cli))
@@ -247,7 +239,7 @@ def process(self, arg1, arg2):
247239
self.mesh.debug_level(level)
248240
except:
249241
print_debug(1, "error parsing")
250-
242+
251243
elif cmd == "config":
252244
print(self.mesh.config)
253245

@@ -272,7 +264,7 @@ def process(self, arg1, arg2):
272264
print("debug - set debug level")
273265
print("config - print config file contents")
274266
print("gps - get/set location coordinates")
275-
267+
276268
except KeyboardInterrupt:
277269
print('cli Got Ctrl-C')
278270
except Exception as e:
@@ -291,4 +283,4 @@ def new_br_message_cb(self, rcv_ip, rcv_port, rcv_data, dest_ip, dest_port):
291283

292284
# user code to be inserted, to send packet to the designated Mesh-external interface
293285
# ...
294-
return
286+
return

pymesh/pymesh_frozen/lib/loramesh.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,20 @@ def ipaddr(self):
233233
""" returns all unicast IPv6 addr """
234234
return self.mesh.ipaddr()
235235

236-
def ping(self, ip):
237-
""" Returns ping return time, to an IP """
238-
res = self.cli('ping ' + str(ip))
239-
# '8 bytes from fdde:ad00:beef:0:0:ff:fe00:e000: icmp_seq=2 hlim=64 time=236ms\r\n'
240-
# 'Error 6: Parse\r\n'
241-
# no answer
242-
ret_time = -1
243-
try:
244-
ret_time = int(res.split('time=')[1].split('ms')[0])
245-
except Exception:
246-
pass
247-
return ret_time
236+
# def ping(self, ip):
237+
# """ Returns ping return time, to an IP """
238+
# res = self.cli('ping ' + str(ip))
239+
# """
240+
# '8 bytes from fdde:ad00:beef:0:0:ff:fe00:e000: icmp_seq=2 hlim=64 time=236ms\r\n'
241+
# 'Error 6: Parse\r\n'
242+
# no answer
243+
# """
244+
# ret_time = -1
245+
# try:
246+
# ret_time = int(res.split('time=')[1].split('ms')[0])
247+
# except Exception:
248+
# pass
249+
# return ret_time
248250

249251
def blink(self, num = 3, period = .5, color = None):
250252
""" LED blink """
@@ -300,7 +302,7 @@ def neighbors_update(self):
300302
# pass
301303
# add own info in dict
302304
#self.neigh_dict[self.MAC] = (0, self.rloc16, self.state, 0)
303-
print_debug(5, "Neighbors: %s"%(self.router_data.to_string()))
305+
print_debug(3, "Neighbors: %s"%(self.router_data.to_string()))
304306
return
305307

306308
def leader_add_own_neigh(self):

0 commit comments

Comments
 (0)