Skip to content

Commit

Permalink
Merge pull request #17 from tuftsceeo/main
Browse files Browse the repository at this point in the history
Catch up
  • Loading branch information
NicK4rT authored Nov 20, 2024
2 parents 4319ccf + 34ebbb2 commit 6b12a17
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from networking import Networking

#Network
networking = Networking(False, False, True)
networking = Networking()
peer_mac = b'\xff\xff\xff\xff\xff\xff'

print("Running default networking tool")
print(f"Name: {networking.name}, ID: {networking.id}, config: {networking.config}, Sta mac: {networking.sta.mac()}, Ap mac: {networking.ap.mac()}, Version: {networking.version_n}")


Expand Down Expand Up @@ -39,5 +40,3 @@ def boop(pin):
print(f"{int(time.ticks_ms()-start_time)/1000}: {gc.mem_free()} bytes")
time.sleep(1)
gc.collect()


44 changes: 44 additions & 0 deletions software/networking/examples/pyscript_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
from machine import Pin
import gc
gc.collect()

import time

from networking import Networking

#Network
networking = Networking(True, False, True)
peer_mac = b'\xff\xff\xff\xff\xff\xff'

print("Running pyscript networking tool")
print(f"Name: {networking.name}, ID: {networking.id}, config: {networking.config}, Sta mac: {networking.sta.mac()}, Ap mac: {networking.ap.mac()}, Version: {networking.version_n}")


lastPressed = 0
start_time = time.ticks_ms()

message="Boop!"

def boop(pin):
global lastPressed
if(time.ticks_ms()-lastPressed>1000):
lastPressed = time.ticks_ms()
networking.aen.ping(peer_mac)
networking.aen.echo(peer_mac, message)
networking.aen.send(peer_mac, message)
print(f"Sent {message} to {peer_mac}")
print(networking.aen.rssi())

switch_select = Pin(9, Pin.IN, Pin.PULL_UP)

#Buttons
switch_select = Pin(9, Pin.IN, Pin.PULL_UP)
switch_select.irq(trigger=Pin.IRQ_FALLING, handler=boop)

while True:
print(f"{int(time.ticks_ms()-start_time)/1000}: {gc.mem_free()} bytes")
time.sleep(1)
gc.collect()


0 comments on commit 6b12a17

Please sign in to comment.