# user code to be inserted, to send packet to the designated Mesh-external interface for _ in range(3): pycom.rgbled(0x888888) time.sleep(.2) pycom.rgbled(0) time.sleep(.1) return pycom.heartbeat(False) # read config file, or set default values pymesh_config = PymeshConfig.read_config() #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) # mac = pymesh.mac() # if mac > 10: # pymesh.end_device(True) # elif mac == 5: # pymesh.leader_priority(255) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) # send message to the Node having MAC address 5 pymesh.send_mess(5, "Hello World") # def new_br_message_cb(rcv_ip, rcv_port, rcv_data, dest_ip, dest_port):
gc.collect() return gc.enable() print("Current available memory: %d" % gc.mem_free()) pycom.heartbeat(False) # Build SD files system file_ops.sd_setup() #Load pymesh settings, ead from SD card pymesh_config = PymeshConfig.read_config() print("====================================================================") #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) node = cmf.NodeFuncs(pymesh) # if mac > 10: # pymesh.end_device(True) # if mac == 20: # pymesh.leader_priority(255) # elif mac == 15: # pymesh.leader_priority(250) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) print("Current available memory after pymesh load: %d" % gc.mem_free()) gc.collect()
print('Incoming %d bytes from %s (port %d):' % (len(rcv_data), rcv_ip, rcv_port)) print(rcv_data) # user code to be inserted, to send packet to the designated Mesh-external interface # ... return pycom.heartbeat(False) # read config file, or set default values pymesh_config = PymeshConfig.read_config() #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) mac = pymesh.mac() if mac > 10: pymesh.end_device(True) elif mac == 5: pymesh.leader_priority(255) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) # send message to the Node having MAC address 5 pymesh.send_mess(5, "Hello World") # def new_br_message_cb(rcv_ip, rcv_port, rcv_data, dest_ip, dest_port):
for _ in range(3): pycom.rgbled(0x888888) time.sleep(.2) pycom.rgbled(0) time.sleep(.1) return pycom.heartbeat(False) # read config file, or set default values pymesh_config = PymeshConfig.read_config() #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) py = Pycoproc() mac = pymesh.mac() # if mac > 10: # pymesh.end_device(True) if mac == 20: pymesh.leader_priority(255) elif mac == 15: pymesh.leader_priority(250) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) # def new_br_message_cb(rcv_ip, rcv_port, rcv_data, dest_ip, dest_port): # ''' callback triggered when a new packet arrived for the current Border Router,
pycom.rgbled(0x663300) # time.sleep(.2) if pybytes is not None and pybytes.isconnected(): pkt = 'BR %d B from %s (%d), to %s ( %d): %s'%(len(rcv_data), rcv_ip, rcv_port, dest_ip, dest_port, str(rcv_data)) pybytes.send_signal(1, pkt) return pycom.heartbeat(False) # read config file, or set default values pymesh_config = PymeshConfig.read_config() #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) # mac = pymesh.mac() # if mac > 10: # pymesh.end_device(True) # elif mac == 5: # pymesh.leader_priority(255) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) # send message to the Node having MAC address 5 pymesh.send_mess(2, "Hello World")
time.sleep(.2) pycom.rgbled(0) time.sleep(.1) return pycom.heartbeat(False) lora = LoRa(mode=LoRa.LORA, region=LoRa.EU868) lora_mac = int(str(ubinascii.hexlify(lora.mac()))[2:-1], 16) # read config file, or set default values pymesh_config = PymeshConfig.read_config(lora_mac) #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) while not pymesh.is_connected(): print(pymesh.status_str()) time.sleep(3) # send message to the Node having MAC address 5 pymesh.send_mess(20, "Hello World") print("done Pymesh init, forever loop, exit/stop with Ctrl+C multiple times") from lorawan import Lorawan lorawan = Lorawan() t0 = time.time() while True:
machine.idle() # save power while waiting print('WLAN connection succeeded!') print('IP - MASK - ROUTER - DNS') print(wlan.ifconfig()) break else: print('Network not found!') break pycom.heartbeat(False) # read config file, or set default values pymesh_config = PymeshConfig.read_config() #initialize Pymesh pymesh = Pymesh(pymesh_config, new_message_cb) mac = pymesh.mac() # based on LoRa MAC address, some nodes could be forced to be # sleep-end-devices (always Child) or to have increased Leader priority # if mac > 10: # pymesh.end_device(True) # elif mac == 5: # pymesh.leader_priority(255) # while not pymesh.is_connected(): # print(pymesh.status_str()) # time.sleep(3) # send message to the Node having MAC address 5 pymesh.send_mess(5, "Hello World")