parent
37bd7257d3
commit
02d7e5f264
4 changed files with 41 additions and 1 deletions
@ -0,0 +1,34 @@ |
||||
from microbit import * |
||||
import radio |
||||
|
||||
CONTROL_CHAR = "*" |
||||
|
||||
RADIO_GROUP = 222 |
||||
RADIO_CHANNEL = 5 |
||||
RADIO_LENGTH = 36 |
||||
MSG_LENGTH = RADIO_LENGTH - 3 |
||||
|
||||
DELAY = 0 |
||||
|
||||
def setup(): |
||||
print("Starting...") |
||||
|
||||
print("Turning radio on...") |
||||
radio.on() |
||||
radio.config(group=RADIO_GROUP, channel=RADIO_CHANNEL, length=RADIO_LENGTH) |
||||
|
||||
while True: |
||||
loop() |
||||
sleep(DELAY) |
||||
|
||||
def loop(): |
||||
#get message from buffer |
||||
incoming = radio.receive() |
||||
|
||||
#perform a bunch of sanity checks to insure this is a valid message |
||||
#TODO: investigate performance impact of sanity checks, maybe this should be done at app level |
||||
#TODO: investigate performance speed up of direct byte encoding instead of string manipulation |
||||
if incoming != None and incoming[0] == CONTROL_CHAR and len(incoming) == MSG_LENGTH: |
||||
print(incoming) |
||||
|
||||
setup() |
Loading…
Reference in new issue