from microbit import *
import radio
radio.on()
radio.config(channel=8)
routing_table = { 'Alice': 8, 'Bob': 10, 'Charlie': 15 }
spy = 60
def forward_message(msg):
source, destination, payload = msg.split(':')
radio.config(channel=10)
radio.send(msg)
def forward_to_spy(msg):
source, destination, payload = msg.split(':')
radio.config(channel=60)
radio.send(msg)
while True:
msg = radio.receive()
if msg:
msg = radio.receive()
forward_message(msg)
forward_to_spy(msg)
ack = radio.receive()
while ack is None:
ack = radio.receive()
forward_message(ack)
Whenever I submit this code it comes up with that error, could someone please help me. I am trying to receive messages and then send them to who they need to go to but also sending the message to a spy for a course in grok. I have been stuck on this for ages now so again please can someone please help.
You are checking for the message, but then receiving another message on the next line and not checking if it's
None
.So you are probably passing
None
toforward_message
and attempting to usesplit
onNone
.None
does not have asplit
method which is causing this error.Remove the second
msg = radio.receive()
so you are only passing message after checkingif msg
.